Pārlūkot izejas kodu

Changed SAFE_DELETE so that it doesn't check for NULL. It is valid to call "delete 0;"

Darryl Gough 14 gadi atpakaļ
vecāks
revīzija
779a5f7f07
2 mainītis faili ar 2 papildinājumiem un 3 dzēšanām
  1. 0 2
      gameplay/src/Base.h
  2. 2 1
      gameplay/src/DebugNew.cpp

+ 0 - 2
gameplay/src/Base.h

@@ -108,7 +108,6 @@ extern void printError(const char* format, ...);
 
 // Object deletion macro
 #define SAFE_DELETE(x) \
-    if (x) \
     { \
         delete x; \
         x = NULL; \
@@ -116,7 +115,6 @@ extern void printError(const char* format, ...);
 
 // Array deletion macro
 #define SAFE_DELETE_ARRAY(x) \
-    if (x) \
     { \
         delete[] x; \
         x = NULL; \

+ 2 - 1
gameplay/src/DebugNew.cpp

@@ -109,7 +109,8 @@ void* debugAlloc(std::size_t size, const char* file, int line)
 
 void debugFree(void* p)
 {
-    assert(p);
+    if (p == 0)
+        return;
 
     // Backup passed in pointer to access memory allocation record
     void* mem = ((unsigned char*)p) - sizeof(MemoryAllocationRecord);