From d6341bfc9eff21f03eb3717deb22d0f3099e28f1 Mon Sep 17 00:00:00 2001 From: Bruno Dilly Date: Tue, 19 Jun 2012 18:24:17 +0000 Subject: [PATCH] Elm: module unloading Implements the module unloading to all modules on elm_module_shutdown. This change also fixes a memory leak within elm_module picked by valgrind. Here follows the valgrind log: 96 bytes in 1 blocks are definitely lost in loss record 105 of 168 at 0x4C29DB4: calloc ( in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so) by 0x52065B6: _elm_module_add (elm_module.c:223) by 0x520669E: _elm_module_parse (elm_module.c:77) by 0x51F1249: elm_quicklaunch_sub_init (elm_main.c:437) by 0x51F12BE: elm_init (elm_main.c:180) Patch by Leandro Dorileo SVN revision: 72499 --- legacy/elementary/src/lib/elm_module.c | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/legacy/elementary/src/lib/elm_module.c b/legacy/elementary/src/lib/elm_module.c index 396e9de7dc..8357cadc7d 100644 --- a/legacy/elementary/src/lib/elm_module.c +++ b/legacy/elementary/src/lib/elm_module.c @@ -42,9 +42,21 @@ _elm_module_init(void) void _elm_module_shutdown(void) { - // FIXME: unload all modules - if (modules) eina_hash_free(modules); - modules = NULL; + Eina_Iterator *it; + Elm_Module *m; + + if (modules) + { + it = eina_hash_iterator_data_new(modules); + + EINA_ITERATOR_FOREACH(it, m) + _elm_module_del(m); + + eina_iterator_free(it); + eina_hash_free(modules); + modules = NULL; + } + if (modules_as) eina_hash_free(modules_as); modules_as = NULL; }