2121#include <stdbool.h>
2222#include <errno.h>
2323
24+ #include <hash.h>
2425#include <hashtable.h>
2526#include <list.h>
2627#include <xalloc.h>
@@ -210,19 +211,6 @@ struct symbol {
210211
211212static HASHTABLE_DEFINE (symbol_hashtable , 1U << 10 ) ;
212213
213- /* This is based on the hash algorithm from gdbm, via tdb */
214- static inline unsigned int tdb_hash (const char * name )
215- {
216- unsigned value ; /* Used to compute the hash value. */
217- unsigned i ; /* Used to cycle through random values. */
218-
219- /* Set the initial value from the key size. */
220- for (value = 0x238F13AF * strlen (name ), i = 0 ; name [i ]; i ++ )
221- value = (value + (((unsigned char * )name )[i ] << (i * 5 % 24 )));
222-
223- return (1103515243 * value + 12345 );
224- }
225-
226214/**
227215 * Allocate a new symbols for use in the hash of exported symbols or
228216 * the list of unresolved symbols per module
@@ -240,7 +228,7 @@ static struct symbol *alloc_symbol(const char *name)
240228/* For the hash of exported symbols */
241229static void hash_add_symbol (struct symbol * sym )
242230{
243- hash_add (symbol_hashtable , & sym -> hnode , tdb_hash (sym -> name ));
231+ hash_add (symbol_hashtable , & sym -> hnode , hash_str (sym -> name ));
244232}
245233
246234static void sym_add_unresolved (const char * name , struct module * mod , bool weak )
@@ -261,7 +249,7 @@ static struct symbol *sym_find_with_module(const char *name, struct module *mod)
261249 if (name [0 ] == '.' )
262250 name ++ ;
263251
264- hash_for_each_possible (symbol_hashtable , s , hnode , tdb_hash (name )) {
252+ hash_for_each_possible (symbol_hashtable , s , hnode , hash_str (name )) {
265253 if (strcmp (s -> name , name ) == 0 && (!mod || s -> module == mod ))
266254 return s ;
267255 }
0 commit comments