Kaynağa Gözat

Mimic free()/delete behavior

Daniele Bartolini 11 yıl önce
ebeveyn
işleme
4fa9c557f4

+ 2 - 1
engine/core/mem/Memory.cpp

@@ -103,7 +103,8 @@ public:
 	{
 		ScopedMutex sm(m_mutex);
 
-		if (!data) return;
+		if (!data)
+			return;
 
 		Header* h = header(data);
 

+ 3 - 0
engine/core/mem/PoolAllocator.cpp

@@ -91,6 +91,9 @@ void* PoolAllocator::allocate(size_t size, size_t align)
 //-----------------------------------------------------------------------------
 void PoolAllocator::deallocate(void* data)
 {
+	if (!data)
+		return;
+
 	CE_ASSERT(m_num_allocations > 0, "Did not allocate");
 
 	uintptr_t* next = (uintptr_t*) data;

+ 3 - 0
engine/core/mem/StackAllocator.cpp

@@ -78,6 +78,9 @@ void* StackAllocator::allocate(size_t size, size_t align)
 //-----------------------------------------------------------------------------
 void StackAllocator::deallocate(void* data)
 {
+	if (!data)
+		return;
+
 	Header* data_header = (Header*) ((char*)data - sizeof(Header));
 
 	CE_ASSERT(data_header->alloc_id == m_allocation_count - 1,