diff options
author | Andrei Karas <akaras@inbox.ru> | 2013-09-15 00:32:07 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2013-09-15 00:32:07 +0300 |
commit | 57288890689bfa2c2d35882169a539813be621f1 (patch) | |
tree | 8c2886837e997d073906cb85aee38c9d77a8069b /src/utils | |
parent | 53947c9d39440424dcf815ea5df130e833457437 (diff) | |
download | plus-57288890689bfa2c2d35882169a539813be621f1.tar.gz plus-57288890689bfa2c2d35882169a539813be621f1.tar.bz2 plus-57288890689bfa2c2d35882169a539813be621f1.tar.xz plus-57288890689bfa2c2d35882169a539813be621f1.zip |
add RWops leaks reporting.
Diffstat (limited to 'src/utils')
-rw-r--r-- | src/utils/physfsrwops.cpp | 6 | ||||
-rw-r--r-- | src/utils/physfsrwops.h | 2 | ||||
-rw-r--r-- | src/utils/sdlcheckutils.cpp | 18 |
3 files changed, 17 insertions, 9 deletions
diff --git a/src/utils/physfsrwops.cpp b/src/utils/physfsrwops.cpp index 022e8160f..aa5caf7c7 100644 --- a/src/utils/physfsrwops.cpp +++ b/src/utils/physfsrwops.cpp @@ -27,6 +27,7 @@ #include "logger.h" #include "utils/fuzzer.h" +#include "utils/physfscheckutils.h" #include <stdio.h> @@ -161,6 +162,9 @@ static int physfsrwops_close(SDL_RWops *const rw) logger->log("closing already closed RWops"); openedRWops --; #endif +#ifdef DEBUG_PHYSFS + FakePhysFSClose(rw); +#endif return 0; } /* physfsrwops_close */ @@ -256,10 +260,12 @@ SDL_RWops *PHYSFSRWOPS_openAppend(const char *const fname) return create_rwops(PhysFs::openAppend(fname)); } /* PHYSFSRWOPS_openAppend */ +#ifdef DUMP_LEAKED_RESOURCES void reportRWops() { if (openedRWops) logger->log("leaking RWops: %d", openedRWops); } +#endif /* end of physfsrwops.c ... */ diff --git a/src/utils/physfsrwops.h b/src/utils/physfsrwops.h index 45ee21cc4..7e859a234 100644 --- a/src/utils/physfsrwops.h +++ b/src/utils/physfsrwops.h @@ -79,6 +79,8 @@ SDL_RWops *PHYSFSRWOPS_openAppend(const char *const fname) A_WARN_UNUSED; */ SDL_RWops *PHYSFSRWOPS_makeRWops(PHYSFS_file *const handle) A_WARN_UNUSED; +#ifdef DUMP_LEAKED_RESOURCES void reportRWops(); +#endif #endif // UTILS_PHYSFSRWOPS_H diff --git a/src/utils/sdlcheckutils.cpp b/src/utils/sdlcheckutils.cpp index 50adedb28..3810672d9 100644 --- a/src/utils/sdlcheckutils.cpp +++ b/src/utils/sdlcheckutils.cpp @@ -35,10 +35,10 @@ #define DEBUG_SURFACE_ALLOCATION 1 -struct SurfaceObject +struct MemoryObject { - SurfaceObject(const std::string &name, const char *const file, - const unsigned int line) : + MemoryObject(const std::string &name, const char *const file, + const unsigned int line) : mName(name), mAddFile(strprintf("%s:%u", file, line)), mRemoveFile(), @@ -52,7 +52,7 @@ struct SurfaceObject int mCnt; }; -std::map<SDL_Surface*, SurfaceObject*> mSurfaces; +std::map<void*, MemoryObject*> mSurfaces; static SDL_Surface *addSurface(const char *const name, SDL_Surface *const surface, @@ -63,11 +63,11 @@ static SDL_Surface *addSurface(const char *const name, logger->log("add surface: %s %s:%u %p", name, file, line, static_cast<void*>(surface)); #endif - std::map<SDL_Surface*, SurfaceObject*>::iterator + std::map<void*, MemoryObject*>::iterator it = mSurfaces.find(surface); if (it != mSurfaces.end()) { - SurfaceObject *const obj = (*it).second; + MemoryObject *const obj = (*it).second; if (obj) { // found some time ago created surface #ifdef DEBUG_SURFACE_ALLOCATION @@ -80,7 +80,7 @@ static SDL_Surface *addSurface(const char *const name, } else { // creating surface object - mSurfaces[surface] = new SurfaceObject(name, file, line); + mSurfaces[surface] = new MemoryObject(name, file, line); } return surface; } @@ -93,7 +93,7 @@ static void deleteSurface(const char *const name A_UNUSED, #ifdef DEBUG_SURFACE_ALLOCATION logger->log("delete surface: %s %s:%u %p", name, file, line, surface); #endif - std::map<SDL_Surface*, SurfaceObject*>::iterator + std::map<void*, MemoryObject*>::iterator it = mSurfaces.find(surface); if (it == mSurfaces.end()) { @@ -102,7 +102,7 @@ static void deleteSurface(const char *const name A_UNUSED, } else { - SurfaceObject *const obj = (*it).second; + MemoryObject *const obj = (*it).second; if (obj) { const int cnt = obj->mCnt; |