ref: 9482ba50b7eae7312d4eace1433de6e1d2186267
parent: 9ca782569c218e18c420e7c13bdbdf3e9a75c87a
author: David Turner <[email protected]>
date: Tue May 2 06:21:28 EDT 2006
* 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.
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,9 @@
2006-05-02 David Turner <[email protected]>
+ * 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,
--- a/include/freetype/internal/ftstream.h
+++ b/include/freetype/internal/ftstream.h
@@ -515,17 +515,18 @@
#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
--- 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;