#include <nitro/os.h>
void* OS_InitAlloc( OSArenaId id, void* arenaStart, void* arenaEnd, int maxHeaps );
This function initializes the memory allocation system. This function must be called first before creating a heap that is specified by the arena ID id.
For more information about the arena ID value, see OS_InitArena.
An information region for heaps is reserved at the beginning of the arena. The address that is returned after OS_InitAlloc is the arena's lower boundary address (start address) after the region has been reserved. Therefore, set and correct using the OS_Set*ArenaLo function.
void* nstart; // On the main memory, initialize all of the arena for the heap region // Declares that the maximum number of the heap is 3 nstart = OS_InitAlloc( OS_ARENA_MAIN, OS_GetMainArenaLo, OS_GetMainArenaHi, 3 ); // Lower boundary address of the arena OS_SetMainArenaLo( nstart );
To start over with the setting, it is necessary to clear the memory allocation system information from arena by using the OS_ClearAlloc function.
id |
The arena ID of the arena for which you will initialize the memory allocation system. |
arenaStart |
The arena lower boundary address. |
arenaEnd |
The arena upper boundary address. |
maxHeap |
The maximum heap number that can be reserved in that arena. |
After acquiring the region for heap information at the start of the arena, this function returns the arena's actual 32-byte aligned, lower boundary address.
OS_SetArenaLo, OS_CreateHeap, OS_ClearAlloc
08/30/2004 Added description for OS_ClearAlloc
07/06/2004 Added an example
01/06/2004 Initial version