A class to hold memory pointers referenced by string names.
More...
#include <memory.h>
|
bool | assign (const char *name, void *pointer) |
| Assign a name to a data pointer. More...
|
|
unsigned | count (void) const |
| Get the number of associations we have in our object. More...
|
|
bool | create (const char *name, void *pointer) |
| Create a new name in the association table and assign it's value. More...
|
|
| keyassoc (unsigned indexing=177, size_t max=0, size_t page=0) |
| Create a key associated memory pointer table. More...
|
|
void * | locate (const char *name) |
| Lookup the data pointer by the string name given. More...
|
|
void * | operator() (const char *name) |
| Lookup the data pointer of a string by direct operation. More...
|
|
void | purge (void) |
| Purge all associations and return allocated pages to heap.
|
|
void * | remove (const char *name) |
| Remove a name and pointer association. More...
|
|
| ~keyassoc () |
| Destroy association object. More...
|
|
|
void * | allocate (const char *name, size_t size) |
| Allocate object stored in pager also. More...
|
|
virtual void * | _alloc (size_t size) |
| Allocate memory from the pager heap. More...
|
|
virtual void | _lock (void) |
| Lock the memory pager mutex. More...
|
|
virtual void | _unlock (void) |
| Unlock the memory pager mutex.
|
|
void | assign (mempager &source) |
| Assign foreign pager to us. More...
|
|
virtual void | dealloc (void *memory) |
| Return memory back to pager heap. More...
|
|
| mempager (size_t page=0) |
| Construct a memory pager. More...
|
|
mempager & | operator= (mempager &source) |
|
void | purge (void) |
| Purge all allocated memory and heap pages immediately.
|
|
unsigned | utilization (void) |
| Determine fragmentation level of acquired heap pages. More...
|
|
virtual | ~mempager () |
| Destroy a memory pager. More...
|
|
virtual void | fault (void) const |
| Report runtime memory exhaustion.
|
|
page_t * | pager (void) |
| Acquire a new page from the heap. More...
|
|
void | assign (memalloc &source) |
| Assign foreign pager to us. More...
|
|
unsigned | max (void) const |
| Get the maximum number of pages that are permitted. More...
|
|
| memalloc (size_t page=0) |
| Construct a memory pager. More...
|
|
memalloc & | operator= (memalloc &source) |
|
unsigned | pages (void) const |
| Get the number of pages that have been allocated from the real heap. More...
|
|
void | purge (void) |
| Purge all allocated memory and heap pages immediately.
|
|
unsigned | size (void) const |
| Get the size of a memory page. More...
|
|
unsigned | utilization (void) const |
| Determine fragmentation level of acquired heap pages. More...
|
|
virtual | ~memalloc () |
| Destroy a memory pager. More...
|
|
A class to hold memory pointers referenced by string names.
This is used to form a typeless data pointer that can be associated and referenced by string/logical name. The memory used for forming the string names can itself be managed in reusable memory pools and the entire structure uses it's own private pager heap. This allows new string named pointers to be added and deleted at runtime in a thread- safe manner. This might typically be used as a session id manager or for symbol tables.
- Author
- David Sugar dyfet.nosp@m.@gnu.nosp@m.telep.nosp@m.hony.nosp@m..org
Definition at line 1027 of file memory.h.
ucommon::keyassoc::keyassoc |
( |
unsigned |
indexing = 177 , |
|
|
size_t |
max = 0 , |
|
|
size_t |
page = 0 |
|
) |
| |
Create a key associated memory pointer table.
- Parameters
-
indexing | size for hash map. |
max | size of a string name if names are in reusable managed memory. |
page | size of memory pager. |
ucommon::keyassoc::~keyassoc |
( |
| ) |
|
Destroy association object.
Release all pages back to the heap.
void* ucommon::keyassoc::allocate |
( |
const char * |
name, |
|
|
size_t |
size |
|
) |
| |
|
protected |
Allocate object stored in pager also.
- Parameters
-
name | of object entry. |
size | of object to allocate. |
- Returns
- pointer to allocated object or NULL on failure.
bool ucommon::keyassoc::assign |
( |
const char * |
name, |
|
|
void * |
pointer |
|
) |
| |
Assign a name to a data pointer.
If the name exists, it is re-assigned with the new pointer value, otherwise it is created.
- Parameters
-
name | to assign. |
pointer | value to assign with name. |
- Returns
- false if failed because name is too long for managed table.
unsigned ucommon::keyassoc::count |
( |
void |
| ) |
const |
|
inline |
Get the number of associations we have in our object.
- Returns
- number of associations stored.
Definition at line 1077 of file memory.h.
bool ucommon::keyassoc::create |
( |
const char * |
name, |
|
|
void * |
pointer |
|
) |
| |
Create a new name in the association table and assign it's value.
- Parameters
-
name | to create. |
pointer | value to assign with name. |
- Returns
- false if already exists or name is too long for managed table.
void* ucommon::keyassoc::locate |
( |
const char * |
name | ) |
|
Lookup the data pointer by the string name given.
- Parameters
-
- Returns
- pointer to data or NULL if not found.
void* ucommon::keyassoc::operator() |
( |
const char * |
name | ) |
|
|
inline |
Lookup the data pointer of a string by direct operation.
- Parameters
-
- Returns
- pointer to data or NULL if not found.
Definition at line 1085 of file memory.h.
void* ucommon::keyassoc::remove |
( |
const char * |
name | ) |
|
Remove a name and pointer association.
If managed key names are used then the memory allocated for the name will be re-used.
- Parameters
-
- Returns
- pointer value of the name or NULL if not found.
The documentation for this class was generated from the following file: