1
0
mirror of https://github.com/weechat/weechat.git synced 2026-07-02 07:46:38 +02:00

Fix memory leak when removing item in hashtable

This commit is contained in:
Sebastien Helleu
2010-09-27 16:17:16 +02:00
parent bd7ae6d5a7
commit ccd6a81f0b
2 changed files with 9 additions and 0 deletions
+1
View File
@@ -8,6 +8,7 @@ Version 0.3.4 (under dev!)
--------------------------
* core: add new option weechat.look.input_share (task #9228)
* core: fix memory leak when removing item in hashtable
* core: use similar behaviour for keys bound to local or global history
(bug #30759)
* api: add priority for hooks (task #10550)
+8
View File
@@ -514,6 +514,8 @@ hashtable_remove_item (struct t_hashtable *hashtable,
if (hashtable->htable[hash] == item)
hashtable->htable[hash] = item->next_item;
free (item);
hashtable->items_count--;
}
@@ -527,6 +529,9 @@ hashtable_remove (struct t_hashtable *hashtable, const void *key)
struct t_hashtable_item *ptr_item;
unsigned int hash;
if (!hashtable || !key)
return;
ptr_item = hashtable_get_item (hashtable, key, &hash);
if (ptr_item)
hashtable_remove_item (hashtable, ptr_item, hash);
@@ -560,6 +565,9 @@ hashtable_remove_all (struct t_hashtable *hashtable)
void
hashtable_free (struct t_hashtable *hashtable)
{
if (!hashtable)
return;
hashtable_remove_all (hashtable);
free (hashtable->htable);
free (hashtable);