diff --git a/drivers/unix/memory_pool_static_malloc.cpp b/drivers/unix/memory_pool_static_malloc.cpp index ac26e230a63..63057ef4b5c 100644 --- a/drivers/unix/memory_pool_static_malloc.cpp +++ b/drivers/unix/memory_pool_static_malloc.cpp @@ -67,10 +67,10 @@ void *MemoryPoolStaticMalloc::_alloc(size_t p_bytes, const char *p_description) ERR_FAIL_COND_V(p_bytes == 0, 0); - MutexLock lock(mutex); - #ifdef DEBUG_MEMORY_ENABLED + MutexLock lock(mutex); + size_t total; #if defined(_add_overflow) if (_add_overflow(p_bytes, sizeof(RingPtr), &total)) return NULL; @@ -176,10 +176,10 @@ void *MemoryPoolStaticMalloc::_realloc(void *p_memory, size_t p_bytes) { return NULL; } - MutexLock lock(mutex); - #ifdef DEBUG_MEMORY_ENABLED + MutexLock lock(mutex); + RingPtr *ringptr = (RingPtr *)p_memory; ringptr--; /* go back an element to find the tingptr */ @@ -240,10 +240,10 @@ void MemoryPoolStaticMalloc::free(void *p_ptr) { void MemoryPoolStaticMalloc::_free(void *p_ptr) { - MutexLock lock(mutex); - #ifdef DEBUG_MEMORY_ENABLED + MutexLock lock(mutex); + if (p_ptr == 0) { printf("**ERROR: STATIC ALLOC: Attempted free of NULL pointer.\n"); return; @@ -298,7 +298,7 @@ void MemoryPoolStaticMalloc::_free(void *p_ptr) { total_mem -= ringptr->size; total_pointers--; // catch more errors - zeromem(ringptr, sizeof(RingPtr) + ringptr->size); + memset(ringptr, 0xEA, sizeof(RingPtr) + ringptr->size); ::free(ringptr); //just free that pointer #else