summaryrefslogtreecommitdiff
path: root/legacy/eio
diff options
context:
space:
mode:
authorCedric BAIL <cedric.bail@free.fr>2012-08-30 08:52:15 +0000
committerCedric BAIL <cedric.bail@free.fr>2012-08-30 08:52:15 +0000
commitf82152f150560edfa555f88ece77e5f7bf0ece06 (patch)
treeb4950804d78118c528dc03e1a85c97b91ee1b336 /legacy/eio
parent19af039b30058a36b32198314492dabe4244d2d1 (diff)
eio: fix memory leak when using file associate.
SVN revision: 75854
Diffstat (limited to 'legacy/eio')
-rw-r--r--legacy/eio/ChangeLog4
-rw-r--r--legacy/eio/NEWS1
-rw-r--r--legacy/eio/src/lib/eio_dir.c8
-rw-r--r--legacy/eio/src/lib/eio_file.c17
-rw-r--r--legacy/eio/src/lib/eio_private.h3
-rw-r--r--legacy/eio/src/lib/eio_single.c20
-rw-r--r--legacy/eio/src/lib/eio_xattr.c2
7 files changed, 39 insertions, 16 deletions
diff --git a/legacy/eio/ChangeLog b/legacy/eio/ChangeLog
index 90cccb3724..dfa4c95684 100644
--- a/legacy/eio/ChangeLog
+++ b/legacy/eio/ChangeLog
@@ -27,3 +27,7 @@
27 27
28 * Do not free Windows stuff when it is not used. Fix seg fault 28 * Do not free Windows stuff when it is not used. Fix seg fault
29 * Add log debugging macros 29 * Add log debugging macros
30
312012-08-30 Cedric Bail
32
33 * Fix memory leak when using file associate API.
diff --git a/legacy/eio/NEWS b/legacy/eio/NEWS
index 81e59189d8..5da27bd815 100644
--- a/legacy/eio/NEWS
+++ b/legacy/eio/NEWS
@@ -11,6 +11,7 @@ Fixes:
11 - memory leak when shutting down fallback monitor. 11 - memory leak when shutting down fallback monitor.
12 - properly shutdown monitor. 12 - properly shutdown monitor.
13 - Fix segfault when shutting down the Windows monitor. 13 - Fix segfault when shutting down the Windows monitor.
14 - Fix memory leak when using file_associate.
14 15
15Improvements: 16Improvements:
16 - Add log debuggong macros 17 - Add log debuggong macros
diff --git a/legacy/eio/src/lib/eio_dir.c b/legacy/eio/src/lib/eio_dir.c
index 40d2b6a670..5de5fb661b 100644
--- a/legacy/eio/src/lib/eio_dir.c
+++ b/legacy/eio/src/lib/eio_dir.c
@@ -454,7 +454,7 @@ _eio_dir_copy_free(Eio_Dir_Copy *copy)
454{ 454{
455 eina_stringshare_del(copy->progress.source); 455 eina_stringshare_del(copy->progress.source);
456 eina_stringshare_del(copy->progress.dest); 456 eina_stringshare_del(copy->progress.dest);
457 free(copy); 457 eio_file_free(&copy->progress.common);
458} 458}
459 459
460static void 460static void
@@ -777,8 +777,7 @@ _eio_dir_stat_done(void *data, Ecore_Thread *thread __UNUSED__)
777 777
778 async->common.done_cb((void*) async->common.data, &async->common); 778 async->common.done_cb((void*) async->common.data, &async->common);
779 779
780 eina_stringshare_del(async->directory); 780 eio_async_free(async);
781 free(async);
782} 781}
783 782
784static void 783static void
@@ -788,8 +787,7 @@ _eio_dir_stat_error(void *data, Ecore_Thread *thread __UNUSED__)
788 787
789 eio_file_error(&async->common); 788 eio_file_error(&async->common);
790 789
791 eina_stringshare_del(async->directory); 790 eio_async_free(async);
792 free(async);
793} 791}
794 792
795/** 793/**
diff --git a/legacy/eio/src/lib/eio_file.c b/legacy/eio/src/lib/eio_file.c
index f1a55794f4..247546fcd6 100644
--- a/legacy/eio/src/lib/eio_file.c
+++ b/legacy/eio/src/lib/eio_file.c
@@ -429,7 +429,7 @@ _eio_file_copy_free(Eio_File_Progress *copy)
429{ 429{
430 eina_stringshare_del(copy->source); 430 eina_stringshare_del(copy->source);
431 eina_stringshare_del(copy->dest); 431 eina_stringshare_del(copy->dest);
432 free(copy); 432 eio_file_free(&copy->common);
433} 433}
434 434
435static void 435static void
@@ -457,7 +457,7 @@ _eio_file_move_free(Eio_File_Move *move)
457{ 457{
458 eina_stringshare_del(move->progress.source); 458 eina_stringshare_del(move->progress.source);
459 eina_stringshare_del(move->progress.dest); 459 eina_stringshare_del(move->progress.dest);
460 free(move); 460 eio_file_free(&move->progress.common);
461} 461}
462 462
463static void 463static void
@@ -703,14 +703,20 @@ eio_file_copy_do(Ecore_Thread *thread, Eio_File_Progress *copy)
703} 703}
704 704
705void 705void
706eio_async_free(Eio_File_Ls *async)
707{
708 eina_stringshare_del(async->directory);
709 eio_file_free(&async->common);
710}
711
712void
706eio_async_end(void *data, Ecore_Thread *thread __UNUSED__) 713eio_async_end(void *data, Ecore_Thread *thread __UNUSED__)
707{ 714{
708 Eio_File_Ls *async = data; 715 Eio_File_Ls *async = data;
709 716
710 async->common.done_cb((void*) async->common.data, &async->common); 717 async->common.done_cb((void*) async->common.data, &async->common);
711 718
712 eina_stringshare_del(async->directory); 719 eio_async_free(async);
713 free(async);
714} 720}
715 721
716void 722void
@@ -720,8 +726,7 @@ eio_async_error(void *data, Ecore_Thread *thread __UNUSED__)
720 726
721 eio_file_error(&async->common); 727 eio_file_error(&async->common);
722 728
723 eina_stringshare_del(async->directory); 729 eio_async_free(async);
724 free(async);
725} 730}
726 731
727/** 732/**
diff --git a/legacy/eio/src/lib/eio_private.h b/legacy/eio/src/lib/eio_private.h
index aab69dc2f2..ef983f98a0 100644
--- a/legacy/eio/src/lib/eio_private.h
+++ b/legacy/eio/src/lib/eio_private.h
@@ -464,6 +464,9 @@ Eina_Bool eio_long_file_set(Eio_File *common,
464 Ecore_Thread_Cb end_cb, 464 Ecore_Thread_Cb end_cb,
465 Ecore_Thread_Cb cancel_cb); 465 Ecore_Thread_Cb cancel_cb);
466 466
467void eio_file_free(Eio_File *common);
468void eio_async_free(Eio_File_Ls *async);
469
467void eio_file_container_set(Eio_File *common, void *container); 470void eio_file_container_set(Eio_File *common, void *container);
468 471
469void eio_file_error(Eio_File *common); 472void eio_file_error(Eio_File *common);
diff --git a/legacy/eio/src/lib/eio_single.c b/legacy/eio/src/lib/eio_single.c
index 69f4185c29..8bc99fa41e 100644
--- a/legacy/eio/src/lib/eio_single.c
+++ b/legacy/eio/src/lib/eio_single.c
@@ -42,7 +42,7 @@ static void
42_eio_mkdir_free(Eio_File_Mkdir *m) 42_eio_mkdir_free(Eio_File_Mkdir *m)
43{ 43{
44 eina_stringshare_del(m->path); 44 eina_stringshare_del(m->path);
45 free(m); 45 eio_file_free(&m->common);
46} 46}
47 47
48static void 48static void
@@ -78,7 +78,7 @@ static void
78_eio_unlink_free(Eio_File_Unlink *l) 78_eio_unlink_free(Eio_File_Unlink *l)
79{ 79{
80 eina_stringshare_del(l->path); 80 eina_stringshare_del(l->path);
81 free(l); 81 eio_file_free(&l->common);
82} 82}
83 83
84static void 84static void
@@ -169,7 +169,7 @@ static void
169_eio_stat_free(Eio_File_Stat *s) 169_eio_stat_free(Eio_File_Stat *s)
170{ 170{
171 eina_stringshare_del(s->path); 171 eina_stringshare_del(s->path);
172 free(s); 172 eio_file_free(&s->common);
173} 173}
174 174
175static void 175static void
@@ -272,7 +272,7 @@ _eio_chown_free(Eio_File_Chown *ch)
272 if (ch->user) eina_stringshare_del(ch->user); 272 if (ch->user) eina_stringshare_del(ch->user);
273 if (ch->group) eina_stringshare_del(ch->group); 273 if (ch->group) eina_stringshare_del(ch->group);
274 eina_stringshare_del(ch->path); 274 eina_stringshare_del(ch->path);
275 free(ch); 275 eio_file_free(&ch->common);
276} 276}
277 277
278static void 278static void
@@ -321,6 +321,16 @@ eio_file_thread_error(Eio_File *common, Ecore_Thread *thread)
321 ecore_thread_cancel(thread); 321 ecore_thread_cancel(thread);
322} 322}
323 323
324void
325eio_file_free(Eio_File *common)
326{
327 if (common->worker.associated)
328 eina_hash_free(common->worker.associated);
329 if (common->main.associated)
330 eina_hash_free(common->main.associated);
331 free(common);
332}
333
324Eina_Bool 334Eina_Bool
325eio_long_file_set(Eio_File *common, 335eio_long_file_set(Eio_File *common,
326 Eio_Done_Cb done_cb, 336 Eio_Done_Cb done_cb,
@@ -372,6 +382,8 @@ eio_file_set(Eio_File *common,
372 common->error = 0; 382 common->error = 0;
373 common->thread = NULL; 383 common->thread = NULL;
374 common->container = NULL; 384 common->container = NULL;
385 common->worker.associated = NULL;
386 common->main.associated = NULL;
375 387
376 /* Be aware that ecore_thread_run could call cancel_cb if something goes wrong. 388 /* Be aware that ecore_thread_run could call cancel_cb if something goes wrong.
377 This means that common would be destroyed if thread == NULL. 389 This means that common would be destroyed if thread == NULL.
diff --git a/legacy/eio/src/lib/eio_xattr.c b/legacy/eio/src/lib/eio_xattr.c
index 696028446d..cff21b92e7 100644
--- a/legacy/eio/src/lib/eio_xattr.c
+++ b/legacy/eio/src/lib/eio_xattr.c
@@ -113,7 +113,7 @@ _eio_file_xattr_free(Eio_File_Xattr *async)
113 if (async->op == EIO_XATTR_DATA) free(async->todo.xdata.xattr_data); 113 if (async->op == EIO_XATTR_DATA) free(async->todo.xdata.xattr_data);
114 if (async->op == EIO_XATTR_STRING) free(async->todo.xstring.xattr_string); 114 if (async->op == EIO_XATTR_STRING) free(async->todo.xstring.xattr_string);
115 } 115 }
116 free(async); 116 eio_file_free(&async->common);
117} 117}
118 118
119static void 119static void