From b034dec40bc1f38856fe1d599d0ab5a3174780f7 Mon Sep 17 00:00:00 2001 From: mquinson Date: Thu, 16 Jul 2009 18:51:40 +0000 Subject: [PATCH] config returns NULL if a string is looked for, but not available git-svn-id: svn+ssh://scm.gforge.inria.fr/svn/simgrid/simgrid/trunk@6519 48e7efb5-ca39-0410-a469-dd3cf9ba447f --- src/xbt/config.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/xbt/config.c b/src/xbt/config.c index 31add8e738..f5541c08f0 100644 --- a/src/xbt/config.c +++ b/src/xbt/config.c @@ -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 *); -- 2.20.1