43 #ifndef COMMONCPP_MISC_H_
44 #define COMMONCPP_MISC_H_
46 #ifndef COMMONCPP_CONFIG_H_
47 #include <commoncpp/config.h>
50 #define KEYDATA_INDEX_SIZE 97
51 #define KEYDATA_PAGER_SIZE 512
54 #define KEYDATA_PATH_SIZE 512
56 #define KEYDATA_PATH_SIZE PATH_MAX
59 #define KEYDATA_PATH_SIZE 256
67 inline MemPager(
size_t pagesize = 4096) :
ucommon::memalloc(pagesize) {};
69 inline void *alloc(
size_t size)
72 char *alloc(
const char *str);
74 inline char *first(
const char *str)
77 inline void *first(
size_t size)
80 inline int getPages(
void)
83 inline void purge(
void)
116 void* alloc(
size_t size);
118 inline void *first(
size_t size)
119 {
return alloc(size);}
140 entry *entries[KEYDATA_INDEX_SIZE];
148 virtual void *getMemory(
size_t size) = 0;
151 void *getPointer(
const char *
id)
const;
152 void setPointer(
const char *
id,
void *data);
Common namespace for all ucommon objects.
This class is used to associate (object) pointers with named strings.
unsigned pages(void) const
Get the number of pages that have been allocated from the real heap.
void purge(void)
Purge all allocated memory and heap pages immediately.
virtual void * _alloc(size_t size)
Allocate memory from the pager heap.
A memory protocol pager for private heap manager.
The shared mempager uses a mutex to protect key access methods.