Enlightenment CVS committal

Author  : lordchaos
Project : e17
Module  : apps/evfs

Dir     : e17/apps/evfs/src/common


Modified Files:
        evfs_cleanup.c evfs_event_helper.c 


Log Message:
Cleanup unfreed memory

===================================================================
RCS file: /cvsroot/enlightenment/e17/apps/evfs/src/common/evfs_cleanup.c,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -3 -r1.3 -r1.4
--- evfs_cleanup.c      8 Oct 2005 01:53:25 -0000       1.3
+++ evfs_cleanup.c      22 Oct 2005 04:51:42 -0000      1.4
@@ -1,6 +1,6 @@
 #include <evfs.h>
 
-void evfs_cleanup_command(evfs_command* command) {
+void evfs_cleanup_command(evfs_command* command, int free_command) {
        printf("Cleaned command..\n");
        
        switch (command->type) {
@@ -9,7 +9,7 @@
                        break;
        }
 
-       free(command);
+       if (free_command == EVFS_CLEANUP_FREE_COMMAND) free(command);
 }
 
 void evfs_cleanup_file_command(evfs_command* command) {
@@ -27,3 +27,45 @@
        if (mon->monitor_path) free (mon->monitor_path);
        free(mon);
 }
+
+
+
+/*----------------------------------*/
+void evfs_cleanup_filereference(evfs_filereference* ref) {
+       if (ref->plugin_uri) free(ref->plugin_uri);
+       if (ref->path) free(ref->path);
+       if (ref->username) free(ref->username);
+       if (ref->password) free(ref->password);
+
+}
+
+void evfs_cleanup_monitor_event(evfs_event* event) {
+       if (event->file_monitor.plugin) free(event->file_monitor.plugin);
+       if (event->file_monitor.filename) free(event->file_monitor.filename);
+       
+}
+
+void evfs_cleanup_file_list_event(evfs_event* event) {
+       evfs_filereference* file;
+       ecore_list_goto_first(event->file_list.list);
+       while ( (file = ecore_list_remove_first(event->file_list.list))) {
+               evfs_cleanup_filereference(file);
+       }
+       ecore_list_destroy(event->file_list.list);
+}
+
+void evfs_cleanup_event(evfs_event* event) {
+       evfs_cleanup_command(&event->resp_command, 
EVFS_CLEANUP_PRESERVE_COMMAND);
+
+       switch (event->type) {
+               case EVFS_EV_FILE_MONITOR:
+                       evfs_cleanup_monitor_event(event);
+                       break;
+               case EVFS_EV_DIR_LIST:
+                       evfs_cleanup_file_list_event(event);
+                       break;
+       }
+
+       free(event);
+               
+}
===================================================================
RCS file: /cvsroot/enlightenment/e17/apps/evfs/src/common/evfs_event_helper.c,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -3 -r1.7 -r1.8
--- evfs_event_helper.c 18 Oct 2005 08:47:38 -0000      1.7
+++ evfs_event_helper.c 22 Oct 2005 04:51:42 -0000      1.8
@@ -10,15 +10,15 @@
 
        evfs_event* event = NEW(evfs_event);
        event->type = EVFS_EV_FILE_MONITOR;
-       event->file_monitor.filename = (char*)path;
+       event->file_monitor.filename = strdup(path);
        event->file_monitor.fileev_type = type;
-       event->file_monitor.plugin = plugin;
+       event->file_monitor.plugin = strdup(plugin);
        event->file_monitor.filename_len = strlen(path)+1;
 
        evfs_write_event(client, NULL, event);
 
        /*Now destroy*/
-       free(event);
+       evfs_cleanup_event(event);
        /*No need to free data -it's probably a const raised by the ecore - it 
will free it.*/
        
 }
@@ -35,7 +35,7 @@
        evfs_write_event(client, command, event);
 
        /*Now destroy*/
-       free(event);
+       evfs_cleanup_event(event);
        /*No need to free data -it's probably a const raised by the ecore - it 
will free it.*/
        
 }
@@ -43,7 +43,6 @@
 void evfs_list_dir_event_create(evfs_client* client, evfs_command* command, 
Ecore_List* files) {
        /*Create a reply event for a file mon event, send it , destroy event*/
 
-       printf("Creating a list dir event..\n");
        
        evfs_event* event = NEW(evfs_event);
        event->type = EVFS_EV_DIR_LIST;
@@ -51,7 +50,7 @@
        evfs_write_event(client, command, event);
 
        /*Now destroy*/
-       free(event);
+       evfs_cleanup_event(event);
        /*No need to free data -it's probably a const raised by the ecore - it 
will free it.*/
 
 }




-------------------------------------------------------
This SF.Net email is sponsored by:
Power Architecture Resource Center: Free content, downloads, discussions,
and more. http://solutions.newsforge.com/ibmarch.tmpl
_______________________________________________
enlightenment-cvs mailing list
enlightenment-cvs@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs

Reply via email to