summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTycho <work.tycho+git@gmail.com>2014-05-23 16:48:09 +0200
committerTycho <work.tycho+git@gmail.com>2014-05-23 16:48:09 +0200
commit6991c2dd84060f8e7375966d4e488a359b42d43a (patch)
tree2282f2b2570f0fb064f2bf92b686666667e2cf29
parentMerge branch 'chunksparsing/structs' into AllocationPool (diff)
downloadcuberite-6991c2dd84060f8e7375966d4e488a359b42d43a.tar
cuberite-6991c2dd84060f8e7375966d4e488a359b42d43a.tar.gz
cuberite-6991c2dd84060f8e7375966d4e488a359b42d43a.tar.bz2
cuberite-6991c2dd84060f8e7375966d4e488a359b42d43a.tar.lz
cuberite-6991c2dd84060f8e7375966d4e488a359b42d43a.tar.xz
cuberite-6991c2dd84060f8e7375966d4e488a359b42d43a.tar.zst
cuberite-6991c2dd84060f8e7375966d4e488a359b42d43a.zip
-rw-r--r--src/AllocationPool.h7
1 files changed, 5 insertions, 2 deletions
diff --git a/src/AllocationPool.h b/src/AllocationPool.h
index f1e324953..d14d56f7a 100644
--- a/src/AllocationPool.h
+++ b/src/AllocationPool.h
@@ -36,12 +36,15 @@ class AllocationPool {
}
}
}
- T* ret = m_FreeList.front();
+ // placement new, used to initalize the object
+ T* ret = new (m_FreeList.front()) T;
m_FreeList.pop_front();
return ret;
}
void Free(T* ptr)
{
+ // placement destruct.
+ ptr->~T();
m_FreeList.push_front(ptr);
if (m_FreeList.size() == BufferSize)
{
@@ -50,5 +53,5 @@ class AllocationPool {
}
private:
- std::list<T*> m_FreeList;
+ std::list<void *> m_FreeList;
}