puzzlebox
Loading...
Searching...
No Matches

Platform-specific memory management functions. More...

Detailed Description

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

Functions

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
 

Function Documentation

◆ pb_free()

void pb_free ( void * ptr)
inline
Parameters
ptrPointer to memory area

◆ pb_malloc()

void * pb_malloc ( size_t sz)
inline
Parameters
szRequested 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
aPointer to first memory region
bPointer to second memory region
szNumber 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
destPointer to destination memory
srcPointer to source memory
szNumber 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
ptrPointer to allocated memory area
szRequested 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.