Skip to content

Commit 4d21ab5

Browse files
author
Jack Tjaden
committed
Removed chapter 11 from PR
1 parent 5bc0b1f commit 4d21ab5

File tree

2 files changed

+38
-4
lines changed

2 files changed

+38
-4
lines changed

wolfSSL/src/CTX_structure.png

17.9 KB
Loading

wolfSSL/src/chapter04.md

+38-4
Original file line numberDiff line numberDiff line change
@@ -551,7 +551,10 @@ By default, wolfSSL assumes that the execution environment provides dynamic memo
551551

552552
Using static-buffer-allocation is equivalent in API to using dynamic memory with wolfSSL. This functional equivalency is achieved in wolfSSL by abstracting memory allocation/free into XMALLOC/XFREE function calls. Once static-buffer-allocation is set, wolfSSL will use it from then on to allocate buffers and other structures used internally. Since this feature is set for WOLFSSL_CTX, it will continue to work for the lifetime of the context object.
553553

554-
The static-buffer-allocation set in a WOLFSSL_CTX is thread-safe. Even if the same WOLFSSL_CTX is shared by different threads, buffer allocation/free is used under exclusive control inside wolfSSL.
554+
The static-buffer-allocation set in a WOLFSSL_CTX is thread-safe. Even if the same WOLFSSL_CTX is shared by different threads, buffer allocation/free is used under exclusive control inside wolfSSL. The following is a visual representation of the CTX structure, the arrows indicate passing a pointer to the heap and "..." references all structs and not to the ones listed.
555+
556+
![Alt text](CTX_structure.png)
557+
555558
In comparison to a memory pool functionality offered by an RTOS implementation, memory functionality in an RTOS will commonly suspend a thread (task) if an unused memory block cannot be found when requested until a free block becomes available. wolfSSL’s static memory functionality has no such synchronization capability.
556559

557560
### Specifying Static Buffer Use
@@ -582,6 +585,36 @@ user_settings.h
582585
#define WOLFSSL_NO_MALLOC
583586
```
584587

588+
In addition there are two build configurations. `--enable-staticmemory=small` which is a
589+
smaller version that has smaller struct sizes and less supporting API's available. The other build
590+
configuration is `--enable-staticmemory=debug` that enables the ability to set a callback function. This is
591+
useful in cases where printf() is not available for determining what is being allocated and what
592+
bucket sizes are being used. Here is what the example client output looks like with example
593+
callback:
594+
595+
```
596+
./examples/client/client
597+
...
598+
...
599+
...
600+
Free'ing : 16128
601+
OUT BUFFER: Alloc'd 6 bytes using bucket size 16992
602+
Alloc'd 848 bytes using bucket size 1024
603+
OUT BUFFER: Alloc'd 150 bytes using bucket size 16992
604+
Alloc'd 13 bytes using bucket size 64
605+
Alloc'd 12 bytes using bucket size 64
606+
Alloc'd 848 bytes using bucket size 1024
607+
IN BUFFER: Alloc'd 40 bytes using bucket size 16992
608+
Alloc'd 13 bytes using bucket size 64
609+
Alloc'd 12 bytes using bucket size 64
610+
Free'ing : 1024
611+
Free'ing : 512
612+
613+
...
614+
...
615+
...
616+
```
617+
585618
### Using Static Buffer Allocation
586619

587620
This can be helpful for environments without dynamic memory support, or safety-critical applications where dynamic memory use is disallowed.
@@ -727,9 +760,10 @@ For DTLS server
727760

728761
|API|description|
729762
|:---|:---|
730-
|`wolfSSL_CTX_load_static_memory`|Set buffer for WOLFSSL_CTX as a heap memory.
731-
|`wolfSSL_CTX_is_static_memory`|Returns whether "Static buffer Allocation" is used. If it is the case, gets usage report.
732-
|`wolfSSL_is_static_memory`|Returns whether "Static buffer Allocation" is used. If it is the case, gets usage report. |
763+
|[`wolfSSL_CTX_load_static_memory`](group__Memory.md#function-wolfSSL_CTX_static_memory)| Set buffer for WOLFSSL_CTX as a heap memory. |
764+
|[`wolfSSL_CTX_is_static_memory`](group__Memory.md#function-wolfSSL_CTX_is_static_memory)| Returns whether "Static buffer Allocation" is used. If it is the case, gets usage report. |
765+
|[`wolfSSL_is_static_memory`](group__Memory.md#function-wolfSSL_is_static_memory)| Returns whether "Static buffer Allocation" is used. If it is the case, gets usage report. |
766+
|[`wc_LoadStaticMemory`](group__Memory.md#function-wc_LoadStaticMemory)| Used to set aside static memory for wolfCrypt use. |
733767
|[`wolfSSL_StaticBufferSz`](group__Memory.md#function-wolfssl_staticbuffersz)| Calculate required buffer size for "Static buffer Allocation" based on the macros defined in /wolfssl/wolfcrypt/memory.h. |
734768

735769

0 commit comments

Comments
 (0)