* eina: Remove memory leak (patch from Andre Dieb).
authorcedric <cedric>
Tue, 9 Jun 2009 16:02:20 +0000 (16:02 +0000)
committercedric <cedric@7cbeb6ba-43b4-40fd-8cce-4c39aea84d33>
Tue, 9 Jun 2009 16:02:20 +0000 (16:02 +0000)
git-svn-id: http://svn.enlightenment.org/svn/e/trunk/eina@40986 7cbeb6ba-43b4-40fd-8cce-4c39aea84d33

src/lib/eina_error.c
src/lib/eina_mempool.c

index 09d7a25..a3f0a22 100644 (file)
@@ -530,7 +530,6 @@ EAPI int eina_error_init(void)
        {
                char *level;
                /* TODO register the eina's basic errors */
-               /* TODO load the environment variable for getting the log level */
                if ((level = getenv("EINA_ERROR_LEVEL")))
                {
                        _error_level = atoi(level);
index 61b6a21..c28ec25 100644 (file)
@@ -123,8 +123,16 @@ eina_mempool_init(void)
        {
                char *path;
 
-               eina_hash_init();
-               eina_module_init();
+               if (!eina_hash_init())
+                 {
+                    fprintf(stderr, "Could not initialize eina hash module.\n");
+                    return 0;
+                 }
+               if (!eina_module_init())
+                 {
+                    fprintf(stderr, "Could not initialize eina module module.\n");
+                    goto module_init_error;
+                 }
 
                EINA_ERROR_NOT_MEMPOOL_MODULE = eina_error_msg_register("Not a memory pool module.");
                _backends = eina_hash_string_superfast_new(NULL);
@@ -147,7 +155,8 @@ eina_mempool_init(void)
                if (!_modules)
                {
                        EINA_ERROR_PERR("ERROR: no mempool modules able to be loaded.\n");
-                       abort();
+                       eina_hash_free(_backends);
+                       goto mempool_init_error;
                }
                eina_module_list_load(_modules);
                /* builtin backends */
@@ -165,6 +174,14 @@ eina_mempool_init(void)
 #endif
        }
        return ++_init_count;
+
+       mempool_init_error:
+          eina_module_shutdown();
+       module_init_error:
+          eina_hash_shutdown();
+
+       return 0;
+
 }
 
 /**
@@ -190,9 +207,15 @@ eina_mempool_shutdown(void)
        ememoa_fixed_shutdown();
 #endif
        /* dynamic backends */
-       eina_module_list_unload(_modules);
+       eina_module_list_delete(_modules);
+       if (_modules)
+          eina_array_free(_modules);
+
        eina_module_shutdown();
-       /* TODO delete the _modules list */
+
+       if (_backends)
+          eina_hash_free(_backends);
+
        eina_hash_shutdown();
        return 0;
 }