Fixes init error handling on eina_array, eina_main and eina_stringshare.
--
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/
Index: src/lib/eina_array.c
===================================================================
--- src/lib/eina_array.c (revision 40896)
+++ src/lib/eina_array.c (working copy)
@@ -148,6 +148,7 @@
#include <assert.h>
#include <stdlib.h>
#include <string.h>
+#include <stdio.h>
#include "eina_types.h"
#include "eina_error.h"
@@ -358,24 +359,34 @@
EAPI int
eina_array_init(void)
{
- if (!_eina_array_init_count)
- {
- eina_error_init();
- eina_magic_string_init();
+ if (!_eina_array_init_count)
+ {
+ if (!eina_error_init())
+ {
+ fprintf(stderr, "Could not initialize eina error module.\n");
+ return 0;
+ }
- eina_magic_string_set(EINA_MAGIC_ITERATOR,
- "Eina Iterator");
- eina_magic_string_set(EINA_MAGIC_ACCESSOR,
- "Eina Accessor");
- eina_magic_string_set(EINA_MAGIC_ARRAY,
- "Eina Array");
- eina_magic_string_set(EINA_MAGIC_ARRAY_ITERATOR,
- "Eina Array Iterator");
- eina_magic_string_set(EINA_MAGIC_ARRAY_ACCESSOR,
- "Eina Array Accessor");
- }
+ if (!eina_magic_string_init())
+ {
+ EINA_ERROR_PERR("ERROR: Could not initialize eina magic string module.\n");
+ eina_error_shutdown();
+ return 0;
+ }
- return ++_eina_array_init_count;
+ eina_magic_string_set(EINA_MAGIC_ITERATOR,
+ "Eina Iterator");
+ eina_magic_string_set(EINA_MAGIC_ACCESSOR,
+ "Eina Accessor");
+ eina_magic_string_set(EINA_MAGIC_ARRAY,
+ "Eina Array");
+ eina_magic_string_set(EINA_MAGIC_ARRAY_ITERATOR,
+ "Eina Array Iterator");
+ eina_magic_string_set(EINA_MAGIC_ARRAY_ACCESSOR,
+ "Eina Array Accessor");
+ }
+
+ return ++_eina_array_init_count;
}
/**
Index: src/lib/eina_main.c
===================================================================
--- src/lib/eina_main.c (revision 40896)
+++ src/lib/eina_main.c (working copy)
@@ -16,6 +16,8 @@
* if not, see <http://www.gnu.org/licenses/>.
*/
+#include <stdio.h>
+
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
@@ -47,18 +49,72 @@
{
if (_eina_main_count) goto finish_init;
- eina_error_init();
- eina_hash_init();
- eina_stringshare_init();
- eina_list_init();
- eina_array_init();
- eina_counter_init();
- eina_benchmark_init();
- eina_magic_string_init();
- eina_rectangle_init();
+ if (!eina_error_init())
+ {
+ fprintf(stderr, "Could not initialize eina error module.\n");
+ return 0;
+ }
+ if (!eina_hash_init())
+ {
+ EINA_ERROR_PERR("Could not initialize eina hash module.\n");
+ goto hash_init_error;
+ }
+ if (!eina_stringshare_init())
+ {
+ EINA_ERROR_PERR("Could not initialize eina stringshare module.\n");
+ goto stringshare_init_error;
+ }
+ if (!eina_list_init())
+ {
+ EINA_ERROR_PERR("Could not initialize eina list module.\n");
+ goto list_init_error;
+ }
+ if (!eina_array_init())
+ {
+ EINA_ERROR_PERR("Could not initialize eina array module.\n");
+ goto array_init_error;
+ }
+ if (!eina_counter_init())
+ {
+ EINA_ERROR_PERR("Could not initialize eina counter module.\n");
+ goto counter_init_error;
+ }
+ if (!eina_benchmark_init())
+ {
+ EINA_ERROR_PERR("Could not initialize eina benchmark module.\n");
+ goto benchmark_init_error;
+ }
+ if (!eina_magic_string_init())
+ {
+ EINA_ERROR_PERR("Could not initialize eina magic string module.\n");
+ goto magic_string_init_error;
+ }
+ if (!eina_rectangle_init())
+ {
+ EINA_ERROR_PERR("Could not initialize eina rectangle module.\n");
+ goto rectangle_init_error;
+ }
- finish_init:
- return ++_eina_main_count;
+ finish_init:
+ return ++_eina_main_count;
+
+ rectangle_init_error:
+ eina_magic_string_shutdown();
+ magic_string_init_error:
+ eina_benchmark_shutdown();
+ benchmark_init_error:
+ eina_counter_shutdown();
+ counter_init_error:
+ eina_array_shutdown();
+ array_init_error:
+ eina_list_shutdown();
+ list_init_error:
+ eina_stringshare_shutdown();
+ stringshare_init_error:
+ eina_hash_shutdown();
+ hash_init_error:
+ eina_error_shutdown();
+ return 0;
}
EAPI int
Index: src/lib/eina_stringshare.c
===================================================================
--- src/lib/eina_stringshare.c (revision 40896)
+++ src/lib/eina_stringshare.c (working copy)
@@ -829,9 +829,19 @@
if (!share)
return 0;
- eina_error_init();
- eina_magic_string_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");
+ eina_error_shutdown();
+ return 0;
+ }
+
eina_magic_string_set(EINA_MAGIC_STRINGSHARE,
"Eina Stringshare");
eina_magic_string_set(EINA_MAGIC_STRINGSHARE_HEAD,
------------------------------------------------------------------------------
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