UCommon
memory.h
Go to the documentation of this file.
1 // Copyright (C) 2006-2014 David Sugar, Tycho Softworks.
2 //
3 // This file is part of GNU uCommon C++.
4 //
5 // GNU uCommon C++ is free software: you can redistribute it and/or modify
6 // it under the terms of the GNU Lesser General Public License as published
7 // by the Free Software Foundation, either version 3 of the License, or
8 // (at your option) any later version.
9 //
10 // GNU uCommon C++ is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 // GNU Lesser General Public License for more details.
14 //
15 // You should have received a copy of the GNU Lesser General Public License
16 // along with GNU uCommon C++. If not, see <http://www.gnu.org/licenses/>.
17 
30 #ifndef _UCOMMON_MEMORY_H_
31 #define _UCOMMON_MEMORY_H_
32 
33 #ifndef _UCOMMON_CONFIG_H_
34 #include <ucommon/platform.h>
35 #endif
36 
37 #ifndef _UCOMMON_PROTOCOLS_H_
38 #include <ucommon/protocols.h>
39 #endif
40 
41 #ifndef _UCOMMON_LINKED_H_
42 #include <ucommon/linked.h>
43 #endif
44 
45 #ifndef _UCOMMON_STRING_H_
46 #include <ucommon/string.h>
47 #endif
48 
49 namespace ucommon {
50 
51 class PagerPool;
52 
60 class __EXPORT memalloc : public MemoryProtocol
61 {
62 private:
63  friend class bufpager;
64 
65  size_t pagesize, align;
66  unsigned count;
67 
68  typedef struct mempage {
69  struct mempage *next;
70  union {
71  void *memalign;
72  unsigned used;
73  };
74  } page_t;
75 
76  page_t *page;
77 
78 protected:
79  unsigned limit;
80 
85  page_t *pager(void);
86 
90  virtual void fault(void) const;
91 
92 public:
97  memalloc(size_t page = 0);
98 
102  virtual ~memalloc();
103 
108  inline unsigned pages(void) const
109  {return count;}
110 
118  inline unsigned max(void) const
119  {return limit;}
120 
125  inline unsigned size(void) const
126  {return pagesize;}
127 
138  unsigned utilization(void) const;
139 
143  void purge(void);
144 
152  virtual void *_alloc(size_t size);
153 };
154 
175 class __EXPORT mempager : public memalloc, public LockingProtocol
176 {
177 private:
178  mutable pthread_mutex_t mutex;
179 
180 protected:
187  virtual void _lock(void);
188 
192  virtual void _unlock(void);
193 
194 public:
199  mempager(size_t page = 0);
200 
204  virtual ~mempager();
205 
216  unsigned utilization(void);
217 
221  void purge(void);
222 
230  virtual void dealloc(void *memory);
231 
240  virtual void *_alloc(size_t size);
241 };
242 
243 class __EXPORT ObjectPager : protected memalloc
244 {
245 public:
246  class __EXPORT member : public LinkedObject
247  {
248  private:
249  void *mem;
250 
251  protected:
252  friend class ObjectPager;
253 
254  inline void set(member *node)
255  {Next = node;}
256 
257  inline void *get(void) const
258  {return mem;}
259 
260  member(LinkedObject **root);
261  member();
262 
263  public:
264  inline void *operator*() const
265  {return mem;}
266  };
267 
268 private:
269  unsigned members;
270  LinkedObject *root;
271  size_t typesize;
272  member *last;
273  void **index;
274 
275 protected:
276  ObjectPager(size_t objsize, size_t pagesize = 256);
277 
284  void *get(unsigned item) const;
285 
290  void *add(void);
291 
292  void *push(void);
293 
298  void *pull(void);
299 
304  void *pop(void);
305 
310  void *invalid(void) const;
311 
312 public:
317  void clear(void);
318 
324  inline ObjectPager::member *begin(void)
325  {return static_cast<ObjectPager::member *>(root);}
326 
327  inline operator bool() const
328  {return members > 0;}
329 
330  inline bool operator!() const
331  {return !members;}
332 
337  inline unsigned count(void) const
338  {return members;}
339 
343  typedef linked_pointer<ObjectPager::member> iterator;
344 
345  inline size_t size(void)
346  {return memalloc::size();}
347 
348  inline unsigned pages(void)
349  {return memalloc::pages();}
350 
351 protected:
356  void **list(void);
357 };
358 
364 class __EXPORT StringPager : protected memalloc
365 {
366 private:
367  unsigned members;
368  LinkedObject *root;
369 
370 protected:
371  virtual const char *invalid(void) const;
372 
373 public:
381  virtual bool filter(char *text, size_t size);
382 
389  class __EXPORT member : public LinkedObject
390  {
391  private:
392  const char *text;
393 
394  protected:
395  friend class StringPager;
396 
397  inline void set(member *node)
398  {Next = node;}
399 
400  member(LinkedObject **root, const char *data);
401  member(const char *data);
402 
403  public:
404  inline const char *operator*() const
405  {return text;}
406 
407  inline const char *get(void) const
408  {return text;}
409  };
410 
415  StringPager(size_t pagesize = 256);
416 
417  StringPager(char **list, size_t pagesize = 256);
418 
423  inline unsigned count(void) const
424  {return members;}
425 
432  const char *get(unsigned item) const;
433 
439  void set(unsigned item, const char *string);
440 
445  void add(const char *text);
446 
451  void push(const char *text);
452 
457  void push(char **text);
458 
463  const char *pull(void);
464 
469  const char *pop(void);
470 
476  void add(char **list);
477 
483  void set(char **list);
484 
489  void clear(void);
490 
497  inline const char *operator[](unsigned item) const
498  {return get(item);}
499 
500  inline const char *at(unsigned item) const
501  {return get(item);}
502 
508  inline StringPager::member *begin(void) const
509  {return static_cast<StringPager::member *>(root);}
510 
515  inline void operator+=(const char *text)
516  {add(text);}
517 
522  inline StringPager& operator<<(const char *text)
523  {add(text); return *this;}
524 
525  inline StringPager& operator>>(const char *text)
526  {push(text); return *this;}
527 
531  void sort(void);
532 
537  char **list(void);
538 
547  unsigned token(const char *text, const char *list, const char *quote = NULL, const char *end = NULL);
548 
549  unsigned split(const char *text, const char *string, unsigned flags = 0);
550 
551  unsigned split(stringex_t& expr, const char *string, unsigned flags = 0);
552 
553  String join(const char *prefix = NULL, const char *middle = NULL, const char *suffix = NULL);
554 
555  inline operator bool()
556  {return members > 0;}
557 
558  inline bool operator!()
559  {return !members;}
560 
561  inline StringPager& operator=(char **list)
562  {set(list); return *this;}
563 
564  inline const char *operator*()
565  {return pull();}
566 
567  inline operator char **()
568  {return list();}
569 
574 
575  inline size_t size(void) const
576  {return memalloc::size();}
577 
578  inline unsigned pages(void) const
579  {return memalloc::pages();}
580 
581 private:
582  member *last;
583  char **index;
584 };
585 
593 class __EXPORT DirPager : protected StringPager
594 {
595 protected:
596  const char *dir;
597 
605  virtual bool filter(char *filename, size_t size);
606 
612  bool load(const char *path);
613 
614 public:
615  DirPager();
616 
617  DirPager(const char *path);
618 
619  void operator=(const char *path);
620 
621  inline const char *operator*() const
622  {return dir;}
623 
624  inline operator bool() const
625  {return dir != NULL;}
626 
627  inline bool operator!() const
628  {return dir == NULL;}
629 
630  inline unsigned count(void) const
631  {return StringPager::count();}
632 
639  inline const char *operator[](unsigned item) const
640  {return StringPager::get(item);}
641 
642  inline const char *get(unsigned item) const
643  {return StringPager::get(item);}
644 
645  inline const char *at(unsigned item) const
646  {return StringPager::get(item);}
647 
648  inline size_t size(void) const
649  {return memalloc::size();}
650 
651  inline unsigned pages(void) const
652  {return memalloc::pages();}
653 };
654 
659 class __EXPORT bufpager : public memalloc, public CharacterProtocol
660 {
661 private:
662  typedef struct cpage {
663  struct cpage *next;
664  char *text;
665  unsigned size, used;
666  } cpage_t;
667 
668  cpage_t *first, *last, *current, *freelist;
669  unsigned cpos;
670  unsigned long ccount;
671  bool eom; /* null written or out of memory */
672 
673  virtual int _getch(void);
674  virtual int _putch(int code);
675 
676 protected:
677  virtual void *_alloc(size_t size);
678 
679 public:
683  void reset(void);
684 
688  void rewind(void);
689 
694  char *dup(void);
695 
700  void set(const char *text);
701 
706  void add(const char *text);
707 
714  size_t get(char *text, size_t size);
715 
721  void put(const char *text, size_t size);
722 
727  inline unsigned long used(void) const
728  {return ccount;}
729 
734  inline char *operator *()
735  {return dup();}
736 
741  inline bufpager& operator<<(const char *text)
742  {add(text); return *this;}
743 
744  bufpager(size_t page = 0);
745 
751  char *request(size_t *iosize);
752 
759  char *copy(size_t *iosize);
760 
765  void update(size_t size);
766 
771  inline bool operator!() const
772  {return eom;}
773 
778  inline operator bool() const
779  {return !eom;}
780 };
781 
789 class __EXPORT autorelease
790 {
791 private:
792  LinkedObject *pool;
793 
794 public:
798  autorelease();
799 
803  ~autorelease();
804 
810  void release(void);
811 
816  void operator+=(LinkedObject *object);
817 };
818 
829 class __EXPORT PagerObject : public LinkedObject, public CountedObject
830 {
831 protected:
832  friend class PagerPool;
833 
834  PagerPool *pager;
835 
839  PagerObject();
840 
844  void reset(void);
845 
849  void release(void);
850 
854  void dealloc(void);
855 };
856 
865 class __EXPORT PagerPool : public MemoryProtocol
866 {
867 private:
868  LinkedObject *freelist;
869  mutable pthread_mutex_t mutex;
870 
871 protected:
872  PagerPool();
873  virtual ~PagerPool();
874 
875  PagerObject *get(size_t size);
876 
877 public:
882  void put(PagerObject *object);
883 };
884 
885 class __EXPORT charmem : public CharacterProtocol
886 {
887 protected:
888  char *buffer;
889  size_t inp, out, size;
890  bool dynamic;
891 
892  int _getch(void);
893  int _putch(int code);
894 
895 public:
896  charmem(char *mem, size_t size);
897  charmem(size_t size);
898  charmem();
899  virtual ~charmem();
900 
901  void release(void);
902 
903  void set(char *mem, size_t size);
904 
905  void set(size_t size);
906 
907  inline void reset(void)
908  {inp = out = 0;}
909 
910  inline void rewind(void)
911  {inp = 0;}
912 };
913 
914 class __EXPORT chartext : public CharacterProtocol
915 {
916 private:
917  char *pos;
918  size_t max;
919 
920  int _putch(int code);
921  int _getch(void);
922 
923 public:
924  chartext();
925  chartext(char *buf);
926  chartext(char *buf, size_t size);
927  virtual ~chartext();
928 };
929 
941 class __EXPORT keyassoc : protected mempager
942 {
943 private:
947  class __LOCAL keydata : public NamedObject
948  {
949  public:
950  void *data;
951  char text[8];
952 
953  keydata(keyassoc *assoc, const char *id, unsigned max, unsigned bufsize);
954  };
955 
956  friend class keydata;
957 
958  unsigned keycount;
959  unsigned paths;
960  size_t keysize;
961  NamedObject **root;
962  LinkedObject **list;
963 
964 protected:
971  void *allocate(const char *name, size_t size);
972 
973 public:
980  keyassoc(unsigned indexing = 177, size_t max = 0, size_t page = 0);
981 
985  ~keyassoc();
986 
991  inline unsigned count(void) const
992  {return keycount;}
993 
999  inline void *operator()(const char *name)
1000  {return locate(name);}
1001 
1005  void purge(void);
1006 
1012  void *locate(const char *name);
1013 
1021  bool assign(const char *name, void *pointer);
1022 
1029  bool create(const char *name, void *pointer);
1030 
1037  void *remove(const char *name);
1038 };
1039 
1040 template <class T, size_t P = 0>
1041 class listof : private ObjectPager
1042 {
1043 public:
1044  inline listof() : ObjectPager(sizeof(T), P) {}
1045 
1046  inline T& operator[](unsigned item) const
1047  {return (T&)ObjectPager::get(item);}
1048 
1049  inline T* operator()(unsigned item) const
1050  {return (T*)ObjectPager::get(item);}
1051 
1052  inline const T& at(unsigned item) const
1053  {return (const T&)ObjectPager::get(item);}
1054 
1055  inline T* pull(void)
1056  {return (T*)ObjectPager::pull();}
1057 
1058  inline T* pop(void)
1059  {return (T*)ObjectPager::pop();}
1060 
1061  inline operator T**()
1062  {return (T**)ObjectPager::list();}
1063 
1064  inline T** list(void)
1065  {return (T**)ObjectPager::list();}
1066 
1067  inline T* operator++(void)
1068  {T* tmp = ObjectPager::add(); if(tmp) new((caddr_t)tmp) T; return tmp;}
1069 
1070  inline T* add(const T& object)
1071  {T* tmp = ObjectPager::add(); if(tmp) new((caddr_t)tmp) T(object); return tmp;}
1072 
1073  inline T* push(const T& object)
1074  {T* tmp = ObjectPager::push(); if(tmp) new((caddr_t)tmp) T(object); return tmp;}
1075 
1076  inline listof& operator<<(const T& object)
1077  {T* tmp = ObjectPager::add(); if(tmp) new((caddr_t)tmp) T(object); return *this;}
1078 
1079  inline listof& operator>>(const T& object)
1080  {T* tmp = ObjectPager::push(); if(tmp) new((caddr_t)tmp) T(object); return *this;}
1081 
1082 };
1083 
1084 template <class T, unsigned I = 177, size_t M = 0, size_t P = 0>
1085 class mapof : private keyassoc
1086 {
1087 public:
1091  inline mapof() : keyassoc(I, M, P) {}
1092 
1097  inline unsigned count(void) const
1098  {return keyassoc::count();}
1099 
1103  inline void purge(void)
1104  {keyassoc::purge();}
1105 
1111  inline T *locate(const char *name)
1112  {return static_cast<T*>(keyassoc::locate(name));}
1113 
1114  inline T *operator[](const char *name)
1115  {return static_cast<T*>(keyassoc::locate(name));}
1116 
1122  inline T *operator()(const char *name)
1123  {return locate(name);}
1124 
1129  inline T *map(const char *name)
1130  {T *tmp = keyassoc::allocate(name, sizeof(T)); if(tmp) new((caddr_t)tmp) T;}
1131 
1137  inline void unmap(const char *name)
1138  {keyassoc::remove(name);}
1139 
1145  inline unsigned utilization(void) const
1146  {return mempager::utilization();}
1147 
1154  inline unsigned pages(void) const
1155  {return mempager::pages();}
1156 };
1157 
1165 template <class T, unsigned I = 177, size_t M = 0, size_t P = 0>
1166 class assoc_pointer : private keyassoc
1167 {
1168 public:
1172  inline assoc_pointer() : keyassoc(I, M, P) {}
1173 
1178  inline unsigned count(void) const
1179  {return keyassoc::count();}
1180 
1184  inline void purge(void)
1185  {keyassoc::purge();}
1186 
1192  inline T *locate(const char *name)
1193  {return static_cast<T*>(keyassoc::locate(name));}
1194 
1195  inline T *operator[](const char *name)
1196  {return static_cast<T*>(keyassoc::locate(name));}
1197 
1198 
1204  inline T *operator()(const char *name)
1205  {return locate(name);}
1206 
1214  inline bool assign(char *name, T *pointer)
1215  {return keyassoc::assign(name, pointer);}
1216 
1223  inline bool create(char *name, T *pointer)
1224  {return keyassoc::create(name, pointer);}
1225 
1231  inline void remove(char *name)
1232  {keyassoc::remove(name);}
1233 
1239  inline unsigned utilization(void) const
1240  {return mempager::utilization();}
1241 
1248  inline unsigned pages(void) const
1249  {return mempager::pages();}
1250 };
1251 
1258 template <typename T>
1259 class pager : private MemoryRedirect, private PagerPool
1260 {
1261 public:
1266  inline pager(mempager *heap = NULL) : MemoryRedirect(heap), PagerPool() {}
1267 
1272  inline T *operator()(void)
1273  {return new(get(sizeof(T))) T;}
1274 
1279  inline T *operator*()
1280  {return new(get(sizeof(T))) T;}
1281 };
1282 
1288 template <class T, unsigned M = 177>
1289 class keypager : public mempager
1290 {
1291 private:
1292  NamedObject *idx[M];
1293 
1294 public:
1299  inline keypager(size_t size) : mempager(size) {}
1300 
1304  inline ~keypager()
1305  {NamedObject::purge(idx, M); mempager::purge();}
1306 
1313  inline T *get(const char *name) const {
1314  T *node = (static_cast<T*>(NamedObject::map(idx, name, M)));
1315  if(!node) {
1316  node = init<T>(static_cast<T*>(mempager::_alloc(sizeof(T))));
1317  node->NamedObject::add(idx, name, M);
1318  }
1319  return node;
1320  }
1321 
1327  bool test(const char *name) const
1328  {return NamedObject::map(idx, name, M) != NULL;}
1329 
1336  inline T *operator[](const char *name) const
1337  {return get(name);}
1338 
1343  inline T *begin(void) const
1344  {return static_cast<T*>(NamedObject::skip(idx, NULL, M));}
1345 
1351  inline T *next(T *current) const
1352  {return static_cast<T*>(NamedObject::skip(idx, current, M));}
1353 
1358  inline unsigned count(void) const
1359  {return NamedObject::count(idx, M);}
1360 
1367  inline T **index(void) const
1368  {return NamedObject::index(idx, M);}
1369 
1376  inline T **sort(void) const
1377  {return NamedObject::sort(NamedObject::index(idx, M));}
1378 
1383 };
1384 
1389 
1394 
1399 
1400 inline const char *shift(stringlist_t& list)
1401  {return list.pull();}
1402 
1403 inline void unshift(stringlist_t& list, const char *text)
1404  {list.push(text);}
1405 
1406 
1407 inline String str(StringPager& list, const char *prefix = NULL, const char *middle = NULL, const char *suffix = NULL)
1408  {return list.join(prefix, middle, suffix);}
1409 
1410 } // namespace ucommon
1411 
1412 #endif
T * operator()(void)
Create a managed object by casting reference.
Definition: memory.h:1272
This is a base class for objects that may be created in pager pools.
Definition: memory.h:829
static NamedObject ** sort(NamedObject **list, size_t count=0)
Sort an array of named objects in alphabetical order.
void purge(void)
Purge all allocated memory and heap pages immediately.
Abstract interfaces and support.
Common locking protocol.
Definition: protocols.h:121
A linked object base class with members found by name.
Definition: linked.h:400
T * operator()(const char *name)
Reference a typed object directly by name.
Definition: memory.h:1204
T ** sort(void) const
Convert our hash map into an alphabetically sorted linear object pointer array.
Definition: memory.h:1376
unsigned count(void) const
Count the number of typed objects in our hash map.
Definition: memory.h:1358
keypager(size_t size)
Create the object cache.
Definition: memory.h:1299
unsigned pages(void) const
Get the number of pages that have been allocated from the real heap.
Definition: memory.h:108
linked_pointer< T > iterator
Convenience typedef for iterative pointer.
Definition: memory.h:1382
~keypager()
Destroy the hash pager by purging the index chains and memory pools.
Definition: memory.h:1304
static NamedObject * skip(NamedObject **hash, NamedObject *current, unsigned size)
Iterate through a hash map table.
T * dup(const T &object)
Convenience function to duplicate object pointer to heap.
Definition: generics.h:478
Buffered pager for storing paged strings for character protocol.
Definition: memory.h:659
unsigned count(void) const
Get the number of associations we have in our object.
Definition: memory.h:991
Linked objects, lists, templates, and containers.
bool create(const char *name, void *pointer)
Create a new name in the association table and assign it's value.
A typed template for using a key association with typed objects.
Definition: memory.h:1166
bool test(const char *name) const
Test if a name exists in the pool.
Definition: memory.h:1327
Generic smart pointer class.
Definition: generics.h:56
A managed private heap for small allocations.
Definition: memory.h:175
T * operator*()
Create a managed object by pointer reference.
Definition: memory.h:1279
Convenience class for directories.
Definition: fsys.h:716
bufpager & operator<<(const char *text)
Convenience operator to add to pager.
Definition: memory.h:741
T &() limit(T &value, T &low, T &high)
Convenience macro to range restrict values.
Definition: generics.h:568
virtual void * _alloc(size_t size)
Allocate memory from the pager heap.
Member of string list.
Definition: memory.h:389
Common namespace for all ucommon objects.
Mempager managed type factory for pager pool objects.
Definition: memory.h:1259
T * locate(const char *name)
Lookup a typed object by name.
Definition: memory.h:1192
pager(mempager *heap=((void *) 0))
Construct a pager and optionally assign a private pager heap.
Definition: memory.h:1266
bool create(char *name, T *pointer)
Create a new name in the association table and assign typed object.
Definition: memory.h:1223
bool operator!() const
Check if can still save into buffer.
Definition: memory.h:771
const char * pull(void)
Remove element from front of list.
A smart pointer template for iterating linked lists.
Definition: linked.h:1292
Common character processing protocol.
Definition: protocols.h:174
static NamedObject * map(NamedObject **hash, const char *name, unsigned size)
Find a named object through a hash map table.
A memory protocol pager for private heap manager.
Definition: memory.h:60
linked_pointer< StringPager::member > iterator
Convenience typedef for iterative pointer.
Definition: memory.h:573
void * operator()(const char *name)
Lookup the data pointer of a string by direct operation.
Definition: memory.h:999
Common base class for all objects that can be formed into a linked list.
Definition: linked.h:58
void release(SharedAccess &object)
Convenience function to unlock shared object through it's protocol.
Definition: access.h:260
static void purge(NamedObject **hash, unsigned size)
Purge a hash indexed table of named objects.
void purge(void)
Purge the hash map of typed objects.
Definition: memory.h:1184
keyassoc(unsigned indexing=177, size_t max=0, size_t page=0)
Create a key associated memory pointer table.
const char * operator[](unsigned item) const
Return specified member from pager list.
Definition: memory.h:497
DirPager dirlist_t
A convenience type for using DirPager directly.
Definition: memory.h:1398
Various miscellaneous platform specific headers and defines.
unsigned pages(void) const
Access to number of pages allocated from heap for our associated index pointer.
Definition: memory.h:1248
String pager for storing lists of NULL terminated strings.
Definition: memory.h:364
T * operator[](const char *name) const
Find a typed object derived from NamedObject in the hash map by name.
Definition: memory.h:1336
A redirection base class for the memory protocol.
Definition: protocols.h:103
unsigned count(void) const
Get the number of items in the pager string list.
Definition: memory.h:423
bool assign(char *name, T *pointer)
Assign a name for a pointer to a typed object.
Definition: memory.h:1214
const char * operator[](unsigned item) const
Return specified filename from directory list.
Definition: memory.h:639
unsigned size(void) const
Get the size of a memory page.
Definition: memory.h:125
StringPager::member * begin(void) const
Get root of pager list.
Definition: memory.h:508
unsigned utilization(void)
Determine fragmentation level of acquired heap pages.
bool assign(const char *name, void *pointer)
Assign a name to a data pointer.
void operator+=(const char *text)
Convenience operator to add to pager and auto-sort.
Definition: memory.h:515
Pager pool base class for managed memory pools.
Definition: memory.h:865
static unsigned count(NamedObject **hash, unsigned size)
Count the total named objects in a hash table.
const char * get(unsigned item) const
Get string item from list.
T ** index(void) const
Convert our hash map into a linear object pointer array.
Definition: memory.h:1367
unsigned count(void) const
Get the count of typed objects stored in our hash map.
Definition: memory.h:1178
void * allocate(const char *name, size_t size)
Allocate object stored in pager also.
assoc_pointer()
Construct an associated pointer hash map based on the class template.
Definition: memory.h:1172
T &() max(T &o1, T &o2)
Convenience function to return max of two objects.
Definition: generics.h:543
Directory pager is a paged string list for directory file names.
Definition: memory.h:593
void * locate(const char *name)
Lookup the data pointer by the string name given.
static NamedObject ** index(NamedObject **hash, unsigned size)
Convert a hash index into a linear object pointer array.
A template class for a hash pager.
Definition: memory.h:1289
StringPager & operator<<(const char *text)
Convenience operator to add to pager.
Definition: memory.h:522
T * next(T *current) const
Find next typed object in hash map for iteration.
Definition: memory.h:1351
A base class for reference counted objects.
Definition: object.h:55
A common string class and character string support functions.
unsigned utilization(void) const
Access to pager utilization stats.
Definition: memory.h:1239
StringPager::member stringlistitem_t
A convenience type for paged string list items.
Definition: memory.h:1393
ObjectProtocol * copy(ObjectProtocol *object)
Convenience function to access object copy.
Definition: object.h:479
T * begin(void) const
Find first typed object in hash map to iterate.
Definition: memory.h:1343
void * remove(const char *name)
Remove a name and pointer association.
unsigned max(void) const
Get the maximum number of pages that are permitted.
Definition: memory.h:118
StringPager stringlist_t
A convenience type for paged string lists.
Definition: memory.h:1388
A class to hold memory pointers referenced by string names.
Definition: memory.h:941
void purge(void)
Purge all associations and return allocated pages to heap.
Create a linked list of auto-releasable objects.
Definition: memory.h:789
unsigned long used(void) const
Get total size.
Definition: memory.h:727