|
AWS IoT Device SDK C:
Static Memory
Statically-allocated buffer pools
|
| Return to main page ↑ |
Common functions for managing static buffers. Only used when IOT_STATIC_MEMORY_ONLY is 1.
More...
#include "iot_config.h"#include <stddef.h>#include <stdint.h>Go to the source code of this file.
Functions | |
| int32_t | IotStaticMemory_FindFree (uint32_t *pInUse, size_t limit) |
| Find a free buffer using the "in-use" flags. More... | |
| void | IotStaticMemory_ReturnInUse (void *ptr, void *pPool, uint32_t *pInUse, size_t limit, size_t elementSize) |
| Return an "in-use" buffer. More... | |
| size_t | Iot_MessageBufferSize (void) |
| Get the fixed size of a message buffer. More... | |
| void * | Iot_MallocMessageBuffer (size_t size) |
| Get an empty message buffer. More... | |
| void | Iot_FreeMessageBuffer (void *ptr) |
| Free an in-use message buffer. More... | |
Common functions for managing static buffers. Only used when IOT_STATIC_MEMORY_ONLY is 1.
| int32_t IotStaticMemory_FindFree | ( | uint32_t * | pInUse, |
| size_t | limit | ||
| ) |
Find a free buffer using the "in-use" flags.
If a free buffer is found, this function marks the buffer in-use. This function is common to the static memory implementation.
| [in] | pInUse | The "in-use" flags to search. |
| [in] | limit | How many flags to check, i.e. the size of pInUse. |
-1 if no free buffers are available.Example:
| void IotStaticMemory_ReturnInUse | ( | void * | ptr, |
| void * | pPool, | ||
| uint32_t * | pInUse, | ||
| size_t | limit, | ||
| size_t | elementSize | ||
| ) |
Return an "in-use" buffer.
This function is common to the static memory implementation.
| [in] | ptr | Pointer to the buffer to return. |
| [in] | pPool | The pool of buffers that the in-use buffer was allocated from. |
| [in] | pInUse | The "in-use" flags for pPool. |
| [in] | limit | How many buffers (and flags) to check while searching for ptr. |
| [in] | elementSize | The size of a single element in pPool. |
Example:
| size_t Iot_MessageBufferSize | ( | void | ) |
Get the fixed size of a message buffer.
The size of the message buffers are known at compile time, but it is a constant that may not be visible to all source files. This function allows other source files to know the size of a message buffer.
| void* Iot_MallocMessageBuffer | ( | size_t | size | ) |
Get an empty message buffer.
This function is the analog of malloc for message buffers.
| [in] | size | Requested size for a message buffer. |
size argument is larger than the fixed size of a message buffer or no message buffers are available, NULL is returned. | void Iot_FreeMessageBuffer | ( | void * | ptr | ) |
Free an in-use message buffer.
This function is the analog of free for message buffers.
| [in] | ptr | Pointer to the message buffer to free. |