0
0
mirror of https://github.com/rkd77/elinks.git synced 2025-06-30 22:19:29 -04:00

Pass a pointer to a hash pointer to free_hash() to ensure hash pointer

is NULL on return.
This commit is contained in:
Laurent MONIN 2006-05-31 19:33:36 +02:00 committed by Laurent MONIN
parent 54099f5286
commit 1d3656a317
10 changed files with 17 additions and 26 deletions

View File

@ -108,6 +108,5 @@ done_bfu_colors(void)
mem_free_if(item->value); mem_free_if(item->value);
} }
free_hash(bfu_colors); free_hash(&bfu_colors);
bfu_colors = NULL;
}; };

View File

@ -162,10 +162,7 @@ free_bookmarks(struct list_head *bookmarks_list,
free_list(*box_items); free_list(*box_items);
free_list(*bookmarks_list); free_list(*bookmarks_list);
if (bookmark_cache) { if (bookmark_cache) free_hash(&bookmark_cache);
free_hash(bookmark_cache);
bookmark_cache = NULL;
}
} }
/* Does final cleanup and saving of bookmarks */ /* Does final cleanup and saving of bookmarks */

View File

@ -1727,11 +1727,9 @@ free_table_cache(void)
mem_free_if(item->value); mem_free_if(item->value);
} }
free_hash(table_cache); free_hash(&table_cache);
table_cache_entries = 0;
} }
table_cache = NULL;
table_cache_entries = 0;
} }
struct part * struct part *

View File

@ -406,8 +406,7 @@ static void
free_global_history(void) free_global_history(void)
{ {
if (globhist_cache) { if (globhist_cache) {
free_hash(globhist_cache); free_hash(&globhist_cache);
globhist_cache = NULL;
globhist_cache_entries = 0; globhist_cache_entries = 0;
} }

View File

@ -316,13 +316,13 @@ done_event(void)
{ {
int i; int i;
if (event_hash) free_hash(event_hash);
for (i = 0; i < eventssize; i++) { for (i = 0; i < eventssize; i++) {
mem_free_if(events[i].handlers); mem_free_if(events[i].handlers);
mem_free(events[i].name); mem_free(events[i].name);
} }
mem_free_set(&events, NULL); mem_free_set(&events, NULL);
if (event_hash) free_hash(&event_hash);
eventssize = 0; eventssize = 0;
} }

View File

@ -438,8 +438,7 @@ done_mailcap(struct module *module)
mem_free(mitem); mem_free(mitem);
} }
free_hash(mailcap_map); free_hash(&mailcap_map);
mailcap_map = NULL;
mailcap_map_size = 0; mailcap_map_size = 0;
} }

View File

@ -207,8 +207,7 @@ done_mimetypes(struct module *module)
} }
} }
free_hash(mimetypes_map); free_hash(&mimetypes_map);
mimetypes_map = NULL;
mimetypes_map_size = 0; mimetypes_map_size = 0;
} }

View File

@ -1526,7 +1526,7 @@ get_uri(unsigned char *string, enum uri_component components)
entry = get_uri_cache_entry(string, strlen(string)); entry = get_uri_cache_entry(string, strlen(string));
if (!entry) { if (!entry) {
if (!is_object_used(&uri_cache)) if (!is_object_used(&uri_cache))
free_hash(uri_cache.map); free_hash(&uri_cache.map);
return NULL; return NULL;
} }
@ -1560,5 +1560,5 @@ done_uri(struct uri *uri)
/* Last URI frees the cache */ /* Last URI frees the cache */
object_unlock(&uri_cache); object_unlock(&uri_cache);
if (!is_object_used(&uri_cache)) if (!is_object_used(&uri_cache))
free_hash(uri_cache.map); free_hash(&uri_cache.map);
} }

View File

@ -57,17 +57,17 @@ init_hash8(void)
} }
void void
free_hash(struct hash *hash) free_hash(struct hash **hashp)
{ {
unsigned int i = 0; unsigned int i = 0;
assert(hash); assert(hashp && *hashp);
if_assert_failed return; if_assert_failed return;
for (; i < hash_size(hash->width); i++) for (; i < hash_size((*hashp)->width); i++)
free_list(hash->hash[i]); free_list((*hashp)->hash[i]);
mem_free(hash); mem_free_set(hashp, NULL);
} }

View File

@ -25,7 +25,7 @@ struct hash {
struct hash *init_hash8(void); struct hash *init_hash8(void);
void free_hash(struct hash *hash); void free_hash(struct hash **hashp);
struct hash_item *add_hash_item(struct hash *hash, unsigned char *key, unsigned int keylen, void *value); 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); struct hash_item *get_hash_item(struct hash *hash, unsigned char *key, unsigned int keylen);