[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.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189
diff --git a/ChangeLog b/ChangeLog
index 251da08..fc484fa 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,18 @@
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.
* src/base/fthash.c (hash_num_lookup, hash_num_compare): New
diff --git a/include/freetype/internal/fthash.h b/include/freetype/internal/fthash.h
index 84563cb..7867e12 100644
--- a/include/freetype/internal/fthash.h
+++ b/include/freetype/internal/fthash.h
@@ -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 );
diff --git a/src/base/fthash.c b/src/base/fthash.c
index 942e650..854741a 100644
--- a/src/base/fthash.c
+++ b/src/base/fthash.c
@@ -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 )
{
diff --git a/src/bdf/bdflib.c b/src/bdf/bdflib.c
index 6944467..cef52c4 100644
--- a/src/bdf/bdflib.c
+++ b/src/bdf/bdflib.c
@@ -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;
}