From: Guus Sliepen Date: Sun, 26 Dec 2010 13:16:49 +0000 (+0100) Subject: Remove redundant NULL pointer checks when deallocating. X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=b11cf27d62fe648bf88625645c21c556ae26ee9b;p=quix0rs-blobwars.git Remove redundant NULL pointer checks when deallocating. --- diff --git a/src/CEngine.cpp b/src/CEngine.cpp index 10bdf60..823953d 100644 --- a/src/CEngine.cpp +++ b/src/CEngine.cpp @@ -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); diff --git a/src/CPak.cpp b/src/CPak.cpp index 5698fa0..8d171e8 100644 --- a/src/CPak.cpp +++ b/src/CPak.cpp @@ -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)); diff --git a/src/pak.cpp b/src/pak.cpp index 257908a..d70fe57 100644 --- a/src/pak.cpp +++ b/src/pak.cpp @@ -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");