From 398d64c0cc360c2022ca8fb3df3b15055c2eb0ef Mon Sep 17 00:00:00 2001 From: David Turner Date: Fri, 21 Oct 2005 10:01:25 +0000 Subject: [PATCH] * src/base/ftdbgmem.c: another realloc memory counting bug fix * src/tools/Jamfile: adding missing file * src/lzw/Jamfile: fixing incorrect source file reference --- ChangeLog | 12 ++++++++++-- src/base/ftdbgmem.c | 48 ++++++++++++--------------------------------- src/lzw/Jamfile | 2 +- src/tools/Jamfile | 5 +++++ 4 files changed, 29 insertions(+), 38 deletions(-) create mode 100644 src/tools/Jamfile diff --git a/ChangeLog b/ChangeLog index 749396237..95a173251 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2005-10-21 David Turner + + * src/base/ftdbgmem.c: another realloc memory counting bug fix + + * src/tools/Jamfile: adding missing file + + * src/lzw/Jamfile: fixing incorrect source file reference + 2005-10-20 David Turner * src/base/ftdbgmem.c (ft_mem_table_set, ft_mem_table_remove, @@ -5,8 +13,8 @@ to better account for memory reallocations. * src/lzw/ftlzw2.c, src/lzw/ftzopen.h, src/lzw/ftzopen.c, - src/lzw/rules.mk: First version of LZW loader re-implementation. - Apparently, this saves about 260 KB of heap memory when loading + src/lzw/rules.mk: First version of LZW loader re-implementation. + Apparently, this saves about 330 KB of heap memory when loading timR24.pcf.Z. 2005-10-20 Chia-I Wu diff --git a/src/base/ftdbgmem.c b/src/base/ftdbgmem.c index fd24689db..72c50075f 100644 --- a/src/base/ftdbgmem.c +++ b/src/base/ftdbgmem.c @@ -554,12 +554,14 @@ if ( delta != 0 ) { /* we're growing or shrinking a realloc-ed block */ - source->cur_size += delta; + source->cur_size += delta; + table->alloc_current += delta; } else { /* we're allocating a new block */ - source->cur_size += size; + source->cur_size += size; + table->alloc_current += size; } source->all_size += size; @@ -575,16 +577,8 @@ pnode[0] = node; table->nodes++; - if ( delta != 0 ) - { - table->alloc_total += size; - table->alloc_current += delta; - } - else - { - table->alloc_total += size; - table->alloc_current += size; - } + table->alloc_total += size; + if ( table->alloc_current > table->alloc_max ) table->alloc_max = table->alloc_current; @@ -742,6 +736,10 @@ FT_Long line_no = table->line_no; + /* unlikely, but possible */ + if ( new_size == cur_size ) + return block; + /* the following is valid according to ANSI C */ #if 0 if ( block == NULL || cur_size == 0 ) @@ -774,19 +772,6 @@ "%ld instead of %ld in (%s:%ld)", block, cur_size, node->size, file_name, line_no ); -#if 0 - new_block = ft_mem_debug_alloc( memory, new_size ); - if ( new_block == NULL ) - return NULL; - - ft_memcpy( new_block, block, cur_size < new_size ? cur_size : new_size ); - - table->file_name = file_name; - table->line_no = line_no; - - ft_mem_debug_free( memory, (FT_Byte*)block ); - -#else /* return NULL if the maximum number of allocations was reached */ if ( table->bound_count && table->alloc_count >= table->alloc_count_max ) @@ -806,23 +791,16 @@ ft_mem_table_set( table, new_block, new_size, delta ); - table->file_name = NULL; - table->line_no = 0; - ft_memcpy( new_block, block, cur_size < new_size ? cur_size : new_size ); - table->file_name = file_name; - table->line_no = line_no; - ft_mem_table_remove( table, (FT_Byte*)block, delta ); + table->file_name = NULL; + table->line_no = 0; + if ( !table->keep_alive ) ft_mem_table_free( table, block ); - table->alloc_current += delta; - -#endif - return new_block; } diff --git a/src/lzw/Jamfile b/src/lzw/Jamfile index e9c3c4adc..f14b8c35b 100644 --- a/src/lzw/Jamfile +++ b/src/lzw/Jamfile @@ -11,7 +11,7 @@ SubDir FT2_TOP $(FT2_SRC_DIR) lzw ; -Library $(FT2_LIB) : ftlzw.c ; +Library $(FT2_LIB) : ftlzw2.c ; # end of src/lzw Jamfile diff --git a/src/tools/Jamfile b/src/tools/Jamfile new file mode 100644 index 000000000..475161e07 --- /dev/null +++ b/src/tools/Jamfile @@ -0,0 +1,5 @@ +# Jamfile for src/tools +# +SubDir FT2_TOP src tools ; + +Main apinames : apinames.c ;