MEMCreateUnitHeapEx

Syntax

#include <revolution/mem.h>

MEMHeapHandle MEMCreateUnitHeapEx(
                        void*       startAddress,
                        u32         heapSize,
                        u32         memBlockSize,
                        u32         alignment,
                        u16         optFlag );

Arguments

startAddress Starting address of the memory region allocated to the heap.
heapSize Size (in bytes) of the memory region allocated to the heap.
memBlockSize Size (in bytes) of the memory block.
alignment Memory block alignment. Can take any of the following values: 4, 8, 16, 32.
optFlag Heap options (see details below).

Return Values

Returns the heap handle when a heap was successfully created. Returns MEM_HEAP_INVALID_HANDLE (a null value) if a heap could not be created.

Description

Creates the unit heap. The heap region is a memory region with size heapSize and a start address specified by startAddress.

Each memory block has a fixed size specified by memBlockSize. Each memory block has an alignment specified by alignment with 4, 8, 16, and 32 as possible values.

Heap options can be specified with optFlag.

MEM_HEAP_OPT_0_CLEAR The allocated memory block is filled with zeroes upon allocation from the heap.
MEM_HEAP_OPT_DEBUG_FILL Upon heap creation or whenever memory blocks are allocated or deallocated, each is filled with different 32-bit values in the memory region. This flag is used for debugging to find memory access bugs caused by either a failure to initialize memory or invalid memory regions. This option is not valid for the FINALROM version of the library.
MEM_HEAP_OPT_THREAD_SAFE Enables exclusive processing between threads. (Note that this will not run safely if it is called during an interrupt.)

See Also

MEMCreateUnitHeap

Revision History

2007/08/20 Added a note regarding calling during interrupts.
2006/03/01 Initial version.


CONFIDENTIAL