summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2017-03-29 22:04:43 +0300
committerAndrei Karas <akaras@inbox.ru>2017-03-29 22:04:43 +0300
commit05eecd6ecb0b094584ff6c9cf3c95642cf373a8b (patch)
tree07394f26ad8345969e896aa8f874ee4652ecb443 /src
parentd6c52fbe02be8d81c10bda4c1d8ba80ef5ea5e81 (diff)
downloadplus-05eecd6ecb0b094584ff6c9cf3c95642cf373a8b.tar.gz
plus-05eecd6ecb0b094584ff6c9cf3c95642cf373a8b.tar.bz2
plus-05eecd6ecb0b094584ff6c9cf3c95642cf373a8b.tar.xz
plus-05eecd6ecb0b094584ff6c9cf3c95642cf373a8b.zip
Remove debug code from DEBUG_VIRTFS defines.
Diffstat (limited to 'src')
-rw-r--r--src/CMakeLists.txt1
-rw-r--r--src/Makefile.am1
-rw-r--r--src/debug.h5
-rw-r--r--src/fs/virtfs/virtfsrwops.cpp96
-rw-r--r--src/fs/virtfs/virtfsrwops.h8
-rw-r--r--src/localconsts.h2
-rw-r--r--src/maingui.cpp3
-rw-r--r--src/utils/debugmemoryobject.h50
8 files changed, 1 insertions, 165 deletions
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 6888b14c2..3a59a23b0 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -882,7 +882,6 @@ SET(SRCS
fs/paths.h
utils/perfomance.cpp
utils/perfomance.h
- utils/debugmemoryobject.h
fs/virtfs/virtfsfuncs.h
fs/virtfs/virtfsrwops.cpp
fs/virtfs/virtfsrwops.h
diff --git a/src/Makefile.am b/src/Makefile.am
index 07e79c582..0c6f7f7a9 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -569,7 +569,6 @@ BASE_SRC += events/actionevent.h \
fs/paths.h \
utils/perfomance.cpp \
utils/perfomance.h \
- utils/debugmemoryobject.h \
fs/virtfs/virtfsfuncs.h \
fs/virtfs/virtfsrwops.cpp \
fs/virtfs/virtfsrwops.h \
diff --git a/src/debug.h b/src/debug.h
index bd7f200a5..a4feb574b 100644
--- a/src/debug.h
+++ b/src/debug.h
@@ -62,8 +62,3 @@
#define MSDL_DisplayFormat(surface) SDL_DisplayFormat(surface)
#endif // ENABLE_SDL_DEBUG
-
-
-#ifdef DEBUG_VIRTFS
-#define RWopsOpenRead(name) RWopsOpenRead(name, __FILE__, __LINE__)
-#endif // DEBUG_VIRTFS
diff --git a/src/fs/virtfs/virtfsrwops.cpp b/src/fs/virtfs/virtfsrwops.cpp
index 0816b93eb..546c18e05 100644
--- a/src/fs/virtfs/virtfsrwops.cpp
+++ b/src/fs/virtfs/virtfsrwops.cpp
@@ -48,12 +48,6 @@
#include "fs/virtfs/virtfs.h"
-#ifdef DEBUG_VIRTFS
-#include "utils/debugmemoryobject.h"
-
-#include <map>
-#endif // DEBUG_VIRTFS
-
#include "utils/fuzzer.h"
#include "debug.h"
@@ -70,70 +64,6 @@
static int openedRWops = 0;
#endif // DUMP_LEAKED_RESOURCES
-#ifdef DEBUG_VIRTFS
-namespace
-{
- std::map<void*, VirtFs::DebugMemoryObject*> mRWops;
-} // namespace
-
-static SDL_RWops *addDebugRWops(SDL_RWops *restrict const rwops,
- const char *restrict const name,
- const char *restrict const file,
- const unsigned line)
-{
- if (!rwops)
- return nullptr;
-
- mRWops[rwops] = new VirtFs::DebugMemoryObject(name, file, line);
- return rwops;
-}
-
-static void deleteDebugRWops(SDL_RWops *const rwops)
-{
- if (!rwops)
- return;
-
- std::map<void*, VirtFs::DebugMemoryObject*>::iterator it =
- mRWops.find(rwops);
- if (it == mRWops.end())
- {
- logger->log("bad RWops delete: %p", static_cast<void*>(rwops));
- }
- else
- {
- VirtFs::DebugMemoryObject *const obj = (*it).second;
- if (obj)
- {
- mRWops.erase(rwops);
- delete obj;
- }
- }
-}
-
-void VirtFs::reportLeaks()
-{
- if (!mRWops.empty())
- {
- logger->log("RWops leaks detected");
- std::map<void*, VirtFs::DebugMemoryObject*>::iterator it =
- mRWops.begin();
- const std::map<void*, VirtFs::DebugMemoryObject*>::iterator
- it_end = mRWops.end();
- for (; it != it_end; ++it)
- {
- VirtFs::DebugMemoryObject *obj = (*it).second;
- if (obj)
- {
- logger->log("file: %s at %s", obj->mName.c_str(),
- obj->mAddFile.c_str());
- delete obj;
- }
- }
- mRWops.clear();
- }
-}
-#endif // DEBUG_VIRTFS
-
static RWOPSINT virtfsrwops_seek(SDL_RWops *const rw,
const RWOPSINT offset,
const int whence)
@@ -273,9 +203,6 @@ static int virtfsrwops_close(SDL_RWops *const rw)
logger->assertLog("virtfsrwops_seek: closing already closed RWops");
openedRWops --;
#endif // DUMP_LEAKED_RESOURCES
-#ifdef DEBUG_VIRTFS
- deleteDebugRWops(rw);
-#endif // DEBUG_VIRTFS
return 0;
} /* virtfsrwops_close */
@@ -347,14 +274,7 @@ static bool checkFilePath(const std::string &restrict fname)
}
#endif // __APPLE__
-#ifdef DEBUG_VIRTFS
-#undef RWopsOpenRead
-SDL_RWops *VirtFs::RWopsOpenRead(const std::string &restrict fname,
- const char *restrict const file,
- const unsigned line)
-#else // DEBUG_VIRTFS
SDL_RWops *VirtFs::RWopsOpenRead(const std::string &restrict fname)
-#endif // DEBUG_VIRTFS
{
BLOCK_START("RWopsopenRead")
#ifdef __APPLE__
@@ -367,29 +287,13 @@ SDL_RWops *VirtFs::RWopsOpenRead(const std::string &restrict fname)
#endif // USE_FUZZER
#ifdef USE_PROFILER
-#ifdef DEBUG_VIRTFS
- SDL_RWops *const ret = addDebugRWops(
- create_rwops(VirtFs::openRead(fname)),
- fname,
- file,
- line);
-#else // DEBUG_VIRTFS
SDL_RWops *const ret = create_rwops(VirtFs::openRead(fname));
-#endif // DEBUG_VIRTFS
BLOCK_END("RWopsopenRead")
return ret;
#else // USE_PROFILER
-#ifdef DEBUG_VIRTFS
- return addDebugRWops(
- create_rwops(VirtFs::openRead(fname)),
- fname,
- file,
- line);
-#else // DEBUG_VIRTFS
return create_rwops(VirtFs::openRead(fname));
-#endif // DEBUG_VIRTFS
#endif // USE_PROFILER
} /* RWopsopenRead */
diff --git a/src/fs/virtfs/virtfsrwops.h b/src/fs/virtfs/virtfsrwops.h
index 2703044df..107cc4265 100644
--- a/src/fs/virtfs/virtfsrwops.h
+++ b/src/fs/virtfs/virtfsrwops.h
@@ -54,15 +54,7 @@ struct VirtFile;
namespace VirtFs
{
-#ifdef DEBUG_VIRTFS
- SDL_RWops *RWopsOpenRead(const std::string &restrict fname,
- const char *restrict const file,
- const unsigned line);
- void reportLeaks();
-#else // DEBUG_VIRTFS
SDL_RWops *RWopsOpenRead(const std::string &restrict fname);
-#endif // DEBUG_VIRTFS
-
SDL_RWops *RWopsOpenWrite(const std::string &restrict fname) A_WARN_UNUSED;
SDL_RWops *RWopsOpenAppend(const std::string &restrict fname)
A_WARN_UNUSED;
diff --git a/src/localconsts.h b/src/localconsts.h
index 61bd0aab9..9928a8f1d 100644
--- a/src/localconsts.h
+++ b/src/localconsts.h
@@ -349,7 +349,7 @@ PRAGMA45(GCC diagnostic pop)
// debug SDL surfaces
// #define DEBUG_SDL_SURFACES 1
-// debug RWops usage
+// debug virtfs usage
// #define DEBUG_VIRTFS 1
// use file access fuzzer
diff --git a/src/maingui.cpp b/src/maingui.cpp
index 3725ee59a..18e743557 100644
--- a/src/maingui.cpp
+++ b/src/maingui.cpp
@@ -137,9 +137,6 @@ int mainGui(int argc, char *argv[])
#ifdef DUMP_LEAKED_RESOURCES
VirtFs::reportRWops();
#endif // DUMP_LEAKED_RESOURCES
-#ifdef DEBUG_VIRTFS
- VirtFs::reportLeaks();
-#endif // DEBUG_VIRTFS
return ret;
}
diff --git a/src/utils/debugmemoryobject.h b/src/utils/debugmemoryobject.h
deleted file mode 100644
index e415cb59e..000000000
--- a/src/utils/debugmemoryobject.h
+++ /dev/null
@@ -1,50 +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 <http://www.gnu.org/licenses/>.
- */
-
-#ifndef UTILS_DEBUGMEMORYOBJECT_H
-#define UTILS_DEBUGMEMORYOBJECT_H
-
-#ifdef DEBUG_VIRTFS
-
-#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_VIRTFS
-#endif // UTILS_DEBUGMEMORYOBJECT_H