Platform-specific memory management functions.
More...
- Note
- This header only declares the memory management functions, and it is up to extensions to implement the underlying memory management functions.
TODO: ref to extensions
|
| void * | pb_malloc (size_t sz) |
| | Allocate a contiguous chunk of memory.
|
| |
| void | pb_free (void *ptr) |
| | Free a chunk of memory previously allocated with pb_malloc()
|
| |
| void * | pb_realloc (void *ptr, size_t sz) |
| | Resize the memory area ptr to size sz.
|
| |
| void * | pb_memcpy (void *dest, const void *src, size_t sz) |
| | copy a memory region
|
| |
| int | pb_memcmp (const void *a, const void *b, size_t sz) |
| | compare two memory regions
|
| |
◆ pb_free()
| void pb_free |
( |
void * | ptr | ) |
|
|
inline |
- Parameters
-
| ptr | Pointer to memory area |
◆ pb_malloc()
| void * pb_malloc |
( |
size_t | sz | ) |
|
|
inline |
- Parameters
-
| sz | Requested size of memory area |
- Returns
- Pointer to memory area, or
NULL on failure
- Note
- The allocated memory must be free'd again using
pb_free()
◆ pb_memcmp()
| int pb_memcmp |
( |
const void * | a, |
|
|
const void * | b, |
|
|
size_t | sz ) |
- Parameters
-
| a | Pointer to first memory region |
| b | Pointer to second memory region |
| sz | Number of bytes to compare |
- Returns
- 0 if the memory regions are identical, or the difference between the first non-matching byte
This function has a portable implementation, and is always available.
◆ pb_memcpy()
| void * pb_memcpy |
( |
void * | dest, |
|
|
const void * | src, |
|
|
size_t | sz ) |
- Parameters
-
| dest | Pointer to destination memory |
| src | Pointer to source memory |
| sz | Number of bytes to copy |
- Returns
- Pointer to
dest
This function has a portable implementation, and is always available.
◆ pb_realloc()
| void * pb_realloc |
( |
void * | ptr, |
|
|
size_t | sz ) |
|
inline |
- Parameters
-
| ptr | Pointer to allocated memory area |
| sz | Requested new size of memory area |
- Returns
- Pointer to memory area, or
NULL on failure
- Warning
- This function is not available on FreeRTOS, and should be avoided if possible. MPack's
mpack_writer_init_growable() is known to use realloc(), and should not be used for this reason.