summaryrefslogtreecommitdiff
path: root/src/utils/physfsrwops.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/utils/physfsrwops.cpp')
-rw-r--r--src/utils/physfsrwops.cpp20
1 files changed, 20 insertions, 0 deletions
diff --git a/src/utils/physfsrwops.cpp b/src/utils/physfsrwops.cpp
index 31b86058c..022e8160f 100644
--- a/src/utils/physfsrwops.cpp
+++ b/src/utils/physfsrwops.cpp
@@ -24,6 +24,8 @@
#include "utils/physfsrwops.h"
+#include "logger.h"
+
#include "utils/fuzzer.h"
#include <stdio.h>
@@ -38,6 +40,10 @@
#define PHYSFSSIZE int
#endif
+#ifdef DUMP_LEAKED_RESOURCES
+static int openedRWops = 0;
+#endif
+
static PHYSFSINT physfsrwops_seek(SDL_RWops *const rw, const PHYSFSINT offset,
const int whence)
{
@@ -150,6 +156,11 @@ static int physfsrwops_close(SDL_RWops *const rw)
} /* if */
SDL_FreeRW(rw);
+#ifdef DUMP_LEAKED_RESOURCES
+ if (openedRWops <= 0)
+ logger->log("closing already closed RWops");
+ openedRWops --;
+#endif
return 0;
} /* physfsrwops_close */
@@ -184,6 +195,9 @@ static SDL_RWops *create_rwops(PHYSFS_file *const handle)
retval->close = physfsrwops_close;
retval->hidden.unknown.data1 = handle;
} /* if */
+#ifdef DUMP_LEAKED_RESOURCES
+ openedRWops ++;
+#endif
} /* else */
return retval;
@@ -242,4 +256,10 @@ SDL_RWops *PHYSFSRWOPS_openAppend(const char *const fname)
return create_rwops(PhysFs::openAppend(fname));
} /* PHYSFSRWOPS_openAppend */
+void reportRWops()
+{
+ if (openedRWops)
+ logger->log("leaking RWops: %d", openedRWops);
+}
+
/* end of physfsrwops.c ... */