[base, bdf] Don't expose `FT_Hashnode' in hash functions.
* src/base/fthash.c (hash_lookup, ft_hash_str_lookup, ft_hash_num_lookup): Return pointer to `size_t' instead of `FT_Hashnode'. * include/freetype/internal/fthash.h: Updated. * src/bdf/bdflib.c (bdf_get_property, _bdf_add_property, bdf_get_font_property): Updated.
This commit is contained in:
parent
ad306eaa5e
commit
76e79ec9a5
13
ChangeLog
13
ChangeLog
|
@ -1,3 +1,16 @@
|
|||
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,
|
||||
ft_hash_num_lookup): Return pointer to `size_t' instead of
|
||||
`FT_Hashnode'.
|
||||
|
||||
* include/freetype/internal/fthash.h: Updated.
|
||||
|
||||
* src/bdf/bdflib.c (bdf_get_property, _bdf_add_property,
|
||||
bdf_get_font_property): Updated.
|
||||
|
||||
2015-12-20 Werner Lemberg <wl@gnu.org>
|
||||
|
||||
[base, bdf] Add number hashing.
|
||||
|
|
|
@ -118,11 +118,11 @@ FT_BEGIN_HEADER
|
|||
FT_Hash hash,
|
||||
FT_Memory memory );
|
||||
|
||||
FT_Hashnode
|
||||
size_t*
|
||||
ft_hash_str_lookup( const char* key,
|
||||
FT_Hash hash );
|
||||
|
||||
FT_Hashnode
|
||||
size_t*
|
||||
ft_hash_num_lookup( FT_Int num,
|
||||
FT_Hash hash );
|
||||
|
||||
|
|
|
@ -291,18 +291,19 @@
|
|||
}
|
||||
|
||||
|
||||
static FT_Hashnode
|
||||
static size_t*
|
||||
hash_lookup( FT_Hashkey key,
|
||||
FT_Hash hash )
|
||||
{
|
||||
FT_Hashnode* np = hash_bucket( key, hash );
|
||||
|
||||
|
||||
return *np;
|
||||
return (*np) ? &(*np)->data
|
||||
: NULL;
|
||||
}
|
||||
|
||||
|
||||
FT_Hashnode
|
||||
size_t*
|
||||
ft_hash_str_lookup( const char* key,
|
||||
FT_Hash hash )
|
||||
{
|
||||
|
@ -315,7 +316,7 @@
|
|||
}
|
||||
|
||||
|
||||
FT_Hashnode
|
||||
size_t*
|
||||
ft_hash_num_lookup( FT_Int num,
|
||||
FT_Hash hash )
|
||||
{
|
||||
|
|
|
@ -848,25 +848,23 @@
|
|||
}
|
||||
|
||||
|
||||
FT_LOCAL_DEF( bdf_property_t * )
|
||||
FT_LOCAL_DEF( bdf_property_t* )
|
||||
bdf_get_property( char* name,
|
||||
bdf_font_t* font )
|
||||
{
|
||||
FT_Hashnode hn;
|
||||
size_t propid;
|
||||
size_t* propid;
|
||||
|
||||
|
||||
if ( name == 0 || *name == 0 )
|
||||
return 0;
|
||||
|
||||
if ( ( hn = ft_hash_str_lookup( name, &(font->proptbl) ) ) == 0 )
|
||||
if ( ( propid = ft_hash_str_lookup( name, &(font->proptbl) ) ) == NULL )
|
||||
return 0;
|
||||
|
||||
propid = hn->data;
|
||||
if ( propid >= _num_bdf_properties )
|
||||
return font->user_props + ( propid - _num_bdf_properties );
|
||||
if ( *propid >= _num_bdf_properties )
|
||||
return font->user_props + ( *propid - _num_bdf_properties );
|
||||
|
||||
return (bdf_property_t*)_bdf_properties + propid;
|
||||
return (bdf_property_t*)_bdf_properties + *propid;
|
||||
}
|
||||
|
||||
|
||||
|
@ -1074,8 +1072,7 @@
|
|||
char* value,
|
||||
unsigned long lineno )
|
||||
{
|
||||
size_t propid;
|
||||
FT_Hashnode hn;
|
||||
size_t* propid;
|
||||
bdf_property_t *prop, *fp;
|
||||
FT_Memory memory = font->memory;
|
||||
FT_Error error = FT_Err_Ok;
|
||||
|
@ -1084,11 +1081,12 @@
|
|||
|
||||
|
||||
/* First, check whether the property already exists in the font. */
|
||||
if ( ( hn = ft_hash_str_lookup( name, (FT_Hash)font->internal ) ) != 0 )
|
||||
if ( ( propid = ft_hash_str_lookup( name,
|
||||
(FT_Hash)font->internal ) ) != NULL )
|
||||
{
|
||||
/* The property already exists in the font, so simply replace */
|
||||
/* the value of the property with the current value. */
|
||||
fp = font->props + hn->data;
|
||||
fp = font->props + *propid;
|
||||
|
||||
switch ( fp->format )
|
||||
{
|
||||
|
@ -1120,13 +1118,13 @@
|
|||
|
||||
/* See whether this property type exists yet or not. */
|
||||
/* If not, create it. */
|
||||
hn = ft_hash_str_lookup( name, &(font->proptbl) );
|
||||
if ( hn == 0 )
|
||||
propid = ft_hash_str_lookup( name, &(font->proptbl) );
|
||||
if ( propid == NULL )
|
||||
{
|
||||
error = bdf_create_property( name, BDF_ATOM, font );
|
||||
if ( error )
|
||||
goto Exit;
|
||||
hn = ft_hash_str_lookup( name, &(font->proptbl) );
|
||||
propid = ft_hash_str_lookup( name, &(font->proptbl) );
|
||||
}
|
||||
|
||||
/* Allocate another property if this is overflow. */
|
||||
|
@ -1150,11 +1148,10 @@
|
|||
font->props_size++;
|
||||
}
|
||||
|
||||
propid = hn->data;
|
||||
if ( propid >= _num_bdf_properties )
|
||||
prop = font->user_props + ( propid - _num_bdf_properties );
|
||||
if ( *propid >= _num_bdf_properties )
|
||||
prop = font->user_props + ( *propid - _num_bdf_properties );
|
||||
else
|
||||
prop = (bdf_property_t*)_bdf_properties + propid;
|
||||
prop = (bdf_property_t*)_bdf_properties + *propid;
|
||||
|
||||
fp = font->props + font->props_used;
|
||||
|
||||
|
@ -2408,15 +2405,15 @@
|
|||
bdf_get_font_property( bdf_font_t* font,
|
||||
const char* name )
|
||||
{
|
||||
FT_Hashnode hn;
|
||||
size_t* propid;
|
||||
|
||||
|
||||
if ( font == 0 || font->props_size == 0 || name == 0 || *name == 0 )
|
||||
return 0;
|
||||
|
||||
hn = ft_hash_str_lookup( name, (FT_Hash)font->internal );
|
||||
propid = ft_hash_str_lookup( name, (FT_Hash)font->internal );
|
||||
|
||||
return hn ? ( font->props + hn->data ) : 0;
|
||||
return propid ? ( font->props + *propid ) : 0;
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue