summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJérémy Zurcher <jeremy@asynk.ch>2012-05-29 15:45:03 +0200
committerJérémy Zurcher <jeremy@asynk.ch>2012-05-29 15:45:03 +0200
commit82afdb93d790105246acfd5a47185ebd10961ab5 (patch)
treedcf9a9dc190af13b213283c62703beb6188e05c4
parent3baf3d0553435a29773c75864e66f86af7e3fe4c (diff)
downloadedoors-82afdb93d790105246acfd5a47185ebd10961ab5.zip
edoors-82afdb93d790105246acfd5a47185ebd10961ab5.tar.gz
eiotas_main: add static init/shutdown counter
-rw-r--r--src/lib/eiotas_main.c15
1 files 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 <stdio.h>
+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;
}