From 91e521435c701002a0cf201df2496863519c2157 Mon Sep 17 00:00:00 2001 From: agiersch Date: Tue, 22 Feb 2011 13:19:23 +0000 Subject: [PATCH] There is no need to dup the key when using xbt_dict_set. git-svn-id: svn+ssh://scm.gforge.inria.fr/svn/simgrid/simgrid/trunk@9682 48e7efb5-ca39-0410-a469-dd3cf9ba447f --- examples/simdag/properties/sd_prop.c | 2 +- src/surf/surf_routing.c | 9 +++++++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/examples/simdag/properties/sd_prop.c b/examples/simdag/properties/sd_prop.c index 28ee5970e2..a23a66f2b9 100644 --- a/examples/simdag/properties/sd_prop.c +++ b/examples/simdag/properties/sd_prop.c @@ -54,7 +54,7 @@ int main(int argc, char **argv) /* Trying to set a new property */ - xbt_dict_set(props, xbt_strdup("NewProp"), strdup("newValue"), free); + xbt_dict_set(props, "NewProp", strdup("newValue"), free); /* Print the properties of the workstation 1 */ xbt_dict_foreach(props, cursor, key, data) { diff --git a/src/surf/surf_routing.c b/src/surf/surf_routing.c index 3b6d3081b3..8c35d2f659 100644 --- a/src/surf/surf_routing.c +++ b/src/surf/surf_routing.c @@ -3873,6 +3873,7 @@ static void routing_parse_Srandom(void) double res = 0; int i = 0; random_data_t random = xbt_new0(s_random_data_t, 1); + char *tmpbuf; xbt_dynar_t radical_elements; unsigned int iter; @@ -3930,7 +3931,9 @@ static void routing_parse_Srandom(void) case 1: xbt_assert1(!xbt_dict_get_or_null(random_value,random_id),"Custom Random '%s' already exists !",random_id); res = random_generate(random); - xbt_dict_set(random_value, bprintf("%s%d",random_id,atoi(xbt_dynar_getfirst_as(radical_ends,char *))), bprintf("%f",res), free); + tmpbuf = bprintf("%s%d",random_id,atoi(xbt_dynar_getfirst_as(radical_ends,char *))); + xbt_dict_set(random_value, tmpbuf, bprintf("%f",res), free); + xbt_free(tmpbuf); break; case 2: surf_parse_get_int(&start, @@ -3939,7 +3942,9 @@ static void routing_parse_Srandom(void) for (i = start; i <= end; i++) { xbt_assert1(!xbt_dict_get_or_null(random_value,random_id),"Custom Random '%s' already exists !",bprintf("%s%d",random_id,i)); res = random_generate(random); - xbt_dict_set(random_value, bprintf("%s%d",random_id,i), bprintf("%f",res), free); + tmpbuf = bprintf("%s%d",random_id,i); + xbt_dict_set(random_value, tmpbuf, bprintf("%f",res), free); + xbt_free(tmpbuf); } break; default: -- 2.20.1