Hello,
This patch adds failure handling on eina_array_init() and eina_list_init()
by shutting down and cleaning up what was used up to the failure point.
--
André Dieb Martins
Embedded Systems and Pervasive Computing Lab (Embedded)
Electrical Engineering Department (DEE)
Center of Electrical Engineering and Informatics (CEEI)
Federal University of Campina Grande (UFCG)
Blog: http://genuinepulse.blogspot.com/
Mail: dieb at embedded.ufcg.edu.br, andre.dieb at gmail.com
Index: src/lib/eina_list.c
===================================================================
--- src/lib/eina_list.c (revision 40872)
+++ src/lib/eina_list.c (working copy)
@@ -446,10 +446,24 @@
if (!_eina_list_init_count)
{
- eina_error_init();
- eina_magic_string_init();
- eina_mempool_init();
+ if (!eina_error_init())
+ {
+ fprintf(stderr, "Could not initialize eina error module\n");
+ return 0;
+ }
+ if (!eina_magic_string_init())
+ {
+ EINA_ERROR_PERR("ERROR: Could not initialize eina magic string module.\n");
+ goto on_magic_string_fail;
+ }
+
+ if (!eina_mempool_init())
+ {
+ EINA_ERROR_PERR("ERROR: Could not initialize eina mempool module.\n");
+ goto on_mempool_fail;
+ }
+
#ifdef EINA_DEFAULT_MEMPOOL
choice = "pass_through";
#else
@@ -462,14 +476,15 @@
if (!_eina_list_mp)
{
EINA_ERROR_PERR("ERROR: Mempool for list cannot be allocated in list init.\n");
- abort();
+ goto on_init_fail;
}
_eina_list_accounting_mp = eina_mempool_new(choice, "list_accounting", NULL,
sizeof (Eina_List_Accounting), 80);
if (!_eina_list_accounting_mp)
{
EINA_ERROR_PERR("ERROR: Mempool for list accounting cannot be allocated in list init.\n");
- abort();
+ eina_mempool_delete(_eina_list_mp);
+ goto on_init_fail;
}
eina_magic_string_set(EINA_MAGIC_ITERATOR,
@@ -487,6 +502,14 @@
}
return ++_eina_list_init_count;
+
+ on_init_fail:
+ eina_mempool_shutdown();
+ on_mempool_fail:
+ eina_magic_string_shutdown();
+ on_magic_string_fail:
+ eina_error_shutdown();
+ return 0;
}
/**
Index: src/lib/eina_hash.c
===================================================================
--- src/lib/eina_hash.c (revision 40872)
+++ src/lib/eina_hash.c (working copy)
@@ -21,6 +21,7 @@
# include "config.h"
#endif
+#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#ifdef _MSC_VER
@@ -664,7 +665,11 @@
eina_hash_init(void)
{
if (!_eina_hash_init_count)
- eina_error_init();
+ if (!eina_error_init())
+ {
+ fprintf(stderr, "Could not initialize eina error module\n");
+ return 0;
+ }
return ++_eina_hash_init_count;
}
------------------------------------------------------------------------------
OpenSolaris 2009.06 is a cutting edge operating system for enterprises
looking to deploy the next generation of Solaris that includes the latest
innovations from Sun and the OpenSource community. Download a copy and
enjoy capabilities such as Networking, Storage and Virtualization.
Go to: http://p.sf.net/sfu/opensolaris-get
_______________________________________________
enlightenment-devel mailing list
enlightenment-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/enlightenment-devel