Skip to content

Commit

Permalink
add some global heap hint documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
JacobBarthelmeh committed May 23, 2024
1 parent 8089fe9 commit d29e2e1
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions wolfSSL/src/chapter04.md
Original file line number Diff line number Diff line change
Expand Up @@ -646,6 +646,20 @@ unsigned char IO_MEM[IO_MEM_SIZE]; 

After this, when you are done using the WOLFSSL_CTX structure, free it with the usual wolfSSL_CTX_free().

#### Setting a Global Heap Hint

A global heap hint can be set using the API `void* wolfSSL_SetGlobalHeapHint(void* heap)`.
When a global heap hint is set all calls to XMALLOC and XFREE using a NULL pointer as the
heap hint will be redirected to use the global heap hint set. This is useful in cases where
no system malloc is available to fall back to and NULL heap hint pointers are being used.
The function wolfSSL_SetGlobalHeapHint returns the current global heap hint set, and is NOT
considered to be thread safe.

The getter function `void* wolfSSL_GetGlobalHeapHint(void)` can be used to get the current
global heap hint set.

This functionality was added in versions of wolfSSL after version 5.7.0.

### Adjustment of Static Buffer Allocation

The static-buffer-allocation option provided by wolfSSL manages the specified buffer by dividing it into multiple areas called "buckets" as shown in the following diagram. Multiple memory blocks of the same size are linked within a bucket. The figure below omits the structure that manages the memory block, but a buffer with a size that includes the omitted structure is required.
Expand Down

0 comments on commit d29e2e1

Please sign in to comment.