From f855cb1750800eae2b9a10573ae36acfb9ed8f36 Mon Sep 17 00:00:00 2001 From: Gabriel Corona Date: Fri, 29 Apr 2016 10:47:46 +0200 Subject: [PATCH] Ensure that the dict subsystem is initialized when creating a dict --- src/xbt/dict.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/src/xbt/dict.c b/src/xbt/dict.c index 59927b752a..6e2135d20c 100644 --- a/src/xbt/dict.c +++ b/src/xbt/dict.c @@ -44,6 +44,9 @@ xbt_dict_t xbt_dict_new(void) */ xbt_dict_t xbt_dict_new_homogeneous(void_f_pvoid_t free_ctn) { + if (dict_elm_mallocator == NULL) + xbt_dict_preinit(); + xbt_dict_t dict; dict = xbt_new(s_xbt_dict_t, 1); @@ -527,10 +530,14 @@ void xbt_dict_dump_sizes(xbt_dict_t dict) */ void xbt_dict_preinit(void) { - dict_elm_mallocator = xbt_mallocator_new(256, dict_elm_mallocator_new_f, dict_elm_mallocator_free_f, - dict_elm_mallocator_reset_f); - dict_het_elm_mallocator = xbt_mallocator_new(256, dict_het_elm_mallocator_new_f, dict_het_elm_mallocator_free_f, - dict_het_elm_mallocator_reset_f); + if (dict_elm_mallocator == NULL) + dict_elm_mallocator = xbt_mallocator_new( + 256, dict_elm_mallocator_new_f, dict_elm_mallocator_free_f, + dict_elm_mallocator_reset_f); + if (dict_het_elm_mallocator == NULL) + dict_het_elm_mallocator = xbt_mallocator_new( + 256, dict_het_elm_mallocator_new_f, dict_het_elm_mallocator_free_f, + dict_het_elm_mallocator_reset_f); } /** -- 2.20.1