shithub: freetype+ttf2subf

Download patch

ref: 7ce6c43c3e7cc78d1f698740012afb38a3985c0f
parent: 60d13bd432f56421ed63c5bf14a73e006e9bf7ad
author: Werner Lemberg <[email protected]>
date: Tue Dec 22 00:39:58 EST 2015

[base] Make hash interface symmetric.

Use `num' and `str' infixes everywhere.

* src/base/fthash.c (ft_hash_init): Renamed to...
(hash_init): ... This.
(ft_hash_str_init, ft_hash_num_init): New functions.
(ft_hash_free): Renamed to...
(ft_hash_str_free): ... This.

* include/freetype/internal/fthash.h: Updated.

* src/bdf/bdflib.c, src/type1/t1load.c, src/type1/t1objs.c: Updated.

git/fs: mount .git/fs: mount/attach disallowed
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,19 @@
+2015-12-22  Werner Lemberg  <[email protected]>
+
+	[base] Make hash interface symmetric.
+
+	Use `num' and `str' infixes everywhere.
+
+	* src/base/fthash.c (ft_hash_init): Renamed to...
+	(hash_init): ... This.
+	(ft_hash_str_init, ft_hash_num_init): New functions.
+	(ft_hash_free): Renamed to...
+	(ft_hash_str_free): ... This.
+
+	* include/freetype/internal/fthash.h: Updated.
+
+	* src/bdf/bdflib.c, src/type1/t1load.c, src/type1/t1objs.c: Updated.
+
 2015-12-21  Werner Lemberg  <[email protected]>
 
 	[type1] Avoid shift of negative numbers (#46732).
--- a/include/freetype/internal/fthash.h
+++ b/include/freetype/internal/fthash.h
@@ -93,13 +93,18 @@
 
 
   FT_Error
-  ft_hash_init( FT_Hash    hash,
-                FT_Bool    is_num,
-                FT_Memory  memory );
+  ft_hash_str_init( FT_Hash    hash,
+                    FT_Memory  memory );
 
+  FT_Error
+  ft_hash_num_init( FT_Hash    hash,
+                    FT_Memory  memory );
+
   void
-  ft_hash_free( FT_Hash    hash,
-                FT_Memory  memory );
+  ft_hash_str_free( FT_Hash    hash,
+                    FT_Memory  memory );
+
+#define ft_hash_num_free  ft_hash_str_free
 
   FT_Error
   ft_hash_str_insert( const char*  key,
--- a/src/base/fthash.c
+++ b/src/base/fthash.c
@@ -161,10 +161,10 @@
   }
 
 
-  FT_Error
-  ft_hash_init( FT_Hash    hash,
-                FT_Bool    is_num,
-                FT_Memory  memory )
+  static FT_Error
+  hash_init( FT_Hash    hash,
+             FT_Bool    is_num,
+             FT_Memory  memory )
   {
     FT_UInt   sz = INITIAL_HT_SIZE;
     FT_Error  error;
@@ -191,9 +191,25 @@
   }
 
 
+  FT_Error
+  ft_hash_str_init( FT_Hash    hash,
+                    FT_Memory  memory )
+  {
+    return hash_init( hash, 0, memory );
+  }
+
+
+  FT_Error
+  ft_hash_num_init( FT_Hash    hash,
+                    FT_Memory  memory )
+  {
+    return hash_init( hash, 1, memory );
+  }
+
+
   void
-  ft_hash_free( FT_Hash    hash,
-                FT_Memory  memory )
+  ft_hash_str_free( FT_Hash    hash,
+                    FT_Memory  memory )
   {
     if ( hash )
     {
@@ -208,6 +224,9 @@
       FT_FREE( hash->table );
     }
   }
+
+
+  /* `ft_hash_num_free' is the same as `ft_hash_str_free' */
 
 
   static FT_Error
--- a/src/bdf/bdflib.c
+++ b/src/bdf/bdflib.c
@@ -1938,7 +1938,7 @@
         bdf_property_t*  prop;
 
 
-        error = ft_hash_init( &(font->proptbl), 0, memory );
+        error = ft_hash_str_init( &(font->proptbl), memory );
         if ( error )
           goto Exit;
         for ( i = 0, prop = (bdf_property_t*)_bdf_properties;
@@ -1953,7 +1953,7 @@
 
       if ( FT_ALLOC( p->font->internal, sizeof ( FT_HashRec ) ) )
         goto Exit;
-      error = ft_hash_init( (FT_Hash)p->font->internal, 0, memory );
+      error = ft_hash_str_init( (FT_Hash)p->font->internal, memory );
       if ( error )
         goto Exit;
       p->font->spacing      = p->opts->font_spacing;
@@ -2339,7 +2339,7 @@
     /* Free up the internal hash table of property names. */
     if ( font->internal )
     {
-      ft_hash_free( (FT_Hash)font->internal, memory );
+      ft_hash_str_free( (FT_Hash)font->internal, memory );
       FT_FREE( font->internal );
     }
 
@@ -2384,7 +2384,7 @@
     FT_FREE( font->overflow.glyphs );
 
     /* bdf_cleanup */
-    ft_hash_free( &(font->proptbl), memory );
+    ft_hash_str_free( &(font->proptbl), memory );
 
     /* Free up the user defined properties. */
     for ( prop = font->user_props, i = 0;
--- a/src/type1/t1load.c
+++ b/src/type1/t1load.c
@@ -1462,7 +1462,7 @@
         if ( FT_NEW( hash ) )
           goto Fail;
 
-        error = ft_hash_init( hash, 1, memory );
+        error = ft_hash_num_init( hash, memory );
         if ( error )
           goto Fail;
       }
@@ -2163,7 +2163,7 @@
     T1_Release_Table( &loader->subrs );
 
     /* finalize hash */
-    ft_hash_free( loader->subrs_hash, memory );
+    ft_hash_num_free( loader->subrs_hash, memory );
     FT_FREE( loader->subrs_hash );
 
     /* finalize parser */
--- a/src/type1/t1objs.c
+++ b/src/type1/t1objs.c
@@ -247,7 +247,7 @@
     FT_FREE( type1->subrs );
     FT_FREE( type1->subrs_len );
 
-    ft_hash_free( type1->subrs_hash, memory );
+    ft_hash_num_free( type1->subrs_hash, memory );
     FT_FREE( type1->subrs_hash );
 
     FT_FREE( type1->subrs_block );