12 #ifndef MFEM_MEM_ALLOC
13 #define MFEM_MEM_ALLOC
15 #include "../config/config.hpp"
21 template <
class Elem,
int Num>
29 template <
class Elem,
int Num>
36 Stack() { TopPart = TopFreePart = NULL; UsedInTop = Num; SSize = 0; }
37 int Size()
const {
return SSize; }
45 template <
class Elem,
int Num>
51 if (TopFreePart == NULL)
57 TopFreePart = (aux = TopFreePart)->Prev;
67 template <
class Elem,
int Num>
73 TopPart = (aux = TopPart)->Prev;
74 aux->
Prev = TopFreePart;
79 return TopPart->
Elements[--UsedInTop];
82 template <
class Elem,
int Num>
86 while (TopPart != NULL)
88 TopPart = (aux = TopPart)->Prev;
91 while (TopFreePart != NULL)
93 TopFreePart = (aux = TopFreePart)->Prev;
100 template <
class Elem,
int Num>
121 template <
class Elem,
int Num>
129 template <
class Elem,
int Num>
145 template <
class Elem,
int Num>
149 if (UsedMem.Size() > 0)
151 return UsedMem.Pop();
153 if (AllocatedInLast == Num)
160 return &(Last->Elements[AllocatedInLast++]);
163 template <
class Elem,
int Num>
169 template <
class Elem,
int Num>
179 AllocatedInLast = Num;
183 template <
class Elem,
int Num>
size_t MemoryUsage() const
size_t MemoryUsage() const
StackPart< Elem, Num > * Prev
MemAllocNode< Elem, Num > * Prev