ReactOS 0.4.16-dev-2332-g4cba65d
fthash.c File Reference
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 46 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 203 of file fthash.c.

205 {
206 return hash_init( hash, 1, memory );
207 }
static FT_Error hash_init(FT_Hash hash, FT_Bool is_num, FT_Memory memory)
Definition: fthash.c:165
static char memory[1024 *256]
Definition: process.c:122
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 286 of file fthash.c.

290 {
291 FT_Hashkey hk;
292
293
294 hk.num = num;
295
296 return hash_insert( hk, data, hash, memory );
297 }
static FT_Error hash_insert(FT_Hashkey key, size_t data, FT_Hash hash, FT_Memory memory)
Definition: fthash.c:233
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 326 of file fthash.c.

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

Referenced by cf2_interpT2CharString(), t1_decoder_parse_metrics(), and t1_ps_get_font_value().

◆ ft_hash_str_free()

void ft_hash_str_free ( FT_Hash  hash,
FT_Memory  memory 
)

Definition at line 211 of file fthash.c.

213 {
214 if ( hash )
215 {
216 FT_UInt sz = hash->size;
217 FT_Hashnode* bp = hash->table;
218 FT_UInt i;
219
220
221 for ( i = 0; i < sz; i++, bp++ )
222 FT_FREE( *bp );
223
224 FT_FREE( hash->table );
225 }
226 }
#define FT_FREE(ptr)
Definition: ftmemory.h:337
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 195 of file fthash.c.

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

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 271 of file fthash.c.

275 {
276 FT_Hashkey hk;
277
278
279 hk.str = key;
280
281 return hash_insert( hk, data, hash, memory );
282 }
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 313 of file fthash.c.

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

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 105 of file fthash.c.

107 {
108 FT_ULong res = 0;
109 FT_Hashnode* bp = hash->table;
110 FT_Hashnode* ndp;
111
112
113 res = (hash->lookup)( &key );
114
115 ndp = bp + ( res % hash->size );
116 while ( *ndp )
117 {
118 if ( (hash->compare)( &(*ndp)->key, &key ) )
119 break;
120
121 ndp--;
122 if ( ndp < bp )
123 ndp = bp + ( hash->size - 1 );
124 }
125
126 return ndp;
127 }
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 165 of file fthash.c.

168 {
171
172
173 hash->size = sz;
174 hash->limit = sz / 3;
175 hash->used = 0;
176
177 if ( is_num )
178 {
179 hash->lookup = hash_num_lookup;
180 hash->compare = hash_num_compare;
181 }
182 else
183 {
184 hash->lookup = hash_str_lookup;
185 hash->compare = hash_str_compare;
186 }
187
188 FT_MEM_NEW_ARRAY( hash->table, sz );
189
190 return error;
191 }
static BOOL is_num(WCHAR val)
Definition: uri.c:267
#define INITIAL_HT_SIZE
Definition: fthash.c:46
static FT_ULong hash_num_lookup(FT_Hashkey *key)
Definition: fthash.c:65
static FT_Bool hash_str_compare(FT_Hashkey *a, FT_Hashkey *b)
Definition: fthash.c:82
static FT_Bool hash_num_compare(FT_Hashkey *a, FT_Hashkey *b)
Definition: fthash.c:94
static FT_ULong hash_str_lookup(FT_Hashkey *key)
Definition: fthash.c:50
#define FT_MEM_NEW_ARRAY(ptr, count)
Definition: ftmemory.h:279
int FT_Error
Definition: fttypes.h:299
#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 233 of file fthash.c.

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

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 301 of file fthash.c.

303 {
305
306
307 return (*np) ? &(*np)->data
308 : NULL;
309 }
#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 94 of file fthash.c.

96 {
97 if ( a->num == b->num )
98 return 1;
99
100 return 0;
101 }
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 65 of file fthash.c.

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

Referenced by hash_init().

◆ hash_rehash()

static FT_Error hash_rehash ( FT_Hash  hash,
FT_Memory  memory 
)
static

Definition at line 131 of file fthash.c.

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

Referenced by hash_insert().

◆ hash_str_compare()

static FT_Bool hash_str_compare ( FT_Hashkey a,
FT_Hashkey b 
)
static

Definition at line 82 of file fthash.c.

84 {
85 if ( a->str[0] == b->str[0] &&
86 ft_strcmp( a->str, b->str ) == 0 )
87 return 1;
88
89 return 0;
90 }
#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 50 of file fthash.c.

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

Referenced by hash_init().