ReactOS 0.4.16-dev-106-g10b08aa
fthash.c File Reference
#include <ft2build.h>
Include dependency graph for fthash.c:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define INITIAL_HT_SIZE   241
 

Functions

static FT_ULong hash_str_lookup (FT_Hashkey *key)
 
static FT_ULong hash_num_lookup (FT_Hashkey *key)
 
static FT_Bool hash_str_compare (FT_Hashkey *a, FT_Hashkey *b)
 
static FT_Bool hash_num_compare (FT_Hashkey *a, FT_Hashkey *b)
 
static FT_Hashnodehash_bucket (FT_Hashkey key, FT_Hash hash)
 
static FT_Error hash_rehash (FT_Hash hash, FT_Memory memory)
 
static FT_Error hash_init (FT_Hash hash, FT_Bool is_num, FT_Memory memory)
 
FT_Error 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_str_free (FT_Hash hash, FT_Memory memory)
 
static FT_Error hash_insert (FT_Hashkey key, size_t data, FT_Hash hash, FT_Memory memory)
 
FT_Error ft_hash_str_insert (const char *key, size_t data, FT_Hash hash, FT_Memory memory)
 
FT_Error ft_hash_num_insert (FT_Int num, size_t data, FT_Hash hash, FT_Memory memory)
 
static size_thash_lookup (FT_Hashkey key, FT_Hash hash)
 
size_tft_hash_str_lookup (const char *key, FT_Hash hash)
 
size_tft_hash_num_lookup (FT_Int num, FT_Hash hash)
 

Macro Definition Documentation

◆ INITIAL_HT_SIZE

#define INITIAL_HT_SIZE   241

Definition at line 47 of file fthash.c.

Function Documentation

◆ ft_hash_num_init()

FT_Error ft_hash_num_init ( FT_Hash  hash,
FT_Memory  memory 
)

Definition at line 204 of file fthash.c.

206 {
207 return hash_init( hash, 1, memory );
208 }
static FT_Error hash_init(FT_Hash hash, FT_Bool is_num, FT_Memory memory)
Definition: fthash.c:166
static char memory[1024 *256]
Definition: process.c:116
Definition: _hash_fun.h:40

Referenced by parse_subrs().

◆ ft_hash_num_insert()

FT_Error ft_hash_num_insert ( FT_Int  num,
size_t  data,
FT_Hash  hash,
FT_Memory  memory 
)

Definition at line 287 of file fthash.c.

291 {
292 FT_Hashkey hk;
293
294
295 hk.num = num;
296
297 return hash_insert( hk, data, hash, memory );
298 }
static FT_Error hash_insert(FT_Hashkey key, size_t data, FT_Hash hash, FT_Memory memory)
Definition: fthash.c:234
FT_BEGIN_HEADER union FT_Hashkey_ FT_Hashkey
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
GLuint GLuint num
Definition: glext.h:9618

Referenced by parse_subrs().

◆ ft_hash_num_lookup()

size_t * ft_hash_num_lookup ( FT_Int  num,
FT_Hash  hash 
)

Definition at line 327 of file fthash.c.

329 {
330 FT_Hashkey hk;
331
332
333 hk.num = num;
334
335 return hash_lookup( hk, hash );
336 }
static size_t * hash_lookup(FT_Hashkey key, FT_Hash hash)
Definition: fthash.c:302

Referenced by cf2_interpT2CharString(), and t1_ps_get_font_value().

◆ ft_hash_str_free()

void ft_hash_str_free ( FT_Hash  hash,
FT_Memory  memory 
)

Definition at line 212 of file fthash.c.

214 {
215 if ( hash )
216 {
217 FT_UInt sz = hash->size;
218 FT_Hashnode* bp = hash->table;
219 FT_UInt i;
220
221
222 for ( i = 0; i < sz; i++, bp++ )
223 FT_FREE( *bp );
224
225 FT_FREE( hash->table );
226 }
227 }
#define FT_FREE(ptr)
Definition: ftmemory.h:329
unsigned int FT_UInt
Definition: fttypes.h:231
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248

Referenced by bdf_free_font().

◆ ft_hash_str_init()

FT_Error ft_hash_str_init ( FT_Hash  hash,
FT_Memory  memory 
)

Definition at line 196 of file fthash.c.

198 {
199 return hash_init( hash, 0, memory );
200 }

Referenced by _bdf_parse_start().

◆ ft_hash_str_insert()

FT_Error ft_hash_str_insert ( const char key,
size_t  data,
FT_Hash  hash,
FT_Memory  memory 
)

Definition at line 272 of file fthash.c.

276 {
277 FT_Hashkey hk;
278
279
280 hk.str = key;
281
282 return hash_insert( hk, data, hash, memory );
283 }
Definition: copy.c:22

Referenced by _bdf_add_property(), _bdf_parse_start(), and bdf_create_property().

◆ ft_hash_str_lookup()

size_t * ft_hash_str_lookup ( const char key,
FT_Hash  hash 
)

Definition at line 314 of file fthash.c.

316 {
317 FT_Hashkey hk;
318
319
320 hk.str = key;
321
322 return hash_lookup( hk, hash );
323 }

Referenced by _bdf_add_property(), bdf_create_property(), bdf_get_font_property(), and bdf_get_property().

◆ hash_bucket()

static FT_Hashnode * hash_bucket ( FT_Hashkey  key,
FT_Hash  hash 
)
static

Definition at line 106 of file fthash.c.

108 {
109 FT_ULong res = 0;
110 FT_Hashnode* bp = hash->table;
111 FT_Hashnode* ndp;
112
113
114 res = (hash->lookup)( &key );
115
116 ndp = bp + ( res % hash->size );
117 while ( *ndp )
118 {
119 if ( (hash->compare)( &(*ndp)->key, &key ) )
120 break;
121
122 ndp--;
123 if ( ndp < bp )
124 ndp = bp + ( hash->size - 1 );
125 }
126
127 return ndp;
128 }
unsigned long FT_ULong
Definition: fttypes.h:253
GLuint res
Definition: glext.h:9613

◆ hash_init()

static FT_Error hash_init ( FT_Hash  hash,
FT_Bool  is_num,
FT_Memory  memory 
)
static

Definition at line 166 of file fthash.c.

169 {
172
173
174 hash->size = sz;
175 hash->limit = sz / 3;
176 hash->used = 0;
177
178 if ( is_num )
179 {
180 hash->lookup = hash_num_lookup;
181 hash->compare = hash_num_compare;
182 }
183 else
184 {
185 hash->lookup = hash_str_lookup;
186 hash->compare = hash_str_compare;
187 }
188
189 FT_MEM_NEW_ARRAY( hash->table, sz );
190
191 return error;
192 }
static BOOL is_num(WCHAR val)
Definition: uri.c:267
#define INITIAL_HT_SIZE
Definition: fthash.c:47
static FT_ULong hash_num_lookup(FT_Hashkey *key)
Definition: fthash.c:66
static FT_Bool hash_str_compare(FT_Hashkey *a, FT_Hashkey *b)
Definition: fthash.c:83
static FT_Bool hash_num_compare(FT_Hashkey *a, FT_Hashkey *b)
Definition: fthash.c:95
static FT_ULong hash_str_lookup(FT_Hashkey *key)
Definition: fthash.c:51
#define FT_MEM_NEW_ARRAY(ptr, count)
Definition: ftmemory.h:271
int FT_Error
Definition: fttypes.h:300
#define error(str)
Definition: mkdosfs.c:1605

Referenced by BCryptCreateHash(), ft_hash_num_init(), and ft_hash_str_init().

◆ hash_insert()

static FT_Error hash_insert ( FT_Hashkey  key,
size_t  data,
FT_Hash  hash,
FT_Memory  memory 
)
static

Definition at line 234 of file fthash.c.

238 {
239 FT_Hashnode nn;
242
243
244 nn = *bp;
245 if ( !nn )
246 {
247 if ( FT_NEW( nn ) )
248 goto Exit;
249 *bp = nn;
250
251 nn->key = key;
252 nn->data = data;
253
254 if ( hash->used >= hash->limit )
255 {
257 if ( error )
258 goto Exit;
259 }
260
261 hash->used++;
262 }
263 else
264 nn->data = data;
265
266 Exit:
267 return error;
268 }
return FT_Err_Ok
Definition: ftbbox.c:511
static FT_Error hash_rehash(FT_Hash hash, FT_Memory memory)
Definition: fthash.c:132
#define FT_NEW(ptr)
Definition: ftmemory.h:331
static void Exit(void)
Definition: sock.c:1330
size_t data
Definition: fthash.h:64
FT_Hashkey key
Definition: fthash.h:63

Referenced by ft_hash_num_insert(), and ft_hash_str_insert().

◆ hash_lookup()

static size_t * hash_lookup ( FT_Hashkey  key,
FT_Hash  hash 
)
static

Definition at line 302 of file fthash.c.

304 {
306
307
308 return (*np) ? &(*np)->data
309 : NULL;
310 }
#define NULL
Definition: types.h:112

Referenced by ft_hash_num_lookup(), and ft_hash_str_lookup().

◆ hash_num_compare()

static FT_Bool hash_num_compare ( FT_Hashkey a,
FT_Hashkey b 
)
static

Definition at line 95 of file fthash.c.

97 {
98 if ( a->num == b->num )
99 return 1;
100
101 return 0;
102 }
GLboolean GLboolean GLboolean b
Definition: glext.h:6204
GLboolean GLboolean GLboolean GLboolean a
Definition: glext.h:6204

Referenced by hash_init().

◆ hash_num_lookup()

static FT_ULong hash_num_lookup ( FT_Hashkey key)
static

Definition at line 66 of file fthash.c.

67 {
68 FT_ULong num = (FT_ULong)key->num;
70
71
72 /* Mocklisp hash function. */
73 res = num & 0xFF;
74 res = ( res << 5 ) - res + ( ( num >> 8 ) & 0xFF );
75 res = ( res << 5 ) - res + ( ( num >> 16 ) & 0xFF );
76 res = ( res << 5 ) - res + ( ( num >> 24 ) & 0xFF );
77
78 return res;
79 }

Referenced by hash_init().

◆ hash_rehash()

static FT_Error hash_rehash ( FT_Hash  hash,
FT_Memory  memory 
)
static

Definition at line 132 of file fthash.c.

134 {
135 FT_Hashnode* obp = hash->table;
136 FT_Hashnode* bp;
137 FT_Hashnode* nbp;
138
139 FT_UInt i, sz = hash->size;
141
142
143 hash->size <<= 1;
144 hash->limit = hash->size / 3;
145
146 if ( FT_NEW_ARRAY( hash->table, hash->size ) )
147 goto Exit;
148
149 for ( i = 0, bp = obp; i < sz; i++, bp++ )
150 {
151 if ( *bp )
152 {
153 nbp = hash_bucket( (*bp)->key, hash );
154 *nbp = *bp;
155 }
156 }
157
158 FT_FREE( obp );
159
160 Exit:
161 return error;
162 }
#define FT_NEW_ARRAY(ptr, count)
Definition: ftmemory.h:333

Referenced by hash_insert().

◆ hash_str_compare()

static FT_Bool hash_str_compare ( FT_Hashkey a,
FT_Hashkey b 
)
static

Definition at line 83 of file fthash.c.

85 {
86 if ( a->str[0] == b->str[0] &&
87 ft_strcmp( a->str, b->str ) == 0 )
88 return 1;
89
90 return 0;
91 }
#define ft_strcmp
Definition: ftstdlib.h:86

Referenced by hash_init().

◆ hash_str_lookup()

static FT_ULong hash_str_lookup ( FT_Hashkey key)
static

Definition at line 51 of file fthash.c.

52 {
53 const char* kp = key->str;
54 FT_ULong res = 0;
55
56
57 /* Mocklisp hash function. */
58 while ( *kp )
59 res = ( res << 5 ) - res + (FT_ULong)*kp++;
60
61 return res;
62 }

Referenced by hash_init().