|
|
@@ -5,6 +5,10 @@
|
|
|
#define USE_DL_PREFIX 1
|
|
|
#define NO_MALLINFO 1
|
|
|
|
|
|
+/* Define this to enable spammy "memmatch" debug output, which can be
|
|
|
+ processed by direct/src/directscripts/memmatch.py. */
|
|
|
+/*#define MEMMATCH 1*/
|
|
|
+
|
|
|
/*
|
|
|
This is a version (aka dlmalloc) of malloc/free/realloc written by
|
|
|
Doug Lea and released to the public domain, as explained at
|
|
|
@@ -2028,6 +2032,10 @@ static struct malloc_state _gm_;
|
|
|
#define is_global(M) ((M) == &_gm_)
|
|
|
#define is_initialized(M) ((M)->top != 0)
|
|
|
|
|
|
+#ifdef MEMMATCH
|
|
|
+static int output_counter = 0;
|
|
|
+#endif
|
|
|
+
|
|
|
/* -------------------------- system alloc setup ------------------------- */
|
|
|
|
|
|
/* Operations on mflags */
|
|
|
@@ -4153,9 +4161,17 @@ void* dlmalloc(size_t bytes) {
|
|
|
|
|
|
postaction:
|
|
|
POSTACTION(gm);
|
|
|
+#ifdef MEMMATCH
|
|
|
+ fprintf(stderr, "memmatch %p %08d malloc(%d)\n",
|
|
|
+ mem, ++output_counter, bytes);
|
|
|
+#endif
|
|
|
return mem;
|
|
|
}
|
|
|
|
|
|
+#ifdef MEMMATCH
|
|
|
+ fprintf(stderr, "memmatch %p %08d malloc(%d)\n",
|
|
|
+ 0, ++output_counter, bytes);
|
|
|
+#endif
|
|
|
return 0;
|
|
|
}
|
|
|
|
|
|
@@ -4166,6 +4182,11 @@ void dlfree(void* mem) {
|
|
|
with special cases for top, dv, mmapped chunks, and usage errors.
|
|
|
*/
|
|
|
|
|
|
+#ifdef MEMMATCH
|
|
|
+ fprintf(stderr, "memmatch %p %08d free\n",
|
|
|
+ mem, ++output_counter);
|
|
|
+#endif
|
|
|
+
|
|
|
if (mem != 0) {
|
|
|
mchunkptr p = mem2chunk(mem);
|
|
|
#if FOOTERS
|