#include <nitro/os.h>
void* OS_InitAlloc( OSArenaId id, void* arenaStart, void* arenaEnd, int maxHeaps );
id | The arena ID of the arena for which you will initialize the memory allocation system. |
arenaStart | Address of the arena's lower boundary |
arenaEnd | Address of the arena's upper boundary |
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.
Initializes memory allocation.
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.
Example:
void* nstart; // In 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.
OS_SetArenaLo
, OS_CreateHeap
, OS_ClearAlloc
2004/08/30 Added description for OS_ClearAlloc
.
2004/07/06 Added an example.
2004/01/06 Initial version.
CONFIDENTIAL