Local Memory: 3.1 Using Local Memory Heaps: Creating a Local Heap

Up: GEOS SDK TechDocs | Up | Prev: 3 Using Local Memory Heaps | Next: 3.2 Using Chunks
LMemInitHeap(), MemAllocLMem()

Before you create a local heap, you must first allocate and lock a block on the global heap using MemAlloc() and MemLock() . (Alternatively, you can allocate a fixed block.) Then, you must call LMemInitHeap() . (If you are creating a local heap to hold objects, you should use the UserAllocObjBlock() routine instead; it's much simpler to use.)

LMemInitHeap() creates and initializes a local memory heap. It must be passed several arguments:

LMemInitHeap() creates the LMemBlockHeader and the chunk handle table. It also creates a single free chunk; more chunks will automatically be created as needed. It may resize the block passed (unless the flag LMF_NO_ENLARGE is passed); therefore, any pointers to the block may become invalid. It does not return anything.

If you want to create a memory block and initialize it as an LMem heap in one operation, call MemAllocLMem() . This routine takes two arguments: a member of the LMemType enumerated type, and the amount of space to leave for the header (again, a zero size indicates that the default header size should be used). MemAllocLMem() allocates a movable, swapable block in the global heap, then initializes an LMem heap in that block. If you specify an LMemType of LMEM_TYPE_OBJ_BLOCK, MemAllocLMem() will pass the STD_LMEM_OBJECT_FLAGS flags; otherwise, it will pass a clear LocalMemoryFlags record.


Up: GEOS SDK TechDocs | Up | Prev: 3 Using Local Memory Heaps | Next: 3.2 Using Chunks