[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.
This commit is contained in:
Werner Lemberg 2015-12-22 05:39:58 +01:00
parent 60d13bd432
commit 7ce6c43c3e
6 changed files with 58 additions and 18 deletions

View File

@ -1,3 +1,19 @@
2015-12-22 Werner Lemberg <wl@gnu.org>
[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 <wl@gnu.org>
[type1] Avoid shift of negative numbers (#46732).

View File

@ -93,13 +93,18 @@ FT_BEGIN_HEADER
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,

View File

@ -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 )
{
@ -210,6 +226,9 @@
}
/* `ft_hash_num_free' is the same as `ft_hash_str_free' */
static FT_Error
hash_insert( FT_Hashkey key,
size_t data,

View File

@ -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;

View File

@ -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 */

View File

@ -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 );