Description | Memory management |
Header file | LMemory.h |
Author | Camil Demetrescu |
Created | Dec 15, 2001 |
Last updated | Sep 25, 2003 |
The component LMemory provides support for dynamic heap storage allocation, memory copy, memory compare, and other memory-related functions.
Constants |
|
LMemory_ID LMemory_OUT_OF_MEMORY |
Macros with arguments |
|
LMemory_NewObject(T,O) LMemory_DeleteObject(O) |
Function | Arguments | Description | Returns | Throws |
Malloc
|
ui4 inSize | Allocate a memory block of inSize bytes. The value of bytes in the block is undefined. Caller is responsible of dellocating the created block using LMemory_Free. |
void* A pointer to the new block of memory. |
OUT_OF_MEMORY if operation failed. |
Calloc | ui4 inSize | Same as Malloc, except for the fact that bytes in the block are also set to 0. Caller is responsible of dellocating the created block using LMemory_Free. | A pointer to the new block of memory. | OUT_OF_MEMORY if operation failed. |
Realloc | void* inPtr | Change the size of a block of memory, while preserving its content. If necessary, the method copies the content to another block of memory. Caller is responsible of dellocating the created block using LMemory_Free. | A pointer to the new block of memory. | OUT_OF_MEMORY if operation failed. |
ui4 inSize | ||||
Free
|
void** inPtrA | Deallocate memory block *inPtrA previously allocated with Malloc, Calloc, or Realloc. *inPtrA is set to NULL. | - | - |
Copy | const void* inSource | Copy inSize bytes from inSource to outDest. If the source and destination blocks overlap, use Move. Copy might be faster than Move. | - | - |
void* outDest | ||||
ui4 inSize | ||||
Move | const void* inSource | Copy inSize bytes from inSource to outDest, even if the two blocks overlap. | - | - |
void* outDest | ||||
ui4 inSize | ||||
Set | void* outPtr | Copy value inByte into each of the first inSize bytes of the block outPtr. | - | - |
i1 inByte | ||||
ui4 inSize | ||||
Clear | void* outPtr | Copy value 0 into each of the first inSize bytes of the block outPtr. | - | - |
ui4 inSize | ||||
Compare | const void* inPtr1 | Perform a bytewise comparison of two blocks of memory. The first inSize bytes of the block inPtr1 are compared to the first inSize bytes of the block inPtr2. |
A positive i4 if inPtr1>inPtr2 Zero if inPtr1==inPtr2 A negative i4 if inPtr1<inPtr2 |
- |
const void* inPtr2 | ||||
ui4 inSize | ||||
GetBlocksCount
|
- | Returns the difference between the actual number of allocation and deallocation operations performed. Can be used to detect memory leaks or other memory-related problems. |
i4 |
- |
Macro | Arguments | Description | Returns | Throws |
NewObject
|
inType | Allocate a memory block of sizeof(inType) bytes. inObject is then copied to the new block, where inObject must have type inType. Caller is responsible of dellocating the created block using LMemory_DeleteObject. |
void* A pointer to the new block of memory. |
OUT_OF_MEMORY if operation failed. |
inObject | ||||
DeleteObject | inPtrA | Same as Free. | - | - |