eina_list: Ensure single init

This fixes a crash in make check when --profile=dev is explicitely
enabled. eina_list_init() is called by the standard eina_init() loop
and by eina_debug_init() as well.

Honestly I'm not sure why it doesn't crash for other people as
well...

The crash was in eolian_suite during the second eina_init (called
from eolian_init).
This commit is contained in:
Jean-Philippe Andre 2017-07-20 17:42:14 +09:00
parent 7bb14727af
commit 5db3e557c5
1 changed files with 13 additions and 0 deletions

View File

@ -473,6 +473,8 @@ eina_list_sort_merge(Eina_List *a, Eina_List *b, Eina_Compare_Cb func)
* Global *
*============================================================================*/
static int _eina_list_init = 0;
/**
* @internal
* @brief Initialize the list module.
@ -493,6 +495,9 @@ eina_list_init(void)
{
const char *choice, *tmp;
if ((_eina_list_init++) > 0)
return _eina_list_init;
_eina_list_log_dom = eina_log_domain_register("eina_list",
EINA_LOG_COLOR_DEFAULT);
if (_eina_list_log_dom < 0)
@ -557,9 +562,17 @@ on_init_fail:
Eina_Bool
eina_list_shutdown(void)
{
if ((--_eina_list_init) != 0)
{
if (_eina_list_init < 0) _eina_list_init = 0;
return _eina_list_init;
}
eina_freeq_clear(eina_freeq_main_get());
eina_mempool_del(_eina_list_accounting_mp);
eina_mempool_del(_eina_list_mp);
_eina_list_accounting_mp = NULL;
_eina_list_mp = NULL;
eina_log_domain_unregister(_eina_list_log_dom);
_eina_list_log_dom = -1;