reduced some nasty memory leaks
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 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151
diff --git a/demos/Makefile b/demos/Makefile
index e50decd..a2b4d9c 100644
--- a/demos/Makefile
+++ b/demos/Makefile
@@ -161,7 +161,7 @@ else
# 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
diff --git a/demos/src/memtest.c b/demos/src/memtest.c
index 574c702..3717b9d 100644
--- a/demos/src/memtest.c
+++ b/demos/src/memtest.c
@@ -42,6 +42,12 @@ typedef struct MyBlock
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 @@ void forget_my_block( void* base )
}
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 @@ static
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 @@ void* my_realloc( FT_Memory memory,
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 @@ static void dump_mem( void )
{
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;
}
}
diff --git a/src/base/ftobjs.c b/src/base/ftobjs.c
index 308b84d..f8889ad 100644
--- 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
@@ -1371,6 +1372,8 @@
}
}
+ ft_done_stream( &stream );
+
/* no driver is able to handle this format */
error = FT_Err_Unknown_File_Format;
goto Fail;
diff --git a/src/truetype/ttgload.c b/src/truetype/ttgload.c
index c048ae7..15d7183 100644
--- 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;
diff --git a/src/type1/t1load.c b/src/type1/t1load.c
index 0b95085..2de739d 100644
--- 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--;
}
diff --git a/src/type1/t1tokens.c b/src/type1/t1tokens.c
index faa5ee6..e1e9adf 100644
--- 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;