svn update: 55523 (latest:55523)
authorJaehwan Kim <jae.hwan.kim@samsung.com>
Wed, 22 Dec 2010 06:05:07 +0000 (15:05 +0900)
committerJaehwan Kim <jae.hwan.kim@samsung.com>
Wed, 22 Dec 2010 06:05:07 +0000 (15:05 +0900)
AUTHORS
src/bin/efreet_desktop_cache_create.c
src/bin/efreet_icon_cache_create.c
src/lib/efreet_cache.c
src/lib/efreet_desktop.c
src/lib/efreet_icon.c
src/lib/efreet_private.h
src/lib/efreet_utils.c
src/tests/main.c

diff --git a/AUTHORS b/AUTHORS
index e1dc35e..ad4bc4c 100644 (file)
--- a/AUTHORS
+++ b/AUTHORS
@@ -1,6 +1,6 @@
 dan 'dj2' sinclair
 Brian 'rephorm' Mattern
-Sebastian 'englebass' Dransfeld
+Sebastian Dransfeld <sd@tango.flipp.net>
 Nathan 'RbdPngn' Ingersoll
 Nicholas 'Mekius' Hughart
 Albin "Lutin" Tonnerre <albin.tonnerre@gmail.com>
index ce726b0..a2d6f69 100644 (file)
@@ -85,7 +85,7 @@ cache_add(const char *path, const char *file_id, int priority __UNUSED__, int *c
     /* TODO: We should check priority, and not just hope we search in right order */
     /* TODO: We need to find out if prioritized file id has changed because of
      * changed search order. */
-    if (desk->type == EFREET_DESKTOP_TYPE_APPLICATION &&
+    if (!desk->hidden && desk->type == EFREET_DESKTOP_TYPE_APPLICATION &&
         file_id && !eina_hash_find(file_ids, file_id))
     {
         int id;
index 0af073b..3fa2f52 100644 (file)
@@ -300,6 +300,73 @@ cache_scan(Efreet_Icon_Theme *theme, Eina_Hash *themes, Eina_Hash *icons, Eina_H
     return 1;
 }
 
+static Efreet_Icon_Theme_Directory *
+icon_theme_directory_new(Efreet_Ini *ini, const char *name)
+{
+    Efreet_Icon_Theme_Directory *dir;
+    int val;
+    const char *tmp;
+
+    if (!ini) return NULL;
+
+    dir = NEW(Efreet_Icon_Theme_Directory, 1);
+    if (!dir) return NULL;
+    dir->name = eina_stringshare_add(name);
+
+    efreet_ini_section_set(ini, name);
+
+    tmp = efreet_ini_string_get(ini, "Context");
+    if (tmp)
+    {
+        if (!strcasecmp(tmp, "Actions"))
+            dir->context = EFREET_ICON_THEME_CONTEXT_ACTIONS;
+
+        else if (!strcasecmp(tmp, "Devices"))
+            dir->context = EFREET_ICON_THEME_CONTEXT_DEVICES;
+
+        else if (!strcasecmp(tmp, "FileSystems"))
+            dir->context = EFREET_ICON_THEME_CONTEXT_FILESYSTEMS;
+
+        else if (!strcasecmp(tmp, "MimeTypes"))
+            dir->context = EFREET_ICON_THEME_CONTEXT_MIMETYPES;
+    }
+
+    /* Threshold is fallback  */
+    dir->type = EFREET_ICON_SIZE_TYPE_THRESHOLD;
+
+    tmp = efreet_ini_string_get(ini, "Type");
+    if (tmp)
+    {
+        if (!strcasecmp(tmp, "Fixed"))
+            dir->type = EFREET_ICON_SIZE_TYPE_FIXED;
+
+        else if (!strcasecmp(tmp, "Scalable"))
+            dir->type = EFREET_ICON_SIZE_TYPE_SCALABLE;
+    }
+
+    dir->size.normal = efreet_ini_int_get(ini, "Size");
+
+    if (dir->type == EFREET_ICON_SIZE_TYPE_THRESHOLD)
+    {
+        val = efreet_ini_int_get(ini, "Threshold");
+        if (val < 0) val = 2;
+        dir->size.max = dir->size.normal + val;
+        dir->size.min = dir->size.normal - val;
+    }
+    else if (dir->type == EFREET_ICON_SIZE_TYPE_SCALABLE)
+    {
+        val = efreet_ini_int_get(ini, "MinSize");
+        if (val < 0) dir->size.min = dir->size.normal;
+        else dir->size.min = val;
+
+        val = efreet_ini_int_get(ini, "MaxSize");
+        if (val < 0) dir->size.max = dir->size.normal;
+        else dir->size.max = val;
+    }
+
+    return dir;
+}
+
 static void
 icon_theme_index_read(Efreet_Icon_Theme *theme, const char *path)
 {
@@ -376,7 +443,7 @@ icon_theme_index_read(Efreet_Icon_Theme *theme, const char *path)
 
             if (p) *p = '\0';
 
-            dir = efreet_icon_theme_directory_new(ini, s);
+            dir = icon_theme_directory_new(ini, s);
             if (!dir) goto error;
             theme->directories = eina_list_append(theme->directories, dir);
 
@@ -413,7 +480,7 @@ cache_theme_scan(const char *dir)
 
         if (!theme)
         {
-            theme = efreet_icon_theme_new();
+            theme = NEW(Efreet_Icon_Theme, 1);
             theme->name.internal = eina_stringshare_add(name);
             eina_hash_direct_add(icon_themes,
                           (void *)theme->name.internal, theme);
index e5448d7..51a4021 100644 (file)
@@ -45,6 +45,7 @@ static Eet_Data_Descriptor *icon_element_edd = NULL;
 static Eet_Data_Descriptor *icon_edd = NULL;
 
 static Eet_File            *icon_cache = NULL;
+static Eet_File            *icon_theme_cache = NULL;
 
 static const char          *icon_theme_cache_file = NULL;
 
@@ -89,6 +90,9 @@ static void desktop_cache_update_cache_job(void *data);
 static void icon_cache_update_cache_job(void *data);
 #endif
 static void desktop_cache_update_free(void *data, void *ev);
+#ifdef ICON_CACHE
+static void icon_cache_update_free(void *data, void *ev);
+#endif
 
 EAPI int EFREET_EVENT_ICON_CACHE_UPDATE = 0;
 EAPI int EFREET_EVENT_DESKTOP_CACHE_UPDATE = 0;
@@ -146,10 +150,10 @@ efreet_cache_shutdown(void)
     theme_cache = _efreet_cache_free(theme_cache);
     fallback_cache = _efreet_cache_fallback_free(fallback_cache);
 
-    if (theme_name) eina_stringshare_del(theme_name);
-    theme_name = NULL;
+    IF_RELEASE(theme_name);
 
     icon_cache = efreet_cache_close(icon_cache);
+    icon_theme_cache = efreet_cache_close(icon_theme_cache);
 #endif
 
     desktop_cache = efreet_cache_close(desktop_cache);
@@ -410,7 +414,7 @@ efreet_icons_edd(Eina_Bool include_dirs)
     EET_DATA_DESCRIPTOR_ADD_VAR_ARRAY(icon_edd, Efreet_Cache_Icon,
                                       "icons", icons, icon_element_pointer_edd);
 
-    EET_EINA_FILE_DATA_DESCRIPTOR_CLASS_SET(&eddc, Efreet_Cache_Icon);
+    EET_EINA_FILE_DATA_DESCRIPTOR_CLASS_SET(&eddc, Efreet_Cache_Icons);
     icons_edd = eet_data_descriptor_file_new(&eddc);
     if (!icons_edd) return NULL;
 
@@ -496,7 +500,7 @@ efreet_icons_fallback_edd(Eina_Bool include_dirs)
     EET_DATA_DESCRIPTOR_ADD_VAR_ARRAY_STRING(icon_fallback_edd,
                                              Efreet_Cache_Fallback_Icon, "icons", icons);
 
-    EET_EINA_FILE_DATA_DESCRIPTOR_CLASS_SET(&eddc, Efreet_Cache_Icon);
+    EET_EINA_FILE_DATA_DESCRIPTOR_CLASS_SET(&eddc, Efreet_Cache_Icons);
     fallback_edd = eet_data_descriptor_file_new(&eddc);
     if (!fallback_edd) return NULL;
 
@@ -590,9 +594,8 @@ efreet_cache_icon_find(Efreet_Icon_Theme *theme, const char *icon)
     {
         /* FIXME: this is bad if people have pointer to this cache, things will go wrong */
         INFO("theme_name change from `%s` to `%s`", theme_name, theme->name.internal);
-        eina_stringshare_del(theme_name);
+        IF_RELEASE(theme_name);
         theme_cache = _efreet_cache_free(theme_cache);
-        theme_name = NULL;
     }
 
     if (!theme_name)
@@ -627,6 +630,49 @@ efreet_cache_icon_fallback_find(const char *icon)
 
     return eina_hash_find(fallback_cache->icons, icon);
 }
+
+Efreet_Icon_Theme *
+efreet_cache_icon_theme_find(const char *theme)
+{
+    if (!efreet_cache_check(&icon_theme_cache, efreet_icon_theme_cache_file(), EFREET_ICON_CACHE_MAJOR)) return NULL;
+    return eet_data_read(icon_theme_cache, efreet_icon_theme_edd(), theme);
+}
+
+void
+efreet_cache_icon_theme_free(Efreet_Icon_Theme *theme)
+{
+    void *data;
+
+    if (!theme) return;
+
+    eina_list_free(theme->paths);
+    eina_list_free(theme->inherits);
+    EINA_LIST_FREE(theme->directories, data)
+        free(data);
+
+    free(theme);
+}
+
+char **
+efreet_cache_icon_theme_name_list(int *num)
+{
+    char **keys;
+    int i;
+
+    if (!efreet_cache_check(&icon_theme_cache, efreet_icon_theme_cache_file(), EFREET_ICON_CACHE_MAJOR)) return NULL;
+    keys = eet_list(icon_theme_cache, "*", num);
+    for (i = 0; i < *num; i++)
+    {
+        if (!strcmp(keys[i], EFREET_CACHE_VERSION) && (i < (*num + 1)))
+        {
+            memmove(&keys[i], &keys[i + 1], (*num - i - 1) * sizeof(char *));
+            (*num)--;
+            break;
+        }
+    }
+    return keys;
+}
+
 #endif
 
 Efreet_Desktop *
@@ -699,6 +745,7 @@ efreet_cache_check(Eet_File **ef, const char *path, int major)
     Efreet_Cache_Version *version;
 
     if (*ef == NON_EXISTING) return EINA_FALSE;
+    if (*ef) return EINA_TRUE;
     if (!*ef)
         *ef = eet_open(path, EET_FILE_MODE_READ);
     if (!*ef)
@@ -789,14 +836,18 @@ cache_update_cb(void *data __UNUSED__, Ecore_File_Monitor *em __UNUSED__,
 #ifdef ICON_CACHE
     else if (!strcmp(file, "icon_data.update"))
     {
+        ev = NEW(Efreet_Event_Cache_Update, 1);
+        if (!ev) goto error;
+        d = NEW(Efreet_Old_Cache, 1);
+        if (!d) goto error;
+
         if (theme_cache)
         {
             INFO("Destorying theme cache due to cache change.");
             theme_cache = _efreet_cache_free(theme_cache);
         }
 
-        if (theme_name) eina_stringshare_del(theme_name);
-        theme_name = NULL;
+        IF_RELEASE(theme_name);
 
         if (fallback_cache)
         {
@@ -806,9 +857,13 @@ cache_update_cb(void *data __UNUSED__, Ecore_File_Monitor *em __UNUSED__,
 
         icon_cache = efreet_cache_close(icon_cache);
 
-        ev = NEW(Efreet_Event_Cache_Update, 1);
-        if (!ev) return;
-        ecore_event_add(EFREET_EVENT_ICON_CACHE_UPDATE, ev, NULL, NULL);
+        d->hash = efreet_icon_themes;
+        d->ef = icon_theme_cache;
+
+        efreet_icon_themes = eina_hash_string_superfast_new(EINA_FREE_CB(efreet_cache_icon_theme_free));
+        icon_theme_cache = NULL;
+
+        ecore_event_add(EFREET_EVENT_ICON_CACHE_UPDATE, ev, icon_cache_update_free, d);
     }
 #endif
     return;
@@ -942,3 +997,17 @@ desktop_cache_update_free(void *data, void *ev)
     free(ev);
 }
 
+#ifdef ICON_CACHE
+static void
+icon_cache_update_free(void *data, void *ev)
+{
+    Efreet_Old_Cache *d;
+
+    d = data;
+    if (d->hash)
+        eina_hash_free(d->hash);
+    efreet_cache_close(d->ef);
+    free(d);
+    free(ev);
+}
+#endif
index 6ae5d8e..83d8eca 100644 (file)
@@ -770,7 +770,7 @@ efreet_desktop_write_cache_dirs_file(void)
 
     if (!efreet_desktop_dirs) return 1;
 
-    snprintf(file, sizeof(file), "%s/.efreet/desktop_data.lock", efreet_home_dir_get());
+    snprintf(file, sizeof(file), "%s/desktop_data.lock", efreet_cache_home_get());
     fd = open(file, O_CREAT | O_RDWR, S_IRUSR | S_IWUSR);
     if (fd < 0) return 0;
     /* TODO: Retry update cache later */
index 769d905..9b4efa4 100644 (file)
@@ -43,11 +43,11 @@ void *alloca (size_t);
 static int _efreet_icon_log_dom = -1;
 
 /* TODO: Scan efreet_extra_icon_dirs for themes */
-/* TODO: icon theme cache */
+
+Eina_Hash *efreet_icon_themes = NULL;
 
 static const char *efreet_icon_deprecated_user_dir = NULL;
 static const char *efreet_icon_user_dir = NULL;
-static Eina_Hash *efreet_icon_themes = NULL;
 static Eina_List *efreet_icon_extensions = NULL;
 static Eina_List *efreet_extra_icon_dirs = NULL;
 #ifndef ICON_CACHE
@@ -65,10 +65,10 @@ struct Efreet_Icon_Cache
 };
 
 static char *efreet_icon_remove_extension(const char *icon);
-static Efreet_Icon_Theme *efreet_icon_find_theme_check(const char *theme_name);
-
 
 #ifndef ICON_CACHE
+static Efreet_Icon_Theme *efreet_icon_find_theme_check(const char *theme_name);
+
 static const char *efreet_icon_find_fallback(Efreet_Icon_Theme *theme,
                                              const char *icon,
                                              unsigned int size);
@@ -102,7 +102,6 @@ static void efreet_icon_populate(Efreet_Icon *icon, const char *file);
 
 #ifndef ICON_CACHE
 static Efreet_Icon_Theme *efreet_icon_theme_new(void);
-#endif
 static void efreet_icon_theme_free(Efreet_Icon_Theme *theme);
 static void efreet_icon_theme_dir_scan_all(const char *theme_name);
 static void efreet_icon_theme_dir_scan(const char *dir,
@@ -112,13 +111,10 @@ static void efreet_icon_theme_path_add(Efreet_Icon_Theme *theme,
 static void efreet_icon_theme_index_read(Efreet_Icon_Theme *theme,
                                          const char *path);
 
-#ifndef ICON_CACHE
 static Efreet_Icon_Theme_Directory *efreet_icon_theme_directory_new(Efreet_Ini *ini,
                                                                     const char *name);
-#endif
 static void efreet_icon_theme_directory_free(Efreet_Icon_Theme_Directory *dir);
 
-#ifndef ICON_CACHE
 static void efreet_icon_theme_cache_check(Efreet_Icon_Theme *theme);
 static int efreet_icon_theme_cache_check_dir(Efreet_Icon_Theme *theme,
                                              const char *dir);
@@ -166,16 +162,16 @@ efreet_icon_init(void)
     for (i = 0; default_exts[i]; i++)
         efreet_icon_extensions = eina_list_append(efreet_icon_extensions, eina_stringshare_add(default_exts[i]));
 
-    efreet_icon_themes = eina_hash_string_superfast_new(EINA_FREE_CB(efreet_icon_theme_free));
-
-    efreet_extra_icon_dirs = NULL;
 #ifndef ICON_CACHE
+    efreet_icon_themes = eina_hash_string_superfast_new(EINA_FREE_CB(efreet_icon_theme_free));
     efreet_icon_cache = eina_hash_string_superfast_new(EINA_FREE_CB(efreet_icon_cache_free));
-#endif
-
-#if ICON_CACHE
+#else
+    efreet_icon_themes = eina_hash_string_superfast_new(EINA_FREE_CB(efreet_cache_icon_theme_free));
     efreet_icon_changes_listen();
 #endif
+
+    efreet_extra_icon_dirs = NULL;
+
     return 1;
 }
 
@@ -279,12 +275,6 @@ efreet_icon_extra_list_get(void)
     return &efreet_extra_icon_dirs;
 }
 
-static Eina_Bool
-_hash_keys(Eina_Hash *hash __UNUSED__, const void *key, void *list)
-{
-    *(Eina_List**)list = eina_list_append(*(Eina_List**)list, key);
-    return EINA_TRUE;
-}
 /**
  * @return Returns a list of Efreet_Icon structs for all the non-hidden icon
  * themes
@@ -295,23 +285,17 @@ EAPI Eina_List *
 efreet_icon_theme_list_get(void)
 {
     Eina_List *list = NULL;
-    Eina_List *theme_list = NULL;
-    char *dir;
+#ifndef ICON_CACHE
     Eina_Iterator *it;
+    Efreet_Icon_Theme *theme;
 
     /* update the list to include all icon themes */
     efreet_icon_theme_dir_scan_all(NULL);
 
     /* create the list for the user */
-    it = eina_hash_iterator_key_new(efreet_icon_themes);
-    eina_iterator_foreach(it, EINA_EACH_CB(_hash_keys), &theme_list);
-    eina_iterator_free(it);
-
-    EINA_LIST_FREE(theme_list, dir)
+    it = eina_hash_iterator_data_new(efreet_icon_themes);
+    EINA_ITERATOR_FOREACH(it, theme)
     {
-        Efreet_Icon_Theme *theme;
-
-        theme = eina_hash_find(efreet_icon_themes, dir);
         if (theme->hidden || !theme->valid) continue;
 #ifndef STRICT_SPEC
         if (!theme->name.name) continue;
@@ -319,6 +303,24 @@ efreet_icon_theme_list_get(void)
 
         list = eina_list_append(list, theme);
     }
+    eina_iterator_free(it);
+#else
+    char **keys;
+    int num, i;
+
+    keys = efreet_cache_icon_theme_name_list(&num);
+    if (keys)
+    {
+        for (i = 0; i < num; i++)
+        {
+            Efreet_Icon_Theme *theme;
+
+            theme = efreet_icon_theme_find(keys[i]);
+            list = eina_list_append(list, theme);
+        }
+        free(keys);
+    }
+#endif
 
     return list;
 }
@@ -339,8 +341,13 @@ efreet_icon_theme_find(const char *theme_name)
     theme = eina_hash_find(efreet_icon_themes, theme_name);
     if (!theme)
     {
+#ifndef ICON_CACHE
         efreet_icon_theme_dir_scan_all(theme_name);
         theme = eina_hash_find(efreet_icon_themes, theme_name);
+#else
+        theme = efreet_cache_icon_theme_find(theme_name);
+        if (theme) eina_hash_direct_add(efreet_icon_themes, theme->name.internal, theme);
+#endif
     }
 
     return theme;
@@ -382,6 +389,7 @@ efreet_icon_remove_extension(const char *icon)
     return tmp;
 }
 
+#ifndef ICON_CACHE
 /**
  * @internal
  * @param theme_name: The icon theme to look for
@@ -405,6 +413,7 @@ efreet_icon_find_theme_check(const char *theme_name)
 
     return theme;
 }
+#endif
 
 /**
  * @param theme_name: The icon theme to look for
@@ -419,7 +428,11 @@ efreet_icon_path_find(const char *theme_name, const char *icon, unsigned int siz
     const char *value = NULL;
     Efreet_Icon_Theme *theme;
 
+#ifndef ICON_CACHE
     theme = efreet_icon_find_theme_check(theme_name);
+#else
+    theme = efreet_icon_theme_find(theme_name);
+#endif
 
     if (theme)
     {
@@ -489,7 +502,11 @@ efreet_icon_list_find(const char *theme_name, Eina_List *icons,
     char *data;
     Efreet_Icon_Theme *theme;
 
+#ifndef ICON_CACHE
     theme = efreet_icon_find_theme_check(theme_name);
+#else
+    theme = efreet_icon_theme_find(theme_name);
+#endif
 
     if (theme)
     {
@@ -1244,6 +1261,7 @@ error:
     efreet_ini_free(ini);
 }
 
+#ifndef ICON_CACHE
 /**
  * @internal
  * @return Returns a new Efreet_Icon_Theme on success or NULL on failure
@@ -1251,11 +1269,7 @@ error:
  *
  * Needs EAPI because of helper binaries
  */
-#ifndef ICON_CACHE
 static Efreet_Icon_Theme *
-#else
-EAPI Efreet_Icon_Theme *
-#endif
 efreet_icon_theme_new(void)
 {
     Efreet_Icon_Theme *theme;
@@ -1307,7 +1321,6 @@ efreet_icon_theme_path_add(Efreet_Icon_Theme *theme, const char *path)
         theme->paths = eina_list_append(theme->paths, eina_stringshare_add(path));
 }
 
-#ifndef ICON_CACHE
 /**
  * @internal
  * @return Returns no value
@@ -1383,7 +1396,6 @@ efreet_icon_theme_cache_check_dir(Efreet_Icon_Theme *theme, const char *dir)
 
     return 1;
 }
-#endif
 
 /**
  * @internal
@@ -1590,11 +1602,7 @@ error:
  *
  * Needs EAPI because of helper binaries
  */
-#ifndef ICON_CACHE
 static Efreet_Icon_Theme_Directory *
-#else
-EAPI Efreet_Icon_Theme_Directory *
-#endif
 efreet_icon_theme_directory_new(Efreet_Ini *ini, const char *name)
 {
     Efreet_Icon_Theme_Directory *dir;
@@ -1676,7 +1684,6 @@ efreet_icon_theme_directory_free(Efreet_Icon_Theme_Directory *dir)
     FREE(dir);
 }
 
-#ifndef ICON_CACHE
 static void
 efreet_icon_cache_free(Efreet_Icon_Cache *value)
 {
@@ -2085,6 +2092,7 @@ efreet_icon_changes_monitor_add(const char *path)
                                                  efreet_icon_changes_cb,
                                                  NULL));
         }
+        eina_iterator_free(it);
     }
 }
 
index b0533c3..7432761 100644 (file)
@@ -114,6 +114,9 @@ extern int _efreet_log_dom_global;
 #define WRN(...) EINA_LOG_DOM_WARN(EFREET_MODULE_LOG_DOM, __VA_ARGS__)
 
 extern Eina_Hash *efreet_desktop_cache;
+#ifdef ICON_CACHE
+extern Eina_Hash *efreet_icon_themes;
+#endif
 
 #define EFREET_DESKTOP_CACHE_MAJOR 0
 #define EFREET_DESKTOP_CACHE_MINOR 1
@@ -238,10 +241,9 @@ EAPI void efreet_cache_icon_free(Efreet_Cache_Icon *icon);
 EAPI void efreet_cache_icon_fallback_free(Efreet_Cache_Fallback_Icon *icon);
 Efreet_Cache_Icon *efreet_cache_icon_find(Efreet_Icon_Theme *theme, const char *icon);
 Efreet_Cache_Fallback_Icon *efreet_cache_icon_fallback_find(const char *icon);
-
-EAPI Efreet_Icon_Theme *efreet_icon_theme_new(void);
-EAPI Efreet_Icon_Theme_Directory *efreet_icon_theme_directory_new(Efreet_Ini *ini,
-                                                                    const char *name);
+Efreet_Icon_Theme *efreet_cache_icon_theme_find(const char *theme);
+void efreet_cache_icon_theme_free(Efreet_Icon_Theme *theme);
+char **efreet_cache_icon_theme_name_list(int *num);
 #endif
 
 EAPI void efreet_hash_free(Eina_Hash *hash, Eina_Free_Cb free_cb);
index bc9227b..0624448 100644 (file)
@@ -3,6 +3,7 @@
 #endif
 
 /* TODO: move eet file handling to eet_cache.c */
+/* TODO: add no_display check, as we might want only displayable items */
 
 #undef alloca
 #ifdef HAVE_ALLOCA_H
index f30fbc9..f0093b0 100644 (file)
@@ -84,12 +84,8 @@ environment_store(void)
     char *env;
     char **e;
 
-    while (environment)
-    {
-        env = eina_list_data_get(environment);
+    EINA_LIST_FREE(environment, env)
         free(env);
-        environment = eina_list_remove_list(environment, environment);
-    }
 
     for (e = environ; *e; e++)
         environment = eina_list_append(environment, strdup(*e));
@@ -102,7 +98,7 @@ environment_restore(void)
     char *e;
     if (!environment) return;
 
-    *environ = NULL;
+    clearenv();
     EINA_LIST_FOREACH(environment, l, e)
         putenv(e);
 }
@@ -113,6 +109,7 @@ main(int argc, char ** argv)
     int i, passed = 0, num_tests = 0;
     Eina_List *run = NULL;
     double total;
+    char *env;
 
     eina_init();
     ecore_init();
@@ -167,11 +164,9 @@ main(int argc, char ** argv)
     }
 
     printf("\n-----------------\n");
-    while (environment)
-    {
-        free(eina_list_data_get(environment));
-        environment = eina_list_remove_list(environment, environment);
-    }
+    clearenv();
+    EINA_LIST_FREE(environment, env)
+        free(env);
     printf("Passed %d of %d tests.\n", passed, num_tests);
 
     while (run)