From 0c8dbc2061acc92f674cf53b4fb20fafe8c86a25 Mon Sep 17 00:00:00 2001 From: Dirk Hohndel Date: Wed, 11 Jun 2014 19:02:20 -0700 Subject: Simplify code Since trimspace() null terminates the string, we can simply use strdup() here. Signed-off-by: Dirk Hohndel --- parse-xml.c | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) (limited to 'parse-xml.c') diff --git a/parse-xml.c b/parse-xml.c index 163b1b7fa..6abb788e3 100644 --- a/parse-xml.c +++ b/parse-xml.c @@ -505,15 +505,11 @@ int trimspace(char *buffer) { static void utf8_string(char *buffer, void *_res) { - char *res; + char **res = _res; int size; size = trimspace(buffer); - if(size) { - res = malloc(size + 1); - memcpy(res, buffer, size); - res[size] = 0; - *(char **)_res = res; - } + if(size) + *res = strdup(buffer); } /* Extract the dive computer type from the xml text buffer */ -- cgit v1.2.3-70-g09d2