Fixed memory pool code

This commit is contained in:
Guilhem Lavaux 2012-05-21 14:19:36 -04:00
parent 80951b4b52
commit 604b19ce74

View File

@ -15,11 +15,13 @@ namespace CosmoTool
PoolNode<T> *next; PoolNode<T> *next;
}; };
template<typename T> class MemoryPool;
template<typename T> template<typename T>
class MemoryIterator class MemoryIterator
{ {
private: private:
friend class MemoryPool<T>; friend class MemoryPool<T>;
PoolNode<T> *cur, *previous; PoolNode<T> *cur, *previous;
uint32_t in_node; uint32_t in_node;
@ -41,7 +43,7 @@ namespace CosmoTool
in_node = i.in_node; in_node = i.in_node;
} }
bool MemoryIterator::operator==(const MemoryIterator& i) const bool operator==(const MemoryIterator& i) const
{ {
return (cur == i.cur) && (in_node == i.in_node); return (cur == i.cur) && (in_node == i.in_node);
} }
@ -82,7 +84,7 @@ namespace CosmoTool
private: private:
uint32_t m_allocSize; uint32_t m_allocSize;
PoolNode<T> *head, *current; PoolNode<T> *head, *current;
typedef typename MemoryIterator<T> iterator; typedef MemoryIterator<T> iterator;
public: public:
MemoryPool(uint32_t allocSize) MemoryPool(uint32_t allocSize)
: m_allocSize(allocSize), head(0), current(0) {} : m_allocSize(allocSize), head(0), current(0) {}