Functions | |
void * | Malloc (int size) |
Dynamically allocate memory from the heap. | |
void * | MallocWait (int size, int interval) |
Same as Malloc, but keeps trying until it succeeds. | |
void | Free (void *memory) |
Free memory from the heap. |
FreeRTOS has several options for memory management - we've chosen a default one here which is pretty sensible in most cases, but you're of course welcome to use whatever makes most sense for your application. See http://www.freertos.org/a00111.html for the available options.
void Free | ( | void * | memory | ) |
Free memory from the heap.
Once you've allocated memory using Malloc(), free it when you're done with it. It's usually a good idea to set the pointer the freed memory to NULL after you've freed it.
memory | A pointer to the memory created by Malloc( ) |
void* Malloc | ( | int | size | ) |
Dynamically allocate memory from the heap.
This is pretty much the same as a normal malloc(), but for the SAM7X.
int bufferSize = 1024; char *bufferPtr = Malloc( bufferSize ); // now you have a 1024 character buffer
void* MallocWait | ( | int | size, | |
int | interval | |||
) |
Same as Malloc, but keeps trying until it succeeds.
This is a convenience function that will continue to call Malloc( ) at a given interval until it returns successfully. Once this function returns, you know you have been allocated the memory you asked for.
size | An integer specifying the amount of memory, in bytes, you want to allocate. | |
interval | An integer specifying the number of milliseconds to wait between successive attempts to allocate memory. It's best to not set this too low, as it will be a bit taxing on the system. |
char *bufferPtr = MallocWait( 1024, 100 ); // now you have a 1024 character buffer