|
LAR Library
1.14
|
Functions | |
| void * | memAlloc (int nb) |
| Allocate a block of memory from the heap. More... | |
| void * | memAllocZero (int nb) |
| Allocate and zero a block of memory from the heap. More... | |
| void * | memRealloc (void *oldp, int nb) |
| Resize a block of memory, or allocate a new one. More... | |
| void | memFree (void *p) |
| Release a previously allocated block. More... | |
Detailed Description
Rationale
Memory management is important, specially in an embedded environment. Besides not all platforms correctly supporting ANSI C, having our own memory-allocation functions allow for easier debugging of applications.
Introduction
This modules includes portable memory-management functions. All modules of larlib use this functions. They may allow improved debugging / tracing support than any given platform's built-in implementation.
Function Documentation
| void* memAlloc | ( | int | nb | ) |
Allocate a block of memory from the heap.
The memory allocated by this function should only be accessed by the calling application. The pointer is not guaranteed to be valid for other applications.
- Parameters
-
nb Number of bytes to allocate.
- Returns
NULLif memory could not be allocated.- A pointer to the newly allocated, uninitialized, block.
| void* memAllocZero | ( | int | nb | ) |
Allocate and zero a block of memory from the heap.
This is equivalent to calling memAlloc() followed by memset().
- Parameters
-
nb Number of bytes to allocate.
- Returns
NULLif memory could not be allocated.- A pointer to the newly allocated, zero-initialized, block.
| void memFree | ( | void * | p | ) |
Release a previously allocated block.
- Parameters
-
p A pointer returned by memAlloc()
| void* memRealloc | ( | void * | oldp, |
| int | nb | ||
| ) |
Resize a block of memory, or allocate a new one.
The data pointed by oldp is shallow-copied (using memcpy()) to the new pointer on success. This is equivalent to the ANSI C function realloc().
- Parameters
-
oldp Address of the memory block to resize. nb Number of bytes to resize oldpto.
- Returns
NULLifoldpcould not be resized and new memory could not be allocated.-
A pointer to the newly allocated memory, its prefix is the same as
oldp.
Generated on Mon Mar 27 2017 15:42:53 for LAR Library by
1.8.9.1