1
0
mirror of https://github.com/rkd77/elinks.git synced 2024-09-28 03:06:20 -04:00

Do not export init_hash(),strhash() and hash_size() anymore, use a

wrapper named init_hash8() instead.
This commit is contained in:
Laurent MONIN 2006-05-31 19:17:01 +02:00 committed by Laurent MONIN
parent 4c5d4bcf34
commit 54099f5286
10 changed files with 22 additions and 15 deletions

View File

@ -41,7 +41,7 @@ get_bfu_color(struct terminal *term, unsigned char *stylename)
if (!bfu_colors) {
/* Initialize the style hash. */
bfu_colors = init_hash(8, &strhash);
bfu_colors = init_hash8();
if (!bfu_colors) return NULL;
last_color_mode = color_mode;

View File

@ -339,7 +339,7 @@ add_bookmark_item_to_bookmarks(struct bookmark *bm, struct bookmark *root, int p
/* Hash creation if needed. */
if (!bookmark_cache)
bookmark_cache = init_hash(8, &strhash);
bookmark_cache = init_hash8();
/* Create a new entry. */
if (check_bookmark_cache(bm->url))

View File

@ -1750,7 +1750,7 @@ format_html_part(struct html_context *html_context,
/* Hash creation if needed. */
if (!table_cache) {
table_cache = init_hash(8, &strhash);
table_cache = init_hash8();
} else if (!document) {
/* Search for cached entry. */
struct table_cache_entry_key key;

View File

@ -248,7 +248,7 @@ add_item_to_global_history(struct global_history_item *history_item,
/* Hash creation if needed. */
if (!globhist_cache)
globhist_cache = init_hash(8, &strhash);
globhist_cache = init_hash8();
if (globhist_cache && globhist_cache_entries < max_globhist_items) {
int urllen = strlen(history_item->url);

View File

@ -308,7 +308,7 @@ unregister_event_hooks(struct event_hook_info *hooks)
void
init_event(void)
{
event_hash = init_hash(8, strhash);
event_hash = init_hash8();
}
void

View File

@ -396,7 +396,7 @@ init_mailcap_map(void)
unsigned char *path;
unsigned int priority = 0;
mailcap_map = init_hash(8, &strhash);
mailcap_map = init_hash8();
if (!mailcap_map) return NULL;
/* Try to setup mailcap_path */

View File

@ -171,7 +171,7 @@ init_mimetypes_map(void)
{
unsigned char *path;
mimetypes_map = init_hash(8, &strhash);
mimetypes_map = init_hash8();
if (!mimetypes_map)
return NULL;

View File

@ -1518,7 +1518,7 @@ get_uri(unsigned char *string, enum uri_component components)
}
if (!is_object_used(&uri_cache)) {
uri_cache.map = init_hash(hash_size(3), strhash);
uri_cache.map = init_hash8();
if (!uri_cache.map) return NULL;
object_nolock(&uri_cache, "uri_cache");
}

View File

@ -22,8 +22,11 @@
* array (same hash value). */
#define hash_mask(n) (hash_size(n) - 1)
#define hash_size(n) (1 << (n))
struct hash *
static hash_value_T strhash(unsigned char *k, unsigned int length, hash_value_T initval);
static inline struct hash *
init_hash(unsigned int width, hash_func_T func)
{
struct hash *hash;
@ -47,6 +50,12 @@ init_hash(unsigned int width, hash_func_T func)
return hash;
}
struct hash *
init_hash8(void)
{
return init_hash(8, &strhash);
}
void
free_hash(struct hash *hash)
{
@ -130,7 +139,7 @@ del_hash_item(struct hash *hash, struct hash_item *item)
#ifdef X31_HASH
/* Fast string hashing. */
hash_value_T
static hash_value_T
strhash(unsigned char *k, /* the key */
unsigned int length, /* the length of the key */
hash_value_T initval /* the previous hash, or an arbitrary value */)
@ -251,7 +260,7 @@ strhash(unsigned char *k, /* the key */
+ ((hash_value_T) (k[(a)+2])<<16) \
+ ((hash_value_T) (k[(a)+3])<<24))
hash_value_T
static hash_value_T
strhash(unsigned char *k, /* the key */
unsigned int length, /* the length of the key */
hash_value_T initval /* the previous hash, or an arbitrary value */)

View File

@ -23,18 +23,16 @@ struct hash {
struct list_head hash[1]; /* Must be at end ! */
};
#define hash_size(n) (1 << (n))
struct hash *init_hash8(void);
struct hash *init_hash(unsigned int width, hash_func_T func);
void free_hash(struct hash *hash);
struct hash_item *add_hash_item(struct hash *hash, unsigned char *key, unsigned int keylen, void *value);
struct hash_item *get_hash_item(struct hash *hash, unsigned char *key, unsigned int keylen);
void del_hash_item(struct hash *hash, struct hash_item *item);
hash_value_T strhash(unsigned char *k, unsigned int length, hash_value_T initval);
#define foreach_hash_item(item, hash_table, iterator) \
for (iterator = 0; iterator < hash_size((hash_table).width); iterator++) \
for (iterator = 0; iterator < (1 << (hash_table).width); iterator++) \
foreach (item, (hash_table).hash[iterator])
#endif