[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[E-devel] e17 thumb patch for memory leaks



Heya

I now the current E thumbnailing system is going to rewritten.
Anyway, for the moment, here is a patch to fix some memory leaks.

laurent 'kiwi'
--- e_thumb.c	2006-07-07 19:00:06.613161672 +0200
+++ NEWe_thumb.c	2006-07-07 19:01:10.363470152 +0200
@@ -1,6 +1,6 @@
 /*
-* vim:ts=8:sw=3:sts=8:noexpandtab:cino=>5n-3f0^-2{2
-*/
+ * vim:ts=8:sw=3:sts=8:noexpandtab:cino=>5n-3f0^-2{2
+ */
 
 #include "e.h"
 
@@ -49,22 +49,31 @@
    else return 0;
    
    event_handlers = 
-     evas_list_append(event_handlers,
-		      ecore_event_handler_add(ECORE_EXE_EVENT_DEL,
-					      _e_thumb_cb_exe_exit,
-					      NULL));      
+      evas_list_append(event_handlers,
+                       ecore_event_handler_add(ECORE_EXE_EVENT_DEL,
+                                               _e_thumb_cb_exe_exit,
+                                               NULL));      
    return 1;
 }
 
 EAPI int
 e_thumb_shutdown(void)
 {
+   Evas_List *l;
+
    E_FREE(thumb_path);
    while (event_handlers)     
      {   
 	ecore_event_handler_del(event_handlers->data);
 	event_handlers = evas_list_remove_list(event_handlers, event_handlers);
      }
+
+   for (l=thumb_files; l; l=evas_list_next(l))
+     {
+        E_Thumb_Item *t;
+        t = evas_list_data(l);
+        free(t);
+     }
    evas_list_free(thumb_files);
 
    if (pid != -1)
@@ -120,10 +129,11 @@
      {
 	t = l->data;
 	if(!strcmp(path, t->path))
-	   {
-	      thumb_files = evas_list_remove_list(thumb_files, l);
-	      break;
-	   }
+          {
+             thumb_files = evas_list_remove_list(thumb_files, l);
+             free(t);
+             break;
+          }
      }
 }
 
@@ -208,6 +218,7 @@
 	free(thumb);
 	return 1;
      }
+   free(thumb);
    return 0;
 }
 
@@ -520,10 +531,10 @@
 {
    char                s[256], *sp;
    const char         *chmap =
-     "0123456789abcdef"
-     "ghijklmnopqrstuv"
-     "wxyz`~!@#$%^&*()"
-     "[];',.{}<>?-=_+|";
+      "0123456789abcdef"
+      "ghijklmnopqrstuv"
+      "wxyz`~!@#$%^&*()"
+      "[];',.{}<>?-=_+|";
    unsigned int        id[4], i;
    struct stat         st;
 
@@ -621,7 +632,7 @@
 	     evas_object_del(tmp);
 	     if(t->cb)
 	       t->cb(t->obj, t->data);
-	     free(t);
+             free(t);
 	  }
      }