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:
parent
54099f5286
commit
1d3656a317
@ -108,6 +108,5 @@ done_bfu_colors(void)
|
||||
mem_free_if(item->value);
|
||||
}
|
||||
|
||||
free_hash(bfu_colors);
|
||||
bfu_colors = NULL;
|
||||
free_hash(&bfu_colors);
|
||||
};
|
||||
|
@ -162,10 +162,7 @@ free_bookmarks(struct list_head *bookmarks_list,
|
||||
|
||||
free_list(*box_items);
|
||||
free_list(*bookmarks_list);
|
||||
if (bookmark_cache) {
|
||||
free_hash(bookmark_cache);
|
||||
bookmark_cache = NULL;
|
||||
}
|
||||
if (bookmark_cache) free_hash(&bookmark_cache);
|
||||
}
|
||||
|
||||
/* Does final cleanup and saving of bookmarks */
|
||||
|
@ -1727,11 +1727,9 @@ free_table_cache(void)
|
||||
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 *
|
||||
|
@ -406,8 +406,7 @@ static void
|
||||
free_global_history(void)
|
||||
{
|
||||
if (globhist_cache) {
|
||||
free_hash(globhist_cache);
|
||||
globhist_cache = NULL;
|
||||
free_hash(&globhist_cache);
|
||||
globhist_cache_entries = 0;
|
||||
}
|
||||
|
||||
|
@ -316,13 +316,13 @@ done_event(void)
|
||||
{
|
||||
int i;
|
||||
|
||||
if (event_hash) free_hash(event_hash);
|
||||
|
||||
for (i = 0; i < eventssize; i++) {
|
||||
mem_free_if(events[i].handlers);
|
||||
mem_free(events[i].name);
|
||||
}
|
||||
|
||||
mem_free_set(&events, NULL);
|
||||
|
||||
if (event_hash) free_hash(&event_hash);
|
||||
eventssize = 0;
|
||||
}
|
||||
|
@ -438,8 +438,7 @@ done_mailcap(struct module *module)
|
||||
mem_free(mitem);
|
||||
}
|
||||
|
||||
free_hash(mailcap_map);
|
||||
mailcap_map = NULL;
|
||||
free_hash(&mailcap_map);
|
||||
mailcap_map_size = 0;
|
||||
}
|
||||
|
||||
|
@ -207,8 +207,7 @@ done_mimetypes(struct module *module)
|
||||
}
|
||||
}
|
||||
|
||||
free_hash(mimetypes_map);
|
||||
mimetypes_map = NULL;
|
||||
free_hash(&mimetypes_map);
|
||||
mimetypes_map_size = 0;
|
||||
}
|
||||
|
||||
|
@ -1526,7 +1526,7 @@ get_uri(unsigned char *string, enum uri_component components)
|
||||
entry = get_uri_cache_entry(string, strlen(string));
|
||||
if (!entry) {
|
||||
if (!is_object_used(&uri_cache))
|
||||
free_hash(uri_cache.map);
|
||||
free_hash(&uri_cache.map);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@ -1560,5 +1560,5 @@ done_uri(struct uri *uri)
|
||||
/* Last URI frees the cache */
|
||||
object_unlock(&uri_cache);
|
||||
if (!is_object_used(&uri_cache))
|
||||
free_hash(uri_cache.map);
|
||||
free_hash(&uri_cache.map);
|
||||
}
|
||||
|
@ -57,17 +57,17 @@ init_hash8(void)
|
||||
}
|
||||
|
||||
void
|
||||
free_hash(struct hash *hash)
|
||||
free_hash(struct hash **hashp)
|
||||
{
|
||||
unsigned int i = 0;
|
||||
|
||||
assert(hash);
|
||||
assert(hashp && *hashp);
|
||||
if_assert_failed return;
|
||||
|
||||
for (; i < hash_size(hash->width); i++)
|
||||
free_list(hash->hash[i]);
|
||||
for (; i < hash_size((*hashp)->width); i++)
|
||||
free_list((*hashp)->hash[i]);
|
||||
|
||||
mem_free(hash);
|
||||
mem_free_set(hashp, NULL);
|
||||
}
|
||||
|
||||
|
||||
|
@ -25,7 +25,7 @@ struct hash {
|
||||
|
||||
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 *get_hash_item(struct hash *hash, unsigned char *key, unsigned int keylen);
|
||||
|
Loading…
x
Reference in New Issue
Block a user