]> git.mxchange.org Git - quix0rs-blobwars.git/commitdiff
Remove redundant NULL pointer checks when deallocating.
authorGuus Sliepen <guus@debian.org>
Sun, 26 Dec 2010 13:16:49 +0000 (14:16 +0100)
committerGuus Sliepen <guus@debian.org>
Sun, 26 Dec 2010 13:16:49 +0000 (14:16 +0100)
src/CEngine.cpp
src/CPak.cpp
src/pak.cpp

index 10bdf60c38fc5eee014a2f30f4156bfa98d6cdc0..823953d455d113d511dc85a25ea97e9f489dd3db 100644 (file)
@@ -96,12 +96,10 @@ void Engine::destroy()
        deleteWidgets();
 
        debug(("engine: free databuffer\n"));
-       if (dataBuffer != NULL)
-               delete[] dataBuffer;
+       delete[] dataBuffer;
 
        debug(("engine: free binarybuffer\n"));
-       if (binaryBuffer != NULL)
-               delete[] binaryBuffer;
+       delete[] binaryBuffer;
 
        debug(("Clearing Define List...\n"));
        defineList.clear();
@@ -333,16 +331,12 @@ bool Engine::unpack(const char *filename, int fileType)
 {
        if (fileType == PAK_DATA)
        {
-               if (dataBuffer != NULL)
-                       delete[] dataBuffer;
-
+               delete[] dataBuffer;
                dataBuffer = NULL;
        }
        else
        {
-               if (binaryBuffer != NULL)
-                       delete[] binaryBuffer;
-
+               delete[] binaryBuffer;
                binaryBuffer = NULL;
        }
 
@@ -405,11 +399,8 @@ bool Engine::unpack(const char *filename, int fileType)
 
 bool Engine::loadData(const char *filename)
 {
-       if (dataBuffer != NULL)
-       {
-               delete[] dataBuffer;
-               dataBuffer = NULL;
-       }
+       delete[] dataBuffer;
+       dataBuffer = NULL;
        
        #if USEPAK
                return unpack(filename, PAK_DATA);
index 5698fa0176c4704d0c96619b491bf8133d269a1b..8d171e83d0c8ac66a858e7e0adaf6307d8c6f6fd 100644 (file)
@@ -35,15 +35,8 @@ Pak::Pak()
 
 Pak::~Pak()
 {
-       if (input != NULL)
-               delete[] input;
-               
-       input = NULL;
-       
-       if (fd != NULL)
-               delete[] fd;
-       
-       fd = NULL;
+       delete[] input;
+       delete[] fd;
 }
 
 void Pak::showPakErrorAndExit()
@@ -131,11 +124,7 @@ bool Pak::unpack(const char *filename, unsigned char **buffer)
        
        fseek(pak, currentFile->location, SEEK_SET);
 
-       if (input != NULL)
-       {
-               delete[] input;
-       }
-
+       delete[] input;
        input = NULL;
        
        input = new unsigned char[(int)(currentFile->cSize * 1.01) + 12];
@@ -150,9 +139,7 @@ bool Pak::unpack(const char *filename, unsigned char **buffer)
 
        fclose(pak);
        
-       if (input != NULL)
-               delete[] input;
-
+       delete[] input;
        input = NULL;
        
        debug(("Pak : Unpack %s...Done\n", filename));
index 257908a702d8b45b3028b4d1561848b56fb964d6..d70fe571864cc15227742e257cd782486f9b5567 100644 (file)
@@ -30,15 +30,8 @@ FileData *fileData = NULL;
 
 void cleanup()
 {
-       if (buffer != NULL)
-       {
-               delete[] buffer;
-       }
-       
-       if (output != NULL)
-       {
-               delete[] output;
-       }
+       delete[] buffer;
+       delete[] output;
 }
 
 void countFiles(const char *dirName)
@@ -136,20 +129,10 @@ void recurseDirectory(const char *dirName)
                        
                        fclose(infile);
                        
-                       if (buffer != NULL)
-                       {
-                               delete[] buffer;
-                               buffer = NULL;
-                       }
-                       
+                       delete[] buffer;
                        buffer = new unsigned char[filesize];
                        
-                       if (output != NULL)
-                       {
-                               delete[] output;
-                               output = NULL;
-                       }
-                       
+                       delete[] output;
                        output = new unsigned char[(int)(filesize * 1.01) + 12];
                        
                        fp = gzopen(filename, "rb");