Commit 1caf629eef20c5809a73f79ce6e2ffc885f125e6

Werner Lemberg 2015-12-20T19:00:35

[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.

diff --git a/ChangeLog b/ChangeLog
index fc484fa..7e62e2e 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,17 @@
 2015-12-20  Werner Lemberg  <wl@gnu.org>
 
+	[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  <wl@gnu.org>
+
 	[base, bdf] Don't expose `FT_Hashnode' in hash functions.
 
 	* src/base/fthash.c (hash_lookup, ft_hash_str_lookup,
diff --git a/include/freetype/internal/fthash.h b/include/freetype/internal/fthash.h
index 7867e12..578d56b 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 854741a..ff90f56 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 );
     }