Commit 0fcf486e0d6f3bb1cb17b6a6f00f651e21077dda

Werner Lemberg 2019-10-06T21:12:42

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.

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,