void instr_paje_init (container_t root)
{
- allContainers = xbt_dict_new ();
- trivaNodeTypes = xbt_dict_new ();
- trivaEdgeTypes = xbt_dict_new ();
+ allContainers = xbt_dict_new_homogeneous(NULL);
+ trivaNodeTypes = xbt_dict_new_homogeneous(xbt_free);
+ trivaEdgeTypes = xbt_dict_new_homogeneous(xbt_free);
rootContainer = root;
}
+void instr_paje_free (void)
+{
+ xbt_dict_free (&allContainers);
+ xbt_dict_free (&trivaNodeTypes);
+ xbt_dict_free (&trivaEdgeTypes);
+}
+
static long long int new_type_id (void)
{
static long long int type_id = 0;
return type_id++;
}
+static void destroyValue (void *value)
+{
+ xbt_free(((val_t)value)->name);
+ xbt_free(((val_t)value)->color);
+ xbt_free(((val_t)value)->id);
+ xbt_free(value);
+}
+
static val_t newValue (const char *valuename, const char *color, type_t father)
{
val_t ret = xbt_new0(s_val_t, 1);
ret->name = xbt_strdup (typename);
ret->father = father;
ret->kind = kind;
- ret->children = xbt_dict_new ();
- ret->values = xbt_dict_new ();
+ ret->children = xbt_dict_new_homogeneous(NULL);
+ ret->values = xbt_dict_new_homogeneous(NULL);
ret->color = xbt_strdup (color);
char str_id[INSTR_DEFAULT_STR_SIZE];
default: xbt_die ("Congratulations, you have found a bug on newContainer function of instr_routing.c"); break;
}
}
- new->children = xbt_dict_new();
+ new->children = xbt_dict_new_homogeneous(NULL);
if (new->father){
xbt_dict_set(new->father->children, new->name, new, NULL);
new_pajeCreateContainer (new);
xbt_dict_set (allContainers, new->name, new, NULL);
//register NODE types for triva configuration
- xbt_dict_set (trivaNodeTypes, new->type->name, xbt_strdup("1"), xbt_free);
+ xbt_dict_set (trivaNodeTypes, new->type->name, xbt_strdup("1"), NULL);
}
return new;
}
void destroyContainer (container_t container)
{
- //remove me from my father
- if (container->father){
- xbt_dict_remove(container->father->children, container->name);
- }
-
XBT_DEBUG("destroy container %s", container->name);
//obligation to dump previous events because they might
//free
xbt_free (container->name);
xbt_free (container->id);
- xbt_free (container->children);
+ xbt_dict_free (&container->children);
xbt_free (container);
container = NULL;
}
}
xbt_free (type->name);
xbt_free (type->id);
- xbt_free (type->children);
- xbt_free (type->values);
+ xbt_free (type->color);
+ xbt_dict_free (&type->children);
+ val_t value;
+ char *value_name;
+ xbt_dict_foreach(type->values, cursor, value_name, value) {
+ destroyValue (value);
+ }
+ xbt_dict_free (&type->values);
xbt_free (type);
type = NULL;
}