Collaboration diagram for Memory Management Utilities:
|
This system adds such features as callback routines for memory error events, tracing capabilities, and reference counting.
Files | |
| file | psMemory.h |
| Contains the definitions for the memory management system. | |
Modules | |
| Memory Callbacks | |
| Routines dealing with the creating and setting of memory management callback functions. | |
| Memory Tracing | |
| Routines dealing with memory tracing and corruption checking. | |
| Reference Count | |
| Routines dealing with the reference counting of allocated buffers. | |
Data Structures | |
| struct | psMemBlock |
| Book-keeping data for storage allocator. More... | |
Typedefs | |
| typedef psU64 | psMemoryId |
| typedef for memory identification numbers. Guaranteed to be some variety of integer. | |
| typedef psU64 | psReferenceCount |
| typedef for a memory block's reference count. Guaranteed to be some variety of integer. | |
| typedef void(* | psFreeFcn )(psPtr ptr) |
| typedef for deallocator. | |
| typedef psMemBlock | psMemBlock |
| Book-keeping data for storage allocator. | |
Functions | |
| psPtr | psAlloc (size_t size) |
| Memory allocation. | |
| void | psMemSetDeallocator (psPtr ptr, psFreeFcn freeFcn) |
| Set the deallocator routine. | |
| psFreeFcn | psMemGetDeallocator (psPtr ptr) |
| Get the deallocator routine. | |
| void | p_psMemSetPersistent (psPtr ptr, psBool value) |
| Set the memory as persistent so that it is ignored when detecting memory leaks. | |
| psBool | p_psMemGetPersistent (psPtr ptr) |
| Get the memory's persistent flag. | |
| psPtr | psRealloc (psPtr ptr, size_t size) |
| Memory re-allocation. | |
| void | psFree (psPtr ptr) |
| Free memory. | |
|
|
typedef for deallocator.
Definition at line 57 of file psMemory.h. |
|
|
Book-keeping data for storage allocator. N.b. sizeof(psMemBlock) must be chosen such that if ptr is a pointer returned by malloc, then ((char *)ptr + sizeof(psMemBlock)) is properly aligned for all storage types. |
|
|
typedef for memory identification numbers. Guaranteed to be some variety of integer.
Definition at line 51 of file psMemory.h. |
|
|
typedef for a memory block's reference count. Guaranteed to be some variety of integer.
Definition at line 54 of file psMemory.h. |
|
|
Get the memory's persistent flag. Checks if a memory block has been marked as persistent by p_psMemSetPresistent. Memory marked as persistent is excluded from memory leak checks.
|
|
||||||||||||
|
Set the memory as persistent so that it is ignored when detecting memory leaks. Used to mark a memory block as persistent data within the library, i.e., non user-level data used to hold psLib's state or cache data. Such examples of this class of memory is psTrace's trace-levels and dynamic error codes. Memory marked as persistent is excluded from memory leak checks.
|
|
|
Memory allocation. This operates much like malloc(), but is guaranteed to return a non-NULL value.
|
|
|
Free memory. This operates much like free().
|
|
|
Get the deallocator routine. This function returns the deallocator for a memory block. A deallocator routine can optionally be assigned to a memory block to ensure that associated memory blocks also get freed, e.g., memory buffers referenced within a struct.
|
|
||||||||||||
|
Set the deallocator routine. A deallocator routine can optionally be assigned to a memory block to ensure that associated memory blocks also get freed, e.g., memory buffers referenced within a struct.
|
|
||||||||||||
|
Memory re-allocation. This operates much like realloc(), but is guaranteed to return a non-NULL value.
|
1.4.1