Files | |
file | otMalloc.h |
memory management library. | |
Modules | |
Version History | |
Functions | |
void | _initMalloc () |
Init malloc functions. This function must be called at setup time as first. | |
U32 | _memFree () |
Memory free. | |
void | _free (void *ptr) |
Deallocate memory block. A block of memory previously allocated by a call to malloc, calloc or realloc is deallocated, making it available again for further allocations. If ptr does not point to a block of memory allocated with the above functions, it causes undefined behavior. If ptr is a null pointer, the function does nothing. Notice that this function does not change the value of ptr itself, hence it still points to the same (now invalid) location. | |
void * | _malloc (U32 size) |
Allocate memory block. Allocates a block of size bytes of memory, returning a pointer to the beginning of the block. The content of the newly allocated block of memory is not initialized, remaining with indeterminate values. If size is zero, the return value depends on the particular library implementation (it may or may not be a null pointer), but the returned pointer shall not be dereferenced. | |
void * | _calloc (U32 size) |
Allocate and zero-initialize array. Allocates a block of memory for an array of size bytes long, and initializes all its bits to zero. | |
void * | _realloc (void *ptr, U32 size) |
Reallocate memory block. Changes the size of the memory block pointed to by ptr. The function may move the memory block to a new location (whose address is returned by the function). The content of the memory block is preserved up to the lesser of the new and old sizes, even if the block is moved to a new location. If the new size is larger, the value of the newly allocated portion is indeterminate. In case that ptr is a null pointer, the function behaves like _malloc, assigning a new block of size bytes and returning a pointer to its beginning. | |
void * | _reallocf (void *ptr, U32 size) |
|
|
|
|
|
|
|
|
|
|
|
|
|
The _reallocf() function changes the size of the previously allocated memory referenced by ptr to size bytes. The contents of the memory are unchanged up to the lesser of the new and old sizes. If the new size is larger, the contents of the newly allocated portion of the memory are undefined. Upon success, the memory referenced by ptr is freed and a pointer to the newly allocated memory is returned. Note that _reallocf() may move the memory allocation, resulting in a different return value than ptr. If ptr is NULL, the _reallocf() function behaves identically to _malloc() for the specified size. Upon failure, when the requested memory cannot be allocated, the passed pointer is freed to ease the problems with traditional coding styles for reallocf() causing memory leaks in libraries.
|