Enlightenment CVS committal

Author  : englebass
Project : e17
Module  : libs/efreet

Dir     : e17/libs/efreet/src/lib


Modified Files:
        efreet_icon.c efreet_private.h 


Log Message:
Make IF_FREE better suited for free'ing global variables. The free cb
can now not interfere with it's owner during free.

===================================================================
RCS file: /cvs/e/e17/libs/efreet/src/lib/efreet_icon.c,v
retrieving revision 1.20
retrieving revision 1.21
diff -u -3 -r1.20 -r1.21
--- efreet_icon.c       7 Jun 2007 01:22:47 -0000       1.20
+++ efreet_icon.c       22 Jun 2007 09:45:09 -0000      1.21
@@ -803,7 +803,7 @@
         ecore_hash_set(theme->icon_cache, (void *)key, NO_MATCH_KEY);
     else 
     {
-        if (value != NO_MATCH_KEY) ((Efreet_Icon *)value)->ref_count ++;
+        if (value != NO_MATCH_KEY) ((Efreet_Icon *)value)->ref_count++;
 
         ecore_hash_set(theme->icon_cache, (void *)key, value);
     }
@@ -1021,9 +1021,9 @@
     IF_FREE(theme->example_icon);
 
     if (theme->paths.count == 1)
-        IF_FREE(theme->paths.path)
+        IF_FREE(theme->paths.path);
     else
-        IF_FREE_LIST(theme->paths.path)
+        IF_FREE_LIST(theme->paths.path);
 
     IF_FREE_LIST(theme->inherits);
     IF_FREE_LIST(theme->directories);
@@ -1063,7 +1063,7 @@
         ecore_list_append(theme->paths.path, old);
         ecore_list_append(theme->paths.path, strdup(path));
     }
-    theme->paths.count ++;
+    theme->paths.count++;
 }
 
 /**
===================================================================
RCS file: /cvs/e/e17/libs/efreet/src/lib/efreet_private.h,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -3 -r1.6 -r1.7
--- efreet_private.h    9 Apr 2007 12:16:09 -0000       1.6
+++ efreet_private.h    22 Jun 2007 09:45:09 -0000      1.7
@@ -42,37 +42,57 @@
  * @def FREE(x) 
  * Free x and set to NULL
  */
-#define FREE(x) { free(x); x = NULL; }
+#define FREE(x) do { free(x); x = NULL; } while (0)
 
 /**
  * @def IF_FREE(x) 
  * If x is set, free x and set to NULL 
  */
-#define IF_FREE(x) { if (x) FREE(x) }
+#define IF_FREE(x) do { if (x) FREE(x); } while (0)
 
 /**
  * @def IF_RELEASE(x)
  * If x is set, ecore_string_release x and set to NULL
  */
-#define IF_RELEASE(x) { if (x) ecore_string_release(x); x = NULL; }
+#define IF_RELEASE(x) do { \
+    if (x) { \
+        const char *__tmp; __tmp = (x); (x) = NULL; 
ecore_string_release(__tmp); \
+    } \
+    (x) = NULL; \
+} while (0)
 
 /**
  * @def IF_FREE_LIST(x) 
  * If x is a valid pointer destroy x and set to NULL
  */
-#define IF_FREE_LIST(x) { if (x) ecore_list_destroy(x); x = NULL; }
+#define IF_FREE_LIST(x) do { \
+    if (x) { \
+        Ecore_List *__tmp; __tmp = (x); (x) = NULL; ecore_list_destroy(__tmp); 
\
+    } \
+    (x) = NULL; \
+} while (0)
 
 /**
  * @def IF_FREE_DLIST(x) 
  * If x is a valid pointer destroy x and set to NULL
  */
-#define IF_FREE_DLIST(x) { if (x) ecore_dlist_destroy(x); x = NULL; }
+#define IF_FREE_DLIST(x) do { \
+    if (x) { \
+        Ecore_DList *__tmp; __tmp = (x); (x) = NULL; 
ecore_dlist_destroy(__tmp); \
+    } \
+    (x) = NULL; \
+} while (0)
 
 /**
  * @def IF_FREE_HASH(x) 
  * If x is a valid pointer destroy x and set to NULL
  */
-#define IF_FREE_HASH(x) { if (x) ecore_hash_destroy(x); x = NULL; }
+#define IF_FREE_HASH(x) do { \
+    if (x) { \
+        Ecore_Hash *__tmp; __tmp = (x); (x) = NULL; ecore_hash_destroy(__tmp); 
\
+    } \
+    (x) = NULL; \
+} while (0)
 
 /**
  * @def __UNUSED__



-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
enlightenment-cvs mailing list
enlightenment-cvs@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs

Reply via email to