Memory management header.
More...
Go to the source code of this file.
|
| struct | mem_stats |
| | Available to the user for display of memory statistics. More...
|
| |
Memory management header.
Definition in file memory.h.
◆ bMemValidate()
| abool bMemValidate |
( |
void * |
vpCtx | ) |
|
Validates a memory context.
- Parameters
-
| vpCtx | A pointer to a memory context. |
- Returns
- APG_TRUE if the handle is valid, APG_FALSE otherwise.
Definition at line 160 of file memory.c.
◆ spMemException()
Get a pointer to this memory objects's exception handler.
- Parameters
-
| vpCtx | A pointer to a valid memory context previously returned from vpMemCtor(). If invalid the application will silently exit with a BAD_CONTEXT exit code. |
- Returns
- Pointer to this memory object's exception structure
Definition at line 174 of file memory.c.
◆ uiMemCount()
| aint uiMemCount |
( |
void * |
vpCtx | ) |
|
Returns the number of memory allocations.
- Parameters
-
| vpCtx | A pointer to a valid memory context previously returned from vpMemCtor(). If invalid the application will silently exit with a BAD_CONTEXT exit code. |
- Returns
- Current number of allocations. vExContext() exception thrown if context pointer is invalid.
Definition at line 342 of file memory.c.
◆ vMemClear()
| void vMemClear |
( |
void * |
vpCtx | ) |
|
Frees all memory allocations.
- Parameters
-
| vpCtx | A pointer to a valid memory context previously returned from vpMemCtor(). If invalid the application will silently exit with a BAD_CONTEXT exit code. |
Definition at line 361 of file memory.c.
◆ vMemDtor()
| void vMemDtor |
( |
void * |
vpCtx | ) |
|
Destroys a Memory component. Frees all memory allocated.
- Parameters
-
| vpCtx | A pointer to a valid memory context previously returned from vpMemCtor(). Silently ignored if NULL. However, if non-NULL it must be a valid memory context pointer. |
Definition at line 141 of file memory.c.
◆ vMemFree()
| void vMemFree |
( |
void * |
vpCtx, |
|
|
const void * |
vpData |
|
) |
| |
Free memory previously allocated with vpMemAlloc().
- Parameters
-
| vpCtx | A pointer to a valid memory context previously returned from vpMemCtor(). If invalid the application will silently exit with a BAD_CONTEXT exit code. |
| vpData | Pointer to the data to free. A NULL pointer is silently ignored. However, an invalid pointer - a pointer not previously returned from vpMemAlloc() or vpMemRealloc() - will result in a thrown exception. vExContext() exception thrown if context pointer is invalid. |
Definition at line 226 of file memory.c.
◆ vMemStats()
| void vMemStats |
( |
void * |
vpCtx, |
|
|
mem_stats * |
spStats |
|
) |
| |
Returns a copy of the Memory component's current statistics.
- Parameters
-
| vpCtx | A pointer to a valid memory context previously returned from vpMemCtor(). If invalid the application will silently exit with a BAD_CONTEXT exit code. |
| spStats | pointer to a user-supplied statistics buffer. |
- Returns
- void
Definition at line 456 of file memory.c.
◆ vpMemAlloc()
| void* vpMemAlloc |
( |
void * |
vpCtx, |
|
|
aint |
uiBytes |
|
) |
| |
Allocates memory.
Note that uiBytes + sizeof(mem_cell) is actually allocated on the heap.
- The data is | cell struct | ... user data ... |
- The actual malloc() heap allocation is at cell struct
- The user data area is at heap allocation address + sizeof(cell struct)
- Parameters
-
| vpCtx | A pointer to a valid memory context previously returned from vpMemCtor(). If invalid the application will silently exit with a BAD_CONTEXT exit code. |
| uiBytes | the number of bytes of memory to allocate |
- Returns
- a pointer to the user data portion of the allocated memory. Exception thrown on memory allocation failure.
Definition at line 196 of file memory.c.
◆ vpMemCtor()
Construct a memory component.
- Parameters
-
| spException | Pointer to a valid exception structure initialized with vExCtor() or XCTOR(). If invalid the application will silently exit with a BAD_CONTEXT exit code. |
- Returns
- Pointer to a memory object context on success. Throws exception on memory allocation failure.
Definition at line 121 of file memory.c.
◆ vpMemRealloc()
| void* vpMemRealloc |
( |
void * |
vpCtx, |
|
|
const void * |
vpData, |
|
|
aint |
uiBytes |
|
) |
| |
Re-allocates memory previously allocated with vpMemAlloc().
Can be used to up-size or down-size a memory allocation. Any previous data in the memory allocation is copied to the re-allocation.
- Parameters
-
| vpCtx | A pointer to a valid memory context previously returned from vpMemCtor(). If invalid the application will silently exit with a BAD_CONTEXT exit code. |
| vpData | Pointer to the data to free. An invalid pointer - a pointer not previously returned from vpMemAlloc() or vpMemRealloc() - will result in a thrown exception. |
| uiBytes | number of re-allocated bytes of memory. Must be > 0; |
- Returns
- pointer to the re-allocated memory. Throws exception on memory allocation error, invalid data pointer error or uiBytes=0.
Definition at line 268 of file memory.c.
APG Version 7.0 is licensed under the
2-Clause BSD License,
an Open Source Initiative Approved License.