This section describes the functionality common among the expanded, frame, and unit heap.
Among the functions that can be used to create a heap, heap options can be specified using MEMCreateExpHeapEx, MEMCreateFrmHeapEx and MEMCreateUnitHeapEx. The following are options that can be specified.
| Flag | Description |
MEM_HEAP_OPT_0_CLEAR | The allocated memory block is filled with zeroes upon allocation from the heap. |
MEM_HEAP_OPT_DEBUG_FILL | At heap creation and/or at memory block allocation and freeing, the memory region is filled with different 32-bit values. |
MEM_HEAP_OPT_THREAD_SAFE | Enables exclusive processing between threads. |
The MEM_HEAP_OPT_DEBUG_FILL flag is used for debugging. Use this flag to find memory access bugs by tracing the pointer that points to the memory initialization failure or invalid memory regions. This flag will not function in the final ROM version of the library. The following values fill in memory regions by default. See the next section to learn how to change these values.
By specifying the MEM_HEAP_OPT_DEBUG_FILL flag when creating the heap, the memory region can be filled with a different 32-bit value during heap creation, memory block allocation and freeing, respectively. This fill value can be modified. You can set and get the fill values using the following functions.
| Function | Description |
MEMSetFillValForHeap | Sets fill values. |
MEMGetFillValForHeap | Gets fill values. |
Different values can be set when heaps are created, memory blocks are allocated, and memory blocks are freed. When you set or get values, the heap operation the values are specific to is set. The following table shows the types of heap operations specified in the function.
| Value Specified in the Function | Heap Operation |
MEM_HEAP_FILL_NOUSE | At heap creation. |
MEM_HEAP_FILL_ALLOC | At memory block allocation. |
MEM_HEAP_FILL_FREE | At memory block freeing. |
This feature for displaying the content of the heap is for debugging. The following functions accomplish this.
| Function | Description |
MEMDumpHeap | Displays internal heap data. |
This feature obtains the start and end address of memory regions used by the heaps. The following functions accomplish this.
| Function | Description |
MEMGetHeapStartAddress | Gets the starting address of the memory region used by the heap. |
MEMGetHeapEndAddress | Gets the ending address + 1 of the memory region used by the heap. |
03/01/2006 Initial version.