54 class ValueObj { 55 public: 56 void* operator new(size_t size) throw(); 57 void operator delete(void* p); 58 }; 59 60 // Base class for classes that constitute name spaces. 61 62 class AllStatic { 63 public: 64 void* operator new(size_t size) throw(); 65 void operator delete(void* p); 66 }; 67 68 69 //------------------------------Chunk------------------------------------------ 70 // Linked list of raw memory chunks 71 class Chunk: public CHeapObj { 72 public: 73 void* operator new(size_t size, size_t length) throw(); 74 void operator delete(void* p, size_t length); 75 Chunk(size_t length); 76 77 enum { 78 init_size = 1*1024, // Size of first chunk 79 size = 32*1024 // Default size of an Arena chunk (following the first) 80 }; 81 Chunk* _next; // Next Chunk in list 82 size_t _len; // Size of this Chunk 83 84 void chop(); // Chop this chunk 85 void next_chop(); // Chop next chunk 86 87 // Boundaries of data area (possibly unused) 88 char* bottom() const { return ((char*) this) + sizeof(Chunk); } 89 char* top() const { return bottom() + _len; } 90 }; 91 92 93 //------------------------------Arena------------------------------------------ | 54 class ValueObj { 55 public: 56 void* operator new(size_t size) throw(); 57 void operator delete(void* p); 58 }; 59 60 // Base class for classes that constitute name spaces. 61 62 class AllStatic { 63 public: 64 void* operator new(size_t size) throw(); 65 void operator delete(void* p); 66 }; 67 68 69 //------------------------------Chunk------------------------------------------ 70 // Linked list of raw memory chunks 71 class Chunk: public CHeapObj { 72 public: 73 void* operator new(size_t size, size_t length) throw(); 74 // Usual (non-placement) deallocation function to allow placement delete use size_t 75 // See 3.7.4.2 [basic.stc.dynamic.deallocation] paragraph 2. 76 void operator delete(void* p); 77 void operator delete(void* p, size_t length); 78 Chunk(size_t length); 79 80 enum { 81 init_size = 1*1024, // Size of first chunk 82 size = 32*1024 // Default size of an Arena chunk (following the first) 83 }; 84 Chunk* _next; // Next Chunk in list 85 size_t _len; // Size of this Chunk 86 87 void chop(); // Chop this chunk 88 void next_chop(); // Chop next chunk 89 90 // Boundaries of data area (possibly unused) 91 char* bottom() const { return ((char*) this) + sizeof(Chunk); } 92 char* top() const { return bottom() + _len; } 93 }; 94 95 96 //------------------------------Arena------------------------------------------ |