From 82afdb93d790105246acfd5a47185ebd10961ab5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Zurcher?= Date: Tue, 29 May 2012 15:45:03 +0200 Subject: eiotas_main: add static init/shutdown counter --- src/lib/eiotas_main.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/lib/eiotas_main.c b/src/lib/eiotas_main.c index d7b5009..e4799a1 100644 --- a/src/lib/eiotas_main.c +++ b/src/lib/eiotas_main.c @@ -22,6 +22,8 @@ #include "eina_main.h" #include +static int _eiotas_main_count = 0; + int _eiotas_log_dom; static Eiotas_Version _version = { VMAJ, VMIN, VMIC }; @@ -30,18 +32,27 @@ EAPI Eiotas_Version *eiotas_version = &_version; EAPI int eiotas_init() { + if (EINA_LIKELY(_eiotas_main_count > 0)) + return ++_eiotas_main_count; + if(!eina_init()) { fprintf(stderr,"Error during the initialization of Eina_Log module\n"); return EXIT_FAILURE; } _eiotas_log_dom = eina_log_domain_register("eiotas", EINA_COLOR_CYAN); + _eiotas_main_count = 1; - return EXIT_SUCCESS; + return 1; } EAPI int eiotas_shutdown() { - return eina_shutdown(); + _eiotas_main_count--; + if (EINA_UNLIKELY(_eiotas_main_count == 0)) { + eina_shutdown(); + } + + return _eiotas_main_count; } -- cgit v1.1-2-g2b99