From 1caf629eef20c5809a73f79ce6e2ffc885f125e6 Mon Sep 17 00:00:00 2001 From: Werner Lemberg Date: Sun, 20 Dec 2015 19:00:35 +0100 Subject: [PATCH] [base] Thinko: Remove free function pointer. We don't copy keys or values while hashing. * include/freetype/internal/fthash.h (FT_Hash_FreeFunc): Removed. (FT_HashRec): Remove `free' field. * src/base/fthash.c (hash_str_free): Removed. (ft_hash_init, ft_hash_free): Updated. --- ChangeLog | 12 ++++++++++++ include/freetype/internal/fthash.h | 5 ----- src/base/fthash.c | 17 ++--------------- 3 files changed, 14 insertions(+), 20 deletions(-) diff --git a/ChangeLog b/ChangeLog index fc484fafb..7e62e2e70 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,15 @@ +2015-12-20 Werner Lemberg + + [base] Thinko: Remove free function pointer. + + We don't copy keys or values while hashing. + + * include/freetype/internal/fthash.h (FT_Hash_FreeFunc): Removed. + (FT_HashRec): Remove `free' field. + + * src/base/fthash.c (hash_str_free): Removed. + (ft_hash_init, ft_hash_free): Updated. + 2015-12-20 Werner Lemberg [base, bdf] Don't expose `FT_Hashnode' in hash functions. diff --git a/include/freetype/internal/fthash.h b/include/freetype/internal/fthash.h index 7867e12e4..578d56bd8 100644 --- a/include/freetype/internal/fthash.h +++ b/include/freetype/internal/fthash.h @@ -75,10 +75,6 @@ FT_BEGIN_HEADER (*FT_Hash_CompareFunc)( FT_Hashkey* a, FT_Hashkey* b ); - typedef void - (*FT_Hash_FreeFunc)( FT_Hashnode hn, - FT_Memory memory ); - typedef struct FT_HashRec_ { @@ -88,7 +84,6 @@ FT_BEGIN_HEADER FT_Hash_LookupFunc lookup; FT_Hash_CompareFunc compare; - FT_Hash_FreeFunc free; FT_Hashnode* table; diff --git a/src/base/fthash.c b/src/base/fthash.c index 854741ab1..ff90f56ec 100644 --- a/src/base/fthash.c +++ b/src/base/fthash.c @@ -101,14 +101,6 @@ } - static void - hash_str_free( FT_Hashnode hn, - FT_Memory memory ) - { - FT_FREE( hn ); - } - - static FT_Hashnode* hash_bucket( FT_Hashkey key, FT_Hash hash ) @@ -186,13 +178,11 @@ { hash->lookup = hash_num_lookup; hash->compare = hash_num_compare; - hash->free = NULL; } else { hash->lookup = hash_str_lookup; hash->compare = hash_str_compare; - hash->free = hash_str_free; } FT_MEM_NEW_ARRAY( hash->table, sz ); @@ -212,11 +202,8 @@ FT_UInt i; - if ( hash->free ) - { - for ( i = 0; i < sz; i++, bp++ ) - (hash->free)( *bp, memory ); - } + for ( i = 0; i < sz; i++, bp++ ) + FT_FREE( *bp ); FT_FREE( hash->table ); }