From c218293c2fe001c23099e73bf9276fe295a7e682 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Fri, 10 Feb 2017 23:19:33 +0300 Subject: Rename physfsmemoryobject into debugmemoryobject. --- src/utils/debugmemoryobject.h | 50 ++++++++++++++++++++++++++++++++++++++++++ src/utils/physfsmemoryobject.h | 47 --------------------------------------- src/utils/virtfsrwops.cpp | 16 +++++++------- 3 files changed, 58 insertions(+), 55 deletions(-) create mode 100644 src/utils/debugmemoryobject.h delete mode 100644 src/utils/physfsmemoryobject.h (limited to 'src/utils') diff --git a/src/utils/debugmemoryobject.h b/src/utils/debugmemoryobject.h new file mode 100644 index 000000000..3f1f0501e --- /dev/null +++ b/src/utils/debugmemoryobject.h @@ -0,0 +1,50 @@ +/* + * The ManaPlus Client + * Copyright (C) 2013-2017 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 . + */ + +#ifndef UTILS_DEBUGMEMORYOBJECT_H +#define UTILS_DEBUGMEMORYOBJECT_H + +#ifdef DEBUG_PHYSFS + +#include "utils/stringutils.h" + +#include "localconsts.h" + +namespace VirtFs +{ + struct DebugMemoryObject final + { + DebugMemoryObject(const char *const name, + const char *const file, + const unsigned int line) : + mName(name), + mAddFile(strprintf("%s:%u", file, line)) + { + } + + A_DELETE_COPY(DebugMemoryObject) + + std::string mName; + std::string mAddFile; + }; +} // VirtFs + +#endif // DEBUG_PHYSFS +#endif // UTILS_DEBUGMEMORYOBJECT_H diff --git a/src/utils/physfsmemoryobject.h b/src/utils/physfsmemoryobject.h deleted file mode 100644 index ec8ecad1f..000000000 --- a/src/utils/physfsmemoryobject.h +++ /dev/null @@ -1,47 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2013-2017 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 . - */ - -#ifndef UTILS_PHYSFSMEMORYOBJECT_H -#define UTILS_PHYSFSMEMORYOBJECT_H - -#ifdef DEBUG_PHYSFS - -#include "utils/stringutils.h" - -#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)) - { - } - - A_DELETE_COPY(PHYSFSMemoryObject) - - std::string mName; - std::string mAddFile; -}; - -#endif // DEBUG_PHYSFS -#endif // UTILS_PHYSFSMEMORYOBJECT_H diff --git a/src/utils/virtfsrwops.cpp b/src/utils/virtfsrwops.cpp index 347d26916..81c8b4726 100644 --- a/src/utils/virtfsrwops.cpp +++ b/src/utils/virtfsrwops.cpp @@ -26,8 +26,8 @@ #include "logger.h" +#include "utils/debugmemoryobject.h" #include "utils/fuzzer.h" -#include "utils/physfsmemoryobject.h" #include @@ -48,7 +48,7 @@ static int openedRWops = 0; #ifdef DEBUG_PHYSFS namespace { - std::map mRWops; + std::map mRWops; } // namespace static SDL_RWops *addDebugRWops(SDL_RWops *restrict const rwops, @@ -59,7 +59,7 @@ static SDL_RWops *addDebugRWops(SDL_RWops *restrict const rwops, if (!rwops) return nullptr; - mRWops[rwops] = new PHYSFSMemoryObject(name, file, line); + mRWops[rwops] = new VirtFs::DebugMemoryObject(name, file, line); return rwops; } @@ -68,14 +68,14 @@ static void deleteDebugRWops(SDL_RWops *const rwops) if (!rwops) return; - std::map::iterator it = mRWops.find(rwops); + std::map::iterator it = mRWops.find(rwops); if (it == mRWops.end()) { logger->log("bad RWops delete: %p", static_cast(rwops)); } else { - PHYSFSMemoryObject *const obj = (*it).second; + VirtFs::DebugMemoryObject *const obj = (*it).second; if (obj) { mRWops.erase(rwops); @@ -89,12 +89,12 @@ void VirtFs::reportLeaks() if (!mRWops.empty()) { logger->log("RWops leaks detected"); - std::map::iterator it = mRWops.begin(); - const std::map::iterator + std::map::iterator it = mRWops.begin(); + const std::map::iterator it_end = mRWops.end(); for (; it != it_end; ++it) { - PHYSFSMemoryObject *obj = (*it).second; + VirtFs::DebugMemoryObject *obj = (*it).second; if (obj) { logger->log("file: %s at %s", obj->mName.c_str(), -- cgit v1.2.3-70-g09d2