19 #include "dirtyAllocator.h"
24 DirtyAllocator::DirtyAllocator(
25 const int dim,
const int tabSize_
28 cellSize =
sizeof(double) +
sizeof(
int) * dim;
30 if(cellSize %
sizeof(
double) != 0)
31 cellSize +=
sizeof(
double) - cellSize %
sizeof(double);
32 currentTab = malloc( cellSize * tabSize );
33 if(currentTab == NULL)
34 throw std::bad_alloc();
35 currentConf = currentTab;
36 endOfTablePtr =
reinterpret_cast<char*
>(currentTab) + cellSize*tabSize;
40 DirtyAllocator::~DirtyAllocator()
42 for(
unsigned int i = 0; i < prevTabs.size(); ++i) free(prevTabs[i]);
46 void DirtyAllocator::shiftTables()
48 prevTabs.push_back(currentTab);
50 currentTab = malloc( cellSize * tabSize );
51 currentConf = currentTab;
52 if(currentTab == NULL)
53 throw std::bad_alloc();
54 endOfTablePtr =
reinterpret_cast<char*
>(currentTab) + cellSize*tabSize;