}
/* callback to decide if we want to use the model-checking */
+#include "xbt_modinter.h"
int _surf_do_model_check = 0; /* this variable is used accros the lib */
static void _surf_cfg_cb_model_check(const char *name, int pos) {
_surf_do_model_check = 1;
+ /* Tell modules using mallocators that they shouldn't. MC don't like them */
+ xbt_fifo_preinit();
+ xbt_dict_preinit();
}
#ifdef HAVE_GTNETS
{
xbt_dict_t dict;
- if (dict_mallocator == NULL) {
- /* first run */
- dict_mallocator = xbt_mallocator_new(256,
- dict_mallocator_new_f,
- dict_mallocator_free_f,
- dict_mallocator_reset_f);
- dict_elm_mallocator = xbt_mallocator_new(256,
- dict_elm_mallocator_new_f,
- dict_elm_mallocator_free_f,
- dict_elm_mallocator_reset_f);
- }
-
dict = xbt_mallocator_get(dict_mallocator);
dict->table_size = 127;
dict->table = xbt_new0(xbt_dictelm_t, dict->table_size + 1);
xbt_dynar_free(&sizes);
}
+/**
+ * Create the dict mallocators.
+ * This is an internal XBT function called during the lib initialization.
+ * It can be used several times to recreate the mallocator, for example when you switch to MC mode
+ */
+void xbt_dict_preinit(void) {
+ if (dict_mallocator != NULL) {
+ /* Already created. I guess we want to switch to MC mode, so kill the previously created mallocator */
+ xbt_mallocator_free(dict_mallocator);
+ xbt_mallocator_free(dict_elm_mallocator);
+ }
+
+ dict_mallocator = xbt_mallocator_new(256,
+ dict_mallocator_new_f,
+ dict_mallocator_free_f,
+ dict_mallocator_reset_f);
+ dict_elm_mallocator = xbt_mallocator_new(256,
+ dict_elm_mallocator_new_f,
+ dict_elm_mallocator_free_f,
+ dict_elm_mallocator_reset_f);
+}
+
/**
* Destroy the dict mallocators.
- * This is an internal XBT function called by xbt_exit().
+ * This is an internal XBT function during the lib initialization
*/
void xbt_dict_postexit(void)
{
/* Module init/exit handling the fifo item mallocator
* These are internal XBT functions called by xbt_preinit/postexit().
+ * It can be used several times to recreate the mallocator, for example when you switch to MC mode
*/
void xbt_fifo_preinit(void) {
+ if (item_mallocator != NULL) {
+ /* Already created. I guess we want to switch to MC mode, so kill the previously created mallocator */
+ xbt_mallocator_free(item_mallocator);
+ }
+
item_mallocator = xbt_mallocator_new(256,
fifo_item_mallocator_new_f,
fifo_item_mallocator_free_f,