77 CellHeap(
size_t dbls_per_cell,
size_t cells_per_superblock)
78 : m_cellsize(dbls_per_cell*sizeof(double)),
79 m_cells_per_superblock(cells_per_superblock),
80 m_superblocksize(m_cellsize*cells_per_superblock),
84 #if VALGRIND_LEVEL >= 2
85 VALGRIND_CREATE_MEMPOOL(
this, 0, 0);
108 if (!m_free_cells) seekMemory();
110 Cell* c = m_free_cells;
111 m_free_cells = meld(c->m_l, c->m_r);
113 #if VALGRIND_LEVEL >= 2
114 VALGRIND_MEMPOOL_ALLOC(
this, c,
cellSize());
178 if (!m_free_cells)
return 0;
180 Cell* c = m_free_cells;
181 m_free_cells = meld(c->m_l, c->m_r);
183 #if VALGRIND_LEVEL >= 2
184 VALGRIND_MEMPOOL_ALLOC(
this, c,
cellSize());
200 Cell(Cell* next = 0) : m_l(next), m_r(0) {}
203 const size_t m_cellsize;
204 const size_t m_cells_per_superblock;
205 const size_t m_superblocksize;
206 std::vector<void*> m_superblocks;
208 unsigned int m_cells_allocated;
212 void checkCell(
const void* p)
const;
216 void checkAllocatedCell(
const void* p)
const;
221 static unsigned int countFreeCells(
const Cell* root);
224 static bool isFreeCell(
const Cell* root,
const Cell* c);
229 static Cell* meld(Cell* a, Cell* b)
232 if (a > b) std::swap(a, b);
240 static void meld_aux(Cell* host, Cell* guest);
242 void seekMemory() throw (std::bad_alloc);