diff options
author | Andrei Karas <akaras@inbox.ru> | 2013-10-23 19:50:09 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2013-10-23 19:50:09 +0300 |
commit | 033a6162914b8f6cdea446751160ca81fbd4c1ca (patch) | |
tree | 88495eb1523c113812f78bdc95ed0816a8ee9e86 | |
parent | 0dca3216743cd5deaffad45ca50fccd7280eb6bd (diff) | |
download | manaplus-033a6162914b8f6cdea446751160ca81fbd4c1ca.tar.gz manaplus-033a6162914b8f6cdea446751160ca81fbd4c1ca.tar.bz2 manaplus-033a6162914b8f6cdea446751160ca81fbd4c1ca.tar.xz manaplus-033a6162914b8f6cdea446751160ca81fbd4c1ca.zip |
replace some malloc/free by new/delete.
-rw-r--r-- | src/net/download.cpp | 5 | ||||
-rw-r--r-- | src/render/mobileopenglgraphics.cpp | 4 | ||||
-rw-r--r-- | src/render/normalopenglgraphics.cpp | 4 | ||||
-rw-r--r-- | src/render/safeopenglgraphics.cpp | 4 | ||||
-rw-r--r-- | src/resources/resourcemanager.cpp | 4 |
5 files changed, 10 insertions, 11 deletions
diff --git a/src/net/download.cpp b/src/net/download.cpp index 3f26aabe7..3ccff63c8 100644 --- a/src/net/download.cpp +++ b/src/net/download.cpp @@ -117,15 +117,14 @@ unsigned long Download::fadler32(FILE *const file) rewind(file); // Calculate Adler-32 checksum - char *const buffer = static_cast<char*>(malloc(fileSize)); + char *const buffer = new char[fileSize]; if (!buffer) return 0; const uInt read = static_cast<uInt>(fread(buffer, 1, fileSize, file)); unsigned long adler = adler32(0L, Z_NULL, 0); adler = adler32(static_cast<uInt>(adler), reinterpret_cast<Bytef*>(buffer), read); - free(buffer); - + delete [] buffer; return adler; } diff --git a/src/render/mobileopenglgraphics.cpp b/src/render/mobileopenglgraphics.cpp index 91184958b..ce930f416 100644 --- a/src/render/mobileopenglgraphics.cpp +++ b/src/render/mobileopenglgraphics.cpp @@ -906,7 +906,7 @@ SDL_Surface* MobileOpenGLGraphics::getScreenshot() SDL_LockSurface(screenshot); const unsigned int lineSize = 3 * w; - GLubyte *const buf = static_cast<GLubyte*>(malloc(lineSize)); + GLubyte *const buf = new GLubyte[lineSize]; if (!buf) return nullptr; @@ -929,7 +929,7 @@ SDL_Surface* MobileOpenGLGraphics::getScreenshot() memcpy(bot, buf, lineSize); } - free(buf); + delete [] buf; if (config.getBoolValue("usefbo")) graphicsManager.deleteFBO(&mFbo); diff --git a/src/render/normalopenglgraphics.cpp b/src/render/normalopenglgraphics.cpp index 4222051ea..fd5568b87 100644 --- a/src/render/normalopenglgraphics.cpp +++ b/src/render/normalopenglgraphics.cpp @@ -1124,7 +1124,7 @@ SDL_Surface* NormalOpenGLGraphics::getScreenshot() // Flip the screenshot, as OpenGL has 0,0 in bottom left const unsigned int lineSize = 3 * w; - GLubyte *const buf = static_cast<GLubyte *const>(malloc(lineSize)); + GLubyte *const buf = new GLubyte[lineSize]; const int h2 = h / 2; for (int i = 0; i < h2; i++) @@ -1139,7 +1139,7 @@ SDL_Surface* NormalOpenGLGraphics::getScreenshot() memcpy(bot, buf, lineSize); } - free(buf); + delete [] buf; if (config.getBoolValue("usefbo")) graphicsManager.deleteFBO(&mFbo); diff --git a/src/render/safeopenglgraphics.cpp b/src/render/safeopenglgraphics.cpp index cd3338188..1daf054ba 100644 --- a/src/render/safeopenglgraphics.cpp +++ b/src/render/safeopenglgraphics.cpp @@ -449,7 +449,7 @@ SDL_Surface* SafeOpenGLGraphics::getScreenshot() // Flip the screenshot, as OpenGL has 0,0 in bottom left unsigned int lineSize = 3 * w; - GLubyte* buf = static_cast<GLubyte*>(malloc(lineSize)); + GLubyte* buf = new GLubyte[lineSize]; const int h2 = h / 2; for (int i = 0; i < h2; i++) @@ -464,7 +464,7 @@ SDL_Surface* SafeOpenGLGraphics::getScreenshot() memcpy(bot, buf, lineSize); } - free(buf); + delete [] buf; if (config.getBoolValue("usefbo")) graphicsManager.deleteFBO(&mFbo); diff --git a/src/resources/resourcemanager.cpp b/src/resources/resourcemanager.cpp index 6b93901d9..ebf2f94bd 100644 --- a/src/resources/resourcemanager.cpp +++ b/src/resources/resourcemanager.cpp @@ -968,13 +968,13 @@ bool ResourceManager::copyFile(const std::string &src, } const int fileSize = static_cast<const int>(PHYSFS_fileLength(srcFile)); - void *buf = malloc(fileSize); + void *buf = new char[fileSize]; PHYSFS_read(srcFile, buf, 1, fileSize); PHYSFS_write(dstFile, buf, 1, fileSize); PHYSFS_close(srcFile); PHYSFS_close(dstFile); - free(buf); + delete [] buf; return true; } |