Improve memory debugging. * include/freetype/internal/ftmemory.h (FT_MEM_FREE): Use `FT_DEBUG_INNER' to set source code file name and line. * src/base/ftdbgmem.c (ft_mem_table_remove): Better formatting of tracing message.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54
diff --git a/ChangeLog b/ChangeLog
index 1246f16..7536383 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+2019-10-06 Werner Lemberg <wl@gnu.org>
+
+ Improve memory debugging.
+
+ * include/freetype/internal/ftmemory.h (FT_MEM_FREE): Use
+ `FT_DEBUG_INNER' to set source code file name and line.
+
+ * src/base/ftdbgmem.c (ft_mem_table_remove): Better formatting of
+ tracing message.
+
2019-10-03 Werner Lemberg <wl@gnu.org>
* src/sfnt/sfwoff2 (reconstruct_font): Fix reallocation.
diff --git a/include/freetype/internal/ftmemory.h b/include/freetype/internal/ftmemory.h
index 78bd3bc..f0891ae 100644
--- a/include/freetype/internal/ftmemory.h
+++ b/include/freetype/internal/ftmemory.h
@@ -153,10 +153,10 @@ extern "C++"
(FT_Long)(size), \
&error ) )
-#define FT_MEM_FREE( ptr ) \
- FT_BEGIN_STMNT \
- ft_mem_free( memory, (ptr) ); \
- (ptr) = NULL; \
+#define FT_MEM_FREE( ptr ) \
+ FT_BEGIN_STMNT \
+ FT_DEBUG_INNER( ft_mem_free( memory, (ptr) ) ); \
+ (ptr) = NULL; \
FT_END_STMNT
#define FT_MEM_NEW( ptr ) \
diff --git a/src/base/ftdbgmem.c b/src/base/ftdbgmem.c
index 55cd269..2599c9b 100644
--- a/src/base/ftdbgmem.c
+++ b/src/base/ftdbgmem.c
@@ -621,8 +621,10 @@
if ( node->size < 0 )
ft_mem_debug_panic(
- "freeing memory block at %p more than once at (%s:%ld)\n"
- "block allocated at (%s:%ld) and released at (%s:%ld)",
+ "freeing memory block at %p more than once\n"
+ " at (%s:%ld)!\n"
+ " Block was allocated at (%s:%ld)\n"
+ " and released at (%s:%ld).",
address,
FT_FILENAME( _ft_debug_file ), _ft_debug_lineno,
FT_FILENAME( node->source->file_name ), node->source->line_no,