xbt_dynar_t globals;
} s_gras_cbps_t;
-static void free_string(void *d){
- free(*(void**)d);
-}
-
gras_cbps_t gras_cbps_new(void) {
gras_cbps_t res;
/* Prototypes of the functions that handle the properties */
XBT_PUBLIC_DATA(xbt_dict_t) current_property_set; /* the prop set for the currently parsed element (also used in SIMIX) */
void parse_properties(void);
-void free_string(void*);
/* Prototypes for functions handling routing and were factorized succesfully from the models */
void init_data(void);
src_id = network_card_new(A_surfxml_route_src);
dst_id = network_card_new(A_surfxml_route_dst);
route_action = A_surfxml_route_action;
- route_link_list = xbt_dynar_new(sizeof(char *), &free_string);
+ route_link_list = xbt_dynar_new(sizeof(char *), &xbt_free_ref);
}
static void parse_route_set_route(void)
src_id = strtol(xbt_dynar_get_as(keys, 0, char*), &end, 16);
dst_id = strtol(xbt_dynar_get_as(keys, 1, char*), &end, 16);
+ xbt_dynar_free(&keys);
xbt_dynar_foreach (links, cpt, link) {
TRY {
src_id = network_card_new(A_surfxml_route_src);
dst_id = network_card_new(A_surfxml_route_dst);
route_action = A_surfxml_route_action;
- route_link_list = xbt_dynar_new(sizeof(char *), &free_string);
+ route_link_list = xbt_dynar_new(sizeof(char *), &xbt_free_ref);
}
static void parse_route_set_route(void)
/* nb_link = 0;
link_name = NULL;
*/
- route_link_list = xbt_dynar_new(sizeof(char *), &free_string);
+ route_link_list = xbt_dynar_new(sizeof(char *), &xbt_free_ref);
}
/* KF*/
surfxml_call_cb_functions(ETag_surfxml_platform_cb_list);
+ xbt_dynar_free(&route_link_list);
xbt_dict_free(&random_data_list);
xbt_dict_free(&set_list);
xbt_dict_set(current_property_set, A_surfxml_prop_id, value, free);
}
-void free_string(void *d)
-{
- free(*(void**)d);
-}
-
void surfxml_add_callback(xbt_dynar_t cb_list, void_f_void_t function)
{
xbt_dynar_push(cb_list, &function);
is_symmetric_route = A_surfxml_route_c_multi_symmetric;
route_multi_size++;
- route_link_list = xbt_dynar_new(sizeof(char *), &free_string);
+ route_link_list = xbt_dynar_new(sizeof(char *), &xbt_free_ref);
}
static int contains(xbt_dynar_t list, const char* value)
dst_names = (xbt_dynar_t)xbt_dict_get_or_null(set_list, dst);
/* Add to dynar even if they are simple names */
if (src_names == NULL) {
- src_names = xbt_dynar_new(sizeof(char *), &free_string);
+ src_names = xbt_dynar_new(sizeof(char *), &xbt_free_ref);
val = xbt_strdup(src);
xbt_dynar_push(src_names, &val);
if (strcmp(val,"$*") != 0 && NULL == xbt_dict_get_or_null(set, val))
THROW3(unknown_error,0,"(In route:multi (%s -> %s) source %s does not exist (not a set or a host)", src, dst, src);
}
if (dst_names == NULL) {
- dst_names = xbt_dynar_new(sizeof(char *), &free_string);
+ dst_names = xbt_dynar_new(sizeof(char *), &xbt_free_ref);
val = xbt_strdup(dst);
if (strcmp(val,"$*") != 0 && NULL == xbt_dict_get_or_null(set, val))
THROW3(unknown_error,0,"(In route:multi (%s -> %s) destination %s does not exist (not a set or a host)", src, dst, dst);
route_action = A_surfxml_route_action;
- route_link_list = xbt_dynar_new(sizeof(char*), &free_string);
+ route_link_list = xbt_dynar_new(sizeof(char*), &xbt_free_ref);
}
static void parse_route_set_route(void)
/* doxygen_string_cruft */
-/* The function we will use to free the data */
-static void free_string(void *d){
- free(*(void**)d);
-}
-
/*******************************************************************************/
/*******************************************************************************/
/*******************************************************************************/
char *s1,*s2;
xbt_test_add0("==== Traverse the empty dynar");
- d=xbt_dynar_new(sizeof(char *),&free_string);
+ d=xbt_dynar_new(sizeof(char *),&xbt_free_ref);
xbt_dynar_foreach(d,iter,s1){
xbt_test_assert0(FALSE,
"Damnit, there is something in the empty dynar");
xbt_test_add1("==== Push %d strings, set them again 3 times, shift them",NB_ELEM);
/* Populate_str [doxygen cruft] */
- d=xbt_dynar_new(sizeof(char*),&free_string);
+ d=xbt_dynar_new(sizeof(char*),&xbt_free_ref);
/* 1. Populate the dynar */
for (cpt=0; cpt< NB_ELEM; cpt++) {
sprintf(buf,"%d",cpt);
xbt_test_add1("==== Unshift, traverse and pop %d strings",NB_ELEM);
- d=xbt_dynar_new(sizeof(char**),&free_string);
+ d=xbt_dynar_new(sizeof(char**),&xbt_free_ref);
for (cpt=0; cpt< NB_ELEM; cpt++) {
sprintf(buf,"%d",cpt);
s1=strdup(buf);
xbt_test_add2("==== Push %d strings, insert %d strings in the middle, shift everything",NB_ELEM,NB_ELEM/5);
- d=xbt_dynar_new(sizeof(char*),&free_string);
+ d=xbt_dynar_new(sizeof(char*),&xbt_free_ref);
for (cpt=0; cpt< NB_ELEM; cpt++) {
sprintf(buf,"%d",cpt);
s1=strdup(buf);
xbt_test_add3("==== Push %d strings, remove %d-%d. free the rest",NB_ELEM,2*(NB_ELEM/5),4*(NB_ELEM/5));
- d=xbt_dynar_new(sizeof(char*),&free_string);
+ d=xbt_dynar_new(sizeof(char*),&xbt_free_ref);
for (cpt=0; cpt< NB_ELEM; cpt++) {
sprintf(buf,"%d",cpt);
s1=strdup(buf);