ref: 2a98b3c431091de7434f9bde087a4f5c47f463ba
parent: 90f68b727208b3a27b7a8c4694960d88d81570cf
author: David Turner <[email protected]>
date: Fri Jun 23 09:47:55 EDT 2000
reduced some nasty memory leaks
--- a/demos/Makefile
+++ b/demos/Makefile
@@ -161,7 +161,7 @@
# The list of demonstration programs to build.
#
# EXES := ftlint ftview fttimer compos ftstring memtest ftmulti
- EXES := ftlint ftview
+ EXES := ftlint ftview fttimer ftstring memtest ftmulti
ifneq ($(findstring $(PLATFORM),os2 unix win32),)
EXES += ttdebug
--- a/demos/src/memtest.c
+++ b/demos/src/memtest.c
@@ -42,6 +42,12 @@
static MyBlock my_blocks[ MAX_RECORDED_BLOCKS ];
static int num_my_blocks = 0;
+static
+void rewind_memory( void )
+{
+ num_my_blocks = 0;
+}
+
/* record a new block in the table, check for duplicates too */
static
void record_my_block( void* base, long size )
@@ -100,13 +106,13 @@
}
else
{
- fprintf( stderr, "Block at %08lx released twice \n", (long)base );
+ fprintf( stderr, "Block at %p released twice \n", base );
exit(1);
}
}
}
- fprintf( stderr, "Trying to release an unallocated block at %08lx\n",
- (long)base );
+ fprintf( stderr, "Trying to release an unallocated block at %p\n",
+ base );
exit(1);
}
@@ -126,7 +132,7 @@
void my_free( FT_Memory memory, void* block )
{
forget_my_block(block);
- free(block);
+ /* free(block); WE DO NOT REALLY FREE THE BLOCK */
}
static
@@ -140,9 +146,16 @@
p = my_alloc( memory, new_size );
if (p)
{
+ long size;
+
+ size = cur_size;
+ if (new_size < size)
+ size = new_size;
+
+ memcpy( p, block, size );
my_free( memory, block );
- record_my_block( p, new_size );
}
+
return p;
}
@@ -168,7 +181,7 @@
{
if (block->size > 0)
{
- fprintf( stderr, "%08lx (%6ld bytes) leaked !!\n", (long)block->base, (long)block->size );
+ fprintf( stderr, "%p (%6ld bytes) leaked !!\n", block->base, (long)block->size );
bad = 1;
}
}
--- a/src/base/ftobjs.c
+++ b/src/base/ftobjs.c
@@ -1337,6 +1337,7 @@
else
error = FT_Err_Invalid_Handle;
+ ft_done_stream( &stream );
goto Fail;
}
else
@@ -1370,6 +1371,8 @@
goto Fail;
}
}
+
+ ft_done_stream( &stream );
/* no driver is able to handle this format */
error = FT_Err_Unknown_File_Format;
--- a/src/truetype/ttgload.c
+++ b/src/truetype/ttgload.c
@@ -392,8 +392,6 @@
}
}
- FORGET_Frame();
-
/* clear the touch tags */
for ( n = 0; n < n_points; n++ )
outline->tags[n] &= FT_Curve_Tag_On;
--- a/src/type1/t1load.c
+++ b/src/type1/t1load.c
@@ -1245,9 +1245,10 @@
/* copy recorder sub-routines */
T1_Done_Table( &parser->table );
- parser->subrs = parser->table.block;
- type1->subrs = parser->table.elements;
- type1->subrs_len = parser->table.lengths;
+ parser->subrs = parser->table.block;
+ type1->subrs = parser->table.elements;
+ type1->subrs_len = parser->table.lengths;
+ type1->subrs_block = parser->table.block;
parser->state_index--;
}
--- a/src/type1/t1tokens.c
+++ b/src/type1/t1tokens.c
@@ -467,6 +467,11 @@
}
while (1);
+ /* we must free the field "tokzer.base" if we're in a disk-based */
+ /* PFB file.. */
+ if (stream->read)
+ FREE( tokzer->base );
+
tokzer->base = private;
tokzer->cursor = 0;
tokzer->limit = private_size;