Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Damn picky compiler. Kill unused vars when using ucontextes
[simgrid.git] / src / xbt / config.c
index 505ce0f..99559a7 100644 (file)
@@ -19,7 +19,7 @@
 
 #include "xbt/config.h" /* prototypes of this module */
 
-XBT_LOG_NEW_DEFAULT_SUBCATEGORY(config,xbt,"configuration support");
+XBT_LOG_NEW_DEFAULT_SUBCATEGORY(xbt_cfg,xbt,"configuration support");
 
 /* xbt_cfgelm_t: the typedef corresponding to a config variable. 
 
@@ -662,7 +662,7 @@ xbt_cfg_set_int(xbt_cfg_t cfg,const char*name, int val) {
           
     xbt_dynar_set(variable->content,0,&val);
   } else {
-    if (variable->max && xbt_dynar_length(variable->content) == variable->max)
+    if (variable->max && xbt_dynar_length(variable->content) == (unsigned long)variable->max)
       THROW3(mismatch_error,0,
              "Cannot add value %d to the config element %s since it's already full (size=%d)",
              val,name,variable->max); 
@@ -723,8 +723,14 @@ xbt_cfg_set_string(xbt_cfg_t cfg,const char*name, const char*val) {
   variable = xbt_cfgelm_get(cfg,name,xbt_cfgelm_string);
 
   if (variable->max == 1) {
-    if (variable->cb_rm && xbt_dynar_length(variable->content))
-      (*variable->cb_rm)(name, 0);
+    if (xbt_dynar_length(variable->content)) {
+       if (variable->cb_rm)
+        (*variable->cb_rm)(name, 0);
+       else if (variable->type == xbt_cfgelm_string) {
+        char * sval=xbt_dynar_get_as(variable->content,0,char*);
+        free(sval);
+       }
+    }
           
     xbt_dynar_set(variable->content,0,&newval);
   } else {
@@ -1195,8 +1201,6 @@ XBT_TEST_UNIT("validation",test_config_validation,"Validation tests") {
 }
 
 XBT_TEST_UNIT("use",test_config_use,"Data retrieving tests") {
-  xbt_cfg_t set = set=make_set();
 
   xbt_test_add0("Get a single value");
   {