ChunkHandle LMemAlloc(
MemHandle mh, /* Handle of block containing heap */
word chunkSize); /* Size of new chunk in bytes */
This routine allocates a new chunk in the LMem heap. The heap must be locked or fixed. It allocates a chunk, expanding the chunk table if enccessary, and returns the chunk's handle. The chunk is not zero-initialized. If the chunk could not be allocated, it returns a null handle. Chunks are dword-aligned, so the chunk's actual size may be slightly larger than you request.
Include: lmem.h
Be Sure To: Lock the block on the global heap (unless the block is fixed).
Warnings: The heap may be compacted; thus, all pointers to chunks are invalidated. If LMF_NO_EXPAND is not set, the heap may be resized (and thus moved), thus invalidating all pointers to that block. Even fixed blocks can be resized and moved.
See Also: LMemDeref(),
LMemReAlloc().
void LMemContract(
MemHandle mh); /* Handle of LMem heap */
This routine contracts an LMem heap; that is, it deletes all the free chunks, moves all the used chunks to the beginning of the heap (right after the chunk handle table), and resizes the block to free the unused space at the end. It's a good idea to call this routine if you have just freed a lot of chunks, since that will free up some of the global heap. The LMem heap is guaranteed not to move; however, all pointers to chunks will be invalidated.
Be Sure To: Lock the block on the global heap (if it isn't fixed).
Include: lmem.h
void LMemDeleteAt(
optr chunk, /* Chunk to resize */
word deleteOffset, /* Offset within chunk of first
* byte to be deleted */
word deleteCount); /* # of bytes to delete */
This routine deletes a specified number of bytes from inside a chunk. It is guaranteed not to cause the heap to be resized or compacted; thus, pointers to other chunks remain valid.
Be Sure To: Lock the block on the global heap (unless it is fixed).
Warnings: The bytes you delete must all be in the chunk. If
deleteOffset
and
deleteCount
indicate bytes that are not in the chunk, results are undefined.
Include: lmem.h
See Also: LMemReAlloc(),
LMemInsertAt(),
LMemDeleteAtHandles().
void LMemDeleteAtHandles(
MemHandle mh, /* Handle of LMem heap */
ChunkHandle ch, /* Handle of chunk to resize */
word deleteOffset, /* Offset within chunk of first
* byte to be deleted */
word deleteCount); /* # of bytes to delete */
This routine is exactly like
LMemDeleteAt()
above, except that the chunk is specified by its global and chunk handles.
Be Sure To: Lock the block on the global heap (unless it is fixed).
Warnings: The bytes you delete must all be in the chunk. If
deleteOffset
and
deleteCount
indicate bytes that are not in the chunk, results are undefined.
Include: lmem.h
void * LMemDeref(
optr chunk); /* optr to chunk to dereference */
This routine translates an optr into the address of the chunk. The LMem heap must be locked or fixed on the global heap. Chunk addresses can be invalidated by many LMem routines, forcing you to dereference the optr again.
Be Sure To: Lock the block on the global heap (unless it is fixed).
Include: lmem.h
See Also: LMemDerefHandles().
void * LMemDerefHandles(
MemHandle mh, /* Handle of LMem heap's block */
ChunkHandle chunk); /* Handle of chunk to dereference */
This routine is exactly like
LMemDeref()
above, except that the chunk is specified by its global and chunk handles.
Be Sure To: Lock the block on the global heap (unless it is fixed).
Include: lmem.h
See Also: LMemDeref().
void LMemFree(
optr chunk); /*optr of chunk to free */
This routine frees a chunk from an LMem heap. The chunk is added to the heap's free list. The routine is guaranteed not to compact or resize the heap; thus, all pointers within the block remain valid (except for pointers to data in the freed chunk, of course).
Be Sure To: Lock the block on the global heap (unless it is fixed).
Include: lmem.h
See Also: LMemFreeHandles().
void LMemFreeHandles(
MemHandle mh, /* Handle of LMem heap */
ChunkHandle chunk); /* Handle of chunk to free */
This routine is just like
LMemFree()
above, except that the chunk is specified by its global and chunk handles (instead of by an optr).
Be Sure To: Lock the block on the global heap (unless it is fixed).
Include: lmem.h
GEOS SDK TechDocs
|
|
isalnum() ...
|
LMemGetChunkSize() ...