summaryrefslogtreecommitdiffstats
path: root/src/AllocationPool.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/AllocationPool.h')
-rw-r--r--src/AllocationPool.h28
1 files changed, 15 insertions, 13 deletions
diff --git a/src/AllocationPool.h b/src/AllocationPool.h
index b3818e8b1..643b44a6d 100644
--- a/src/AllocationPool.h
+++ b/src/AllocationPool.h
@@ -34,22 +34,20 @@ class cAllocationPool {
{
if (m_FreeList.size() <= BufferSize)
{
- try
+ void * space = malloc(sizeof(T));
+ if (space != NULL)
{
- return new(malloc(sizeof(T))) T;
+ return new(space) T;
}
- catch (std::bad_alloc&)
+ else if (m_FreeList.size() == BufferSize)
{
- if (m_FreeList.size() == BufferSize)
- {
- m_Callbacks->OnStartingUsingBuffer();
- }
- else if (m_FreeList.empty())
- {
- m_Callbacks->OnBufferEmpty();
- // Try again until the memory is avalable
- return Allocate();
- }
+ m_Callbacks->OnStartingUsingBuffer();
+ }
+ else if (m_FreeList.empty())
+ {
+ m_Callbacks->OnBufferEmpty();
+ // Try again until the memory is avalable
+ return Allocate();
}
}
// placement new, used to initalize the object
@@ -59,6 +57,10 @@ class cAllocationPool {
}
void Free(T* ptr)
{
+ if (ptr == NULL)
+ {
+ return;
+ }
// placement destruct.
ptr->~T();
m_FreeList.push_front(ptr);