* include/freetype/ftstream.h, src/base/ftstream.c: modifying various frame-related functions to report the place where the frames were entered/extracted/exited/released in the memory debugger.
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 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93
diff --git a/ChangeLog b/ChangeLog
index 362b06a..32a7f18 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,9 @@
2006-05-02 David Turner <david@freetype.org>
+ * include/freetype/ftstream.h, src/base/ftstream.c: modifying
+ various frame-related functions to report the place where the
+ frames were entered/extracted/exited/released in the memory debugger.
+
* include/freetype/internal/ftmemory.h, src/base/ftbitmap.c,
src/base/ftmac.c, src/base/ftrfork.c, src/lzw/ftzopen.c,
src/raster/ftrend1.c, src/sfnt/ttpost.c, src/truetype/ttgxvar.c,
diff --git a/include/freetype/internal/ftstream.h b/include/freetype/internal/ftstream.h
index c5a391e..960cf6f 100644
--- a/include/freetype/internal/ftstream.h
+++ b/include/freetype/internal/ftstream.h
@@ -515,17 +515,18 @@ FT_BEGIN_HEADER
#define FT_FRAME_ENTER( size ) \
- FT_SET_ERROR( FT_Stream_EnterFrame( stream, size ) )
+ FT_SET_ERROR( FT_DEBUG_INNER( FT_Stream_EnterFrame( stream, size ) ) )
#define FT_FRAME_EXIT() \
- FT_Stream_ExitFrame( stream )
+ FT_DEBUG_INNER( FT_Stream_ExitFrame( stream ) )
-#define FT_FRAME_EXTRACT( size, bytes ) \
- FT_SET_ERROR( FT_Stream_ExtractFrame( stream, size, \
- (FT_Byte**)&(bytes) ) )
+#define FT_FRAME_EXTRACT( size, bytes ) \
+ FT_SET_ERROR( \
+ FT_DEBUG_INNER( FT_Stream_ExtractFrame( stream, size, \
+ (FT_Byte**)&(bytes) ) ) )
#define FT_FRAME_RELEASE( bytes ) \
- FT_Stream_ReleaseFrame( stream, (FT_Byte**)&(bytes) )
+ FT_DEBUG_INNER( FT_Stream_ReleaseFrame( stream, (FT_Byte**)&(bytes) ) )
FT_END_HEADER
diff --git a/src/base/ftstream.c b/src/base/ftstream.c
index 3b7b29f..ac62ee1 100644
--- a/src/base/ftstream.c
+++ b/src/base/ftstream.c
@@ -212,8 +212,12 @@
{
FT_Memory memory = stream->memory;
-
+#ifdef FT_DEBUG_MEMORY
+ ft_mem_free( memory, *pbytes );
+ *pbytes = NULL;
+#else
FT_FREE( *pbytes );
+#endif
}
*pbytes = 0;
}
@@ -235,10 +239,15 @@
/* allocate the frame in memory */
FT_Memory memory = stream->memory;
-
+#ifdef FT_DEBUG_MEMORY
+ /* assume _ft_debug_file and _ft_debug_lineno are already set */
+ stream->base = ft_mem_qalloc( memory, count, &error );
+ if ( error )
+ goto Exit;
+#else
if ( FT_QALLOC( stream->base, count ) )
goto Exit;
-
+#endif
/* read it */
read_bytes = stream->read( stream, stream->pos,
stream->base, count );
@@ -298,8 +307,12 @@
{
FT_Memory memory = stream->memory;
-
+#ifdef FT_DEBUG_MEMORY
+ ft_mem_free( memory, stream->base );
+ stream->base = NULL;
+#else
FT_FREE( stream->base );
+#endif
}
stream->cursor = 0;
stream->limit = 0;