20 #include "dirtyAllocator.h"
25 DirtyAllocator::DirtyAllocator(
26 const int dim,
const int tabSize
29 cellSize =
sizeof(double) +
sizeof(
int) * dim;
31 if(cellSize %
sizeof(
double) != 0)
32 cellSize +=
sizeof(
double) - cellSize %
sizeof(double);
33 currentTab = malloc( cellSize * tabSize );
34 currentConf = currentTab;
35 endOfTablePtr =
reinterpret_cast<char*
>(currentTab) + cellSize*tabSize;
39 DirtyAllocator::~DirtyAllocator()
41 for(
unsigned int i = 0; i < prevTabs.size(); ++i) free(prevTabs[i]);
45 void DirtyAllocator::shiftTables()
47 prevTabs.push_back(currentTab);
49 currentTab = malloc( cellSize * tabSize );
50 currentConf = currentTab;
51 endOfTablePtr =
reinterpret_cast<char*
>(currentTab) + cellSize*tabSize;