Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
config returns NULL if a string is looked for, but not available
authormquinson <mquinson@48e7efb5-ca39-0410-a469-dd3cf9ba447f>
Thu, 16 Jul 2009 18:51:40 +0000 (18:51 +0000)
committermquinson <mquinson@48e7efb5-ca39-0410-a469-dd3cf9ba447f>
Thu, 16 Jul 2009 18:51:40 +0000 (18:51 +0000)
git-svn-id: svn+ssh://scm.gforge.inria.fr/svn/simgrid/simgrid/trunk@6519 48e7efb5-ca39-0410-a469-dd3cf9ba447f

src/xbt/config.c

index 31add8e..f5541c0 100644 (file)
@@ -1106,7 +1106,7 @@ double xbt_cfg_get_double(xbt_cfg_t cfg, const char *name)
  *
  * Returns the first value from the config set under the given name.
  * If there is more than one value, it will issue a warning. Consider using
- * xbt_cfg_get_dynar() instead.
+ * xbt_cfg_get_dynar() instead. Returns NULL if there is no value.
  *
  * \warning the returned value is the actual content of the config set
  */
@@ -1119,6 +1119,8 @@ char *xbt_cfg_get_string(xbt_cfg_t cfg, const char *name)
     WARN2
       ("You asked for the first value of the config element '%s', but there is %lu values\n",
        name, xbt_dynar_length(variable->content));
+  } else if (xbt_dynar_length(variable->content) == 0) {
+    return NULL;
   }
 
   return xbt_dynar_get_as(variable->content, 0, char *);