Add free callback to eet hashes

Fixes memleak

SVN revision: 56854
devs/devilhorns/wayland_egl
Sebastian Dransfeld 12 years ago
parent 2728c70bc3
commit 8c9083f65d
  1. 1
      legacy/efreet/ChangeLog
  2. 29
      legacy/efreet/src/lib/efreet_cache.c

@ -60,3 +60,4 @@
* Move theme hash from efreet_icon.c to efreet_cache.c
* Don't free data returned by efreet_util_cache_names
* Add free callback to eet hashes

@ -90,6 +90,9 @@ static void icon_cache_update_cache_job(void *data);
static void desktop_cache_update_free(void *data, void *ev);
static void icon_cache_update_free(void *data, void *ev);
static void *hash_array_string_add(void *hash, const char *key, void *data);
static void *hash_string_add(void *hash, const char *key, void *data);
EAPI int EFREET_EVENT_ICON_CACHE_UPDATE = 0;
EAPI int EFREET_EVENT_DESKTOP_CACHE_UPDATE = 0;
@ -259,7 +262,7 @@ efreet_hash_array_string_edd(void)
if (hash_array_string_edd) return hash_array_string_edd;
EET_EINA_FILE_DATA_DESCRIPTOR_CLASS_SET(&eddc, Efreet_Cache_Hash);
/* TODO: set own hash func */
eddc.func.hash_add = hash_array_string_add;
hash_array_string_edd = eet_data_descriptor_file_new(&eddc);
if (!hash_array_string_edd) return NULL;
@ -280,7 +283,7 @@ efreet_hash_string_edd(void)
if (hash_string_edd) return hash_string_edd;
EET_EINA_FILE_DATA_DESCRIPTOR_CLASS_SET(&eddc, Efreet_Cache_Hash);
/* TODO: set own hash func */
eddc.func.hash_add = hash_string_add;
hash_string_edd = eet_data_descriptor_file_new(&eddc);
if (!hash_string_edd) return NULL;
@ -1087,3 +1090,25 @@ icon_cache_update_free(void *data, void *ev)
}
free(ev);
}
static void *
hash_array_string_add(void *hash, const char *key, void *data)
{
if (!hash)
hash = eina_hash_string_superfast_new(EINA_FREE_CB(efreet_cache_array_string_free));
if (!hash)
return NULL;
eina_hash_add(hash, key, data);
return hash;
}
static void *
hash_string_add(void *hash, const char *key, void *data)
{
if (!hash)
hash = eina_hash_string_superfast_new(free);
if (!hash)
return NULL;
eina_hash_add(hash, key, data);
return hash;
}

Loading…
Cancel
Save