Enlightenment CVS committal

Author  : onefang
Project : e17
Module  : libs/ecore

Dir     : e17/libs/ecore/src/lib/ecore_desktop


Modified Files:
        Ecore_Desktop.h ecore_desktop_icon.c ecore_desktop_paths.c 


Log Message:
Fix some of the memory leaks.  There are more leaks, but it's just me
being conservative and strduping when it's- probably not needed.  I'll
double check them all and sort them out later today.

===================================================================
RCS file: /cvs/e/e17/libs/ecore/src/lib/ecore_desktop/Ecore_Desktop.h,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -3 -r1.10 -r1.11
--- Ecore_Desktop.h     17 Aug 2006 19:11:00 -0000      1.10
+++ Ecore_Desktop.h     17 Aug 2006 20:24:36 -0000      1.11
@@ -107,8 +107,8 @@
                                                            const void *data);
    EAPI int            ecore_desktop_paths_shutdown(void);
 
-   Ecore_Hash         *ecore_desktop_paths_to_hash(char *paths);
-   Ecore_List         *ecore_desktop_paths_to_list(char *paths);
+   Ecore_Hash         *ecore_desktop_paths_to_hash(const char *paths);
+   Ecore_List         *ecore_desktop_paths_to_list(const char *paths);
 
    EAPI int            ecore_desktop_init(void);
    EAPI int            ecore_desktop_shutdown(void);
===================================================================
RCS file: /cvs/e/e17/libs/ecore/src/lib/ecore_desktop/ecore_desktop_icon.c,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -3 -r1.8 -r1.9
--- ecore_desktop_icon.c        17 Aug 2006 19:11:00 -0000      1.8
+++ ecore_desktop_icon.c        17 Aug 2006 20:24:36 -0000      1.9
@@ -26,6 +26,8 @@
  * Using the search algorithm specified by freedesktop.org,
  * search for an icon in the currently installed set of icon themes.
  *
+ * The returned string needs to be freed eventually.
+ *
  * @param   icon The name of the required icon.
  * @param   icon_size The size of the required icon.
  * @param   icon_theme The theme of the required icon.
===================================================================
RCS file: /cvs/e/e17/libs/ecore/src/lib/ecore_desktop/ecore_desktop_paths.c,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -3 -r1.7 -r1.8
--- ecore_desktop_paths.c       17 Aug 2006 17:09:23 -0000      1.7
+++ ecore_desktop_paths.c       17 Aug 2006 20:24:36 -0000      1.8
@@ -273,6 +273,7 @@
             sprintf(temp, "%s%s", this_path, file);
             if (stat(temp, &path_stat) == 0)
               {
+                 /* FIXME: This is defensive but leaks. */
                  path = strdup(temp);
                  if (func)
                     if (func(data, path))
@@ -314,12 +315,12 @@
    /* Merge the results, there are probably some duplicates. */
 
    if (type)
-      types = ecore_desktop_paths_to_list(strdup(type));
+      types = ecore_desktop_paths_to_list(type);
    if (gnome_extra)
-      gnome_extras = ecore_desktop_paths_to_list(strdup(gnome_extra));
+      gnome_extras = ecore_desktop_paths_to_list(gnome_extra);
 #ifdef KDE_SUPPORT
    if (kde)
-      kdes = ecore_desktop_paths_to_list(strdup(kde));
+      kdes = ecore_desktop_paths_to_list(kde);
 #endif
 
    paths = ecore_list_new();
@@ -333,7 +334,7 @@
          {
             Ecore_List         *befores;
 
-            befores = ecore_desktop_paths_to_list(strdup(before));
+            befores = ecore_desktop_paths_to_list(before);
             if (befores)
               {
                  char               *this_before;
@@ -356,7 +357,7 @@
             value = getenv(env_home);
             if ((value == NULL) || (value[0] == '\0'))
                value = env_home_default;
-            env_list = ecore_desktop_paths_to_list(strdup(value));
+            env_list = ecore_desktop_paths_to_list(value);
             if (env_list && types)
               {
                  char               *this_env, *this_type;
@@ -580,6 +581,7 @@
                         {
                            if (strcmp(basename(info_text), file) == 0)
                              {
+                                /* FIXME: This is defensive but leaks. */
                                 fpath = strdup(info_text);
                                 if (func)
                                    if (func(data, path))
@@ -718,9 +720,10 @@
  * @param   paths A list of paths.
  */
 Ecore_Hash         *
-ecore_desktop_paths_to_hash(char *paths)
+ecore_desktop_paths_to_hash(const char *paths)
 {
    Ecore_Hash         *result;
+   char               *path;
 
    result = ecore_hash_new(ecore_str_hash, ecore_str_compare);
    if (result)
@@ -733,27 +736,32 @@
             char               *start, *end, temp;
             int                 finished = 0;
 
-            end = paths;
-            while (!finished)
-              {
-                 start = end;
-                 do            /* FIXME: There is probably a better way to do 
this. */
-                   {
-                      while ((*end != ';') && (*end != ':') && (*end != ',')
-                             && (*end != '\0'))
-                         end++;
-                   }
-                 while ((end != paths) && (*(end - 1) == '\\') && (*end != 
'\0'));     /* Ignore any escaped ;:, */
-                 /* FIXME: We still need to unescape it now. */
-                 temp = *end;
-                 if (*end == '\0')
-                    finished = 1;
-                 else
-                    *end = '\0';
-                 ecore_hash_set(result, strdup(start), strdup(start));
-                 if ((*end) != temp)
-                    *end = temp;
-                 end++;
+            path = strdup(paths);
+            if (path)
+               {
+                  end = path;
+                  while (!finished)
+                    {
+                       start = end;
+                       do              /* FIXME: There is probably a better 
way to do this. */
+                         {
+                            while ((*end != ';') && (*end != ':') && (*end != 
',')
+                                   && (*end != '\0'))
+                               end++;
+                         }
+                       while ((end != path) && (*(end - 1) == '\\') && (*end 
!= '\0'));        /* Ignore any escaped ;:, */
+                       /* FIXME: We still need to unescape it now. */
+                       temp = *end;
+                       if (*end == '\0')
+                          finished = 1;
+                       else
+                          *end = '\0';
+                       ecore_hash_set(result, strdup(start), strdup(start));
+                       if ((*end) != temp)
+                          *end = temp;
+                       end++;
+                    }
+                  free(path);
               }
          }
      }
@@ -771,7 +779,7 @@
  * @param   paths A list of paths.
  */
 Ecore_List         *
-ecore_desktop_paths_to_list(char *paths)
+ecore_desktop_paths_to_list(const char *paths)
 {
    Ecore_List         *result;
    char               *path;
@@ -787,29 +795,32 @@
             int                 finished = 0;
 
             path = strdup(paths);
-            end = path;
-            while (!finished)
-              {
-                 start = end;
-                 do            /* FIXME: There is probably a better way to do 
this. */
-                   {
-                      while ((*end != ';') && (*end != ':') && (*end != ',')
-                             && (*end != '\0'))
-                         end++;
-                   }
-                 while ((end != path) && (*(end - 1) == '\\') && (*end != 
'\0'));      /* Ignore any escaped ;:, */
-                 /* FIXME: We still need to unescape it now. */
-                 temp = *end;
-                 if (*end == '\0')
-                    finished = 1;
-                 else
-                    *end = '\0';
-                 ecore_list_append(result, strdup(start));
-                 if ((*end) != temp)
-                    *end = temp;
-                 end++;
-              }
-            free(path);
+            if (path)
+               {
+                  end = path;
+                  while (!finished)
+                    {
+                       start = end;
+                       do              /* FIXME: There is probably a better 
way to do this. */
+                         {
+                            while ((*end != ';') && (*end != ':') && (*end != 
',')
+                                   && (*end != '\0'))
+                               end++;
+                         }
+                       while ((end != path) && (*(end - 1) == '\\') && (*end 
!= '\0'));        /* Ignore any escaped ;:, */
+                       /* FIXME: We still need to unescape it now. */
+                       temp = *end;
+                       if (*end == '\0')
+                          finished = 1;
+                       else
+                          *end = '\0';
+                       ecore_list_append(result, strdup(start));
+                       if ((*end) != temp)
+                          *end = temp;
+                       end++;
+                    }
+                  free(path);
+               }
          }
      }
    return result;



-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
enlightenment-cvs mailing list
enlightenment-cvs@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs

Reply via email to