diff options
author | Andrei Karas <akaras@inbox.ru> | 2014-05-20 22:52:43 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2014-05-20 23:03:44 +0300 |
commit | 2c844378584de4d0540766d71c906a189bff95fa (patch) | |
tree | 91c1e4f3fe4559a14951a6663d29a0773b771284 | |
parent | d75ab9a77c15b7a99dcd5051846e4978c3ab71c1 (diff) | |
download | manaverse-2c844378584de4d0540766d71c906a189bff95fa.tar.gz manaverse-2c844378584de4d0540766d71c906a189bff95fa.tar.bz2 manaverse-2c844378584de4d0540766d71c906a189bff95fa.tar.xz manaverse-2c844378584de4d0540766d71c906a189bff95fa.zip |
Move physfsmemoryobject into separate file.
-rw-r--r-- | src/CMakeLists.txt | 1 | ||||
-rw-r--r-- | src/Makefile.am | 1 | ||||
-rw-r--r-- | src/utils/physfscheckutils.cpp | 30 | ||||
-rw-r--r-- | src/utils/physfsmemoryobject.h | 45 |
4 files changed, 56 insertions, 21 deletions
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index cc771d49b..06f21b243 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -653,6 +653,7 @@ SET(SRCS utils/perfomance.h utils/physfscheckutils.cpp utils/physfscheckutils.h + utils/physfsmemoryobject.h utils/physfsrwops.cpp utils/physfsrwops.h utils/physfstools.cpp diff --git a/src/Makefile.am b/src/Makefile.am index 1f1e24f2f..f32d0fabb 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -761,6 +761,7 @@ manaplus_SOURCES += gui/widgets/avatarlistbox.cpp \ utils/perfomance.h \ utils/physfscheckutils.cpp \ utils/physfscheckutils.h \ + utils/physfsmemoryobject.h \ utils/physfsrwops.cpp \ utils/physfsrwops.h \ utils/physfstools.cpp \ diff --git a/src/utils/physfscheckutils.cpp b/src/utils/physfscheckutils.cpp index 103726e19..68e636e9e 100644 --- a/src/utils/physfscheckutils.cpp +++ b/src/utils/physfscheckutils.cpp @@ -26,6 +26,7 @@ #include "utils/stringutils.h" +#include "utils/physfsmemoryobject.h" #include "utils/physfsrwops.h" #include <map> @@ -34,21 +35,7 @@ namespace { - struct MemoryObject - { - MemoryObject(const char *const name, - const char *const file, - const unsigned int line) : - mName(name), - mAddFile(strprintf("%s:%u", file, line)) - { - } - - std::string mName; - std::string mAddFile; - }; - - std::map<void*, MemoryObject*> mRWops; + std::map<void*, PHYSFSMemoryObject*> mRWops; } // namespace static SDL_RWops *addRWops(SDL_RWops *restrict const rwops, @@ -59,7 +46,7 @@ static SDL_RWops *addRWops(SDL_RWops *restrict const rwops, if (!rwops) return nullptr; - mRWops[rwops] = new MemoryObject(name, file, line); + mRWops[rwops] = new PHYSFSMemoryObject(name, file, line); return rwops; } @@ -68,14 +55,14 @@ static void deleteRWops(SDL_RWops *const rwops) if (!rwops) return; - std::map<void*, MemoryObject*>::iterator it = mRWops.find(rwops); + std::map<void*, PHYSFSMemoryObject*>::iterator it = mRWops.find(rwops); if (it == mRWops.end()) { logger->log("bad RWops delete: %p", static_cast<void*>(rwops)); } else { - MemoryObject *const obj = (*it).second; + PHYSFSMemoryObject *const obj = (*it).second; if (obj) { mRWops.erase(rwops); @@ -101,11 +88,12 @@ void reportPhysfsLeaks() if (!mRWops.empty()) { logger->log("RWops leaks detected"); - std::map<void*, MemoryObject*>::iterator it = mRWops.begin(); - const std::map<void*, MemoryObject*>::iterator it_end = mRWops.end(); + std::map<void*, PHYSFSMemoryObject*>::iterator it = mRWops.begin(); + const std::map<void*, PHYSFSMemoryObject*>::iterator + it_end = mRWops.end(); for (; it != it_end; ++it) { - MemoryObject *obj = (*it).second; + PHYSFSMemoryObject *obj = (*it).second; if (obj) { logger->log("file: %s at %s", obj->mName.c_str(), diff --git a/src/utils/physfsmemoryobject.h b/src/utils/physfsmemoryobject.h new file mode 100644 index 000000000..f19c6cac1 --- /dev/null +++ b/src/utils/physfsmemoryobject.h @@ -0,0 +1,45 @@ +/* + * The ManaPlus Client + * Copyright (C) 2013-2014 The ManaPlus Developers + * + * This file is part of The ManaPlus Client. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +#ifndef UTILS_PHYSFSMEMORYOBJECT_H +#define UTILS_PHYSFSMEMORYOBJECT_H + +#ifdef DEBUG_PHYSFS + +#include <string> + +#include "localconsts.h" + +struct PHYSFSMemoryObject final +{ + PHYSFSMemoryObject(const char *const name, + const char *const file, + const unsigned int line) : + mName(name), + mAddFile(strprintf("%s:%u", file, line)) + { + } + + std::string mName; + std::string mAddFile; +}; + +#endif // DEBUG_PHYSFS +#endif // UTILS_PHYSFSMEMORYOBJECT_H |