updating debug manager
This commit is contained in:
parent
88cdbb34a2
commit
8dc0fb855e
|
@ -236,12 +236,11 @@ FT_BEGIN_HEADER
|
||||||
/* */
|
/* */
|
||||||
/* FreeType now comes with an integrated memory debugger that is */
|
/* FreeType now comes with an integrated memory debugger that is */
|
||||||
/* capable of detecting simple errors like memory leaks or double */
|
/* capable of detecting simple errors like memory leaks or double */
|
||||||
/* deletes. You should define the FT_DEBUG_MEMORY macro to enable */
|
/* deletes. To compile it within your build of the library, you should */
|
||||||
/* it.. */
|
/* define FT_DEBUG_MEMORY here. */
|
||||||
/* */
|
/* */
|
||||||
/* beware that when the debugging memory allocator is used, FreeType */
|
/* note that the memory debugger is only activated at runtime when */
|
||||||
/* will use a _lot_ more memory. You should always ensure that this */
|
/* when the _environment_ variable "FT_DEBUG_MEMORY" is also defined ! */
|
||||||
/* macro is undefined in release or testing builds.. */
|
|
||||||
/* */
|
/* */
|
||||||
#define FT_DEBUG_MEMORY
|
#define FT_DEBUG_MEMORY
|
||||||
|
|
||||||
|
|
|
@ -39,6 +39,7 @@
|
||||||
|
|
||||||
FT_ULong alloc_total;
|
FT_ULong alloc_total;
|
||||||
FT_ULong alloc_current;
|
FT_ULong alloc_current;
|
||||||
|
FT_ULong alloc_max;
|
||||||
|
|
||||||
const char* file_name;
|
const char* file_name;
|
||||||
FT_Long line_no;
|
FT_Long line_no;
|
||||||
|
@ -167,7 +168,6 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
static FT_MemTable
|
static FT_MemTable
|
||||||
ft_mem_table_new( void )
|
ft_mem_table_new( void )
|
||||||
{
|
{
|
||||||
|
@ -242,11 +242,14 @@
|
||||||
table->size = 0;
|
table->size = 0;
|
||||||
table->nodes = 0;
|
table->nodes = 0;
|
||||||
free( table );
|
free( table );
|
||||||
|
|
||||||
|
printf( "FreeType: total memory allocations = %ld\n", table->alloc_total );
|
||||||
|
printf( "FreeType: maximum memory footprint = %ld\n", table->alloc_max );
|
||||||
|
|
||||||
if ( leak_count > 0 )
|
if ( leak_count > 0 )
|
||||||
ft_mem_debug_panic( "%ld bytes of memory leaked in %ld blocks\n",
|
ft_mem_debug_panic( "FreeType: %ld bytes of memory leaked in %ld blocks\n",
|
||||||
leaks, leak_count );
|
leaks, leak_count );
|
||||||
printf( "no FreeType memory leaks detected !!\n" );
|
printf( "FreeType: no memory leaks detected !!\n" );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -325,6 +328,8 @@
|
||||||
|
|
||||||
table->alloc_total += size;
|
table->alloc_total += size;
|
||||||
table->alloc_current += size;
|
table->alloc_current += size;
|
||||||
|
if ( table->alloc_current > table->alloc_max )
|
||||||
|
table->alloc_max = table->alloc_current;
|
||||||
|
|
||||||
if ( table->nodes*3 < table->size ||
|
if ( table->nodes*3 < table->size ||
|
||||||
table->size *3 < table->nodes )
|
table->size *3 < table->nodes )
|
||||||
|
@ -446,15 +451,18 @@
|
||||||
{
|
{
|
||||||
FT_MemTable table;
|
FT_MemTable table;
|
||||||
FT_Int result = 0;
|
FT_Int result = 0;
|
||||||
|
|
||||||
table = ft_mem_table_new();
|
if ( getenv( "FT_DEBUG_MEMORY") )
|
||||||
if ( table )
|
{
|
||||||
{
|
table = ft_mem_table_new();
|
||||||
memory->user = table;
|
if ( table )
|
||||||
memory->alloc = ft_mem_debug_alloc;
|
{
|
||||||
memory->realloc = ft_mem_debug_realloc;
|
memory->user = table;
|
||||||
memory->free = ft_mem_debug_free;
|
memory->alloc = ft_mem_debug_alloc;
|
||||||
result = 1;
|
memory->realloc = ft_mem_debug_realloc;
|
||||||
|
memory->free = ft_mem_debug_free;
|
||||||
|
result = 1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue