IsoSpec  1.95
allocator.cpp
1 /*
2  * Copyright (C) 2015-2018 Mateusz Łącki and Michał Startek.
3  *
4  * This file is part of IsoSpec.
5  *
6  * IsoSpec is free software: you can redistribute it and/or modify
7  * it under the terms of the Simplified ("2-clause") BSD licence.
8  *
9  * IsoSpec is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
12  *
13  * You should have received a copy of the Simplified BSD Licence
14  * along with IsoSpec. If not, see <https://opensource.org/licenses/BSD-2-Clause>.
15  */
16 
17 
18 #include <iostream>
19 #include "allocator.h"
20 
21 namespace IsoSpec
22 {
23 
24 template <typename T>
25 Allocator<T>::Allocator(const int dim, const int tabSize): currentId(-1), dim(dim), tabSize(tabSize)
26 {
27  currentTab = new T[dim * tabSize];
28 }
29 
30 template <typename T>
32 {
33  for(unsigned int i = 0; i < prevTabs.size(); ++i)
34  {
35  delete [] prevTabs[i];
36  }
37 
38  delete [] currentTab;
39 }
40 
41 template <typename T>
43 {
44  prevTabs.push_back(currentTab);
45  currentTab = new T[dim * tabSize];
46  currentId = 0;
47 }
48 
49 template class Allocator<int>;
50 
51 }
IsoSpec::Allocator
Definition: allocator.h:34
IsoSpec
Definition: allocator.cpp:21