Forráskód Böngészése

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

Darryl Gough 14 éve
szülő
commit
779a5f7f07
2 módosított fájl, 2 hozzáadás és 3 törlés
  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
 // Object deletion macro
 #define SAFE_DELETE(x) \
 #define SAFE_DELETE(x) \
-    if (x) \
     { \
     { \
         delete x; \
         delete x; \
         x = NULL; \
         x = NULL; \
@@ -116,7 +115,6 @@ extern void printError(const char* format, ...);
 
 
 // Array deletion macro
 // Array deletion macro
 #define SAFE_DELETE_ARRAY(x) \
 #define SAFE_DELETE_ARRAY(x) \
-    if (x) \
     { \
     { \
         delete[] x; \
         delete[] x; \
         x = NULL; \
         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)
 void debugFree(void* p)
 {
 {
-    assert(p);
+    if (p == 0)
+        return;
 
 
     // Backup passed in pointer to access memory allocation record
     // Backup passed in pointer to access memory allocation record
     void* mem = ((unsigned char*)p) - sizeof(MemoryAllocationRecord);
     void* mem = ((unsigned char*)p) - sizeof(MemoryAllocationRecord);