From 9482ba50b7eae7312d4eace1433de6e1d2186267 Mon Sep 17 00:00:00 2001 From: David Turner Date: Tue, 2 May 2006 10:21:28 +0000 Subject: [PATCH] * 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. --- ChangeLog | 4 ++++ include/freetype/internal/ftstream.h | 13 +++++++------ src/base/ftstream.c | 21 +++++++++++++++++---- 3 files changed, 28 insertions(+), 10 deletions(-) diff --git a/ChangeLog b/ChangeLog index 362b06a72..32a7f18f5 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,9 @@ 2006-05-02 David Turner + * 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 c5a391ef6..960cf6f62 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 3b7b29f90..ac62ee1f2 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;