diff options
author | Dirk Hohndel <dirk@hohndel.org> | 2014-06-11 19:02:20 -0700 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2014-06-11 19:02:49 -0700 |
commit | 0c8dbc2061acc92f674cf53b4fb20fafe8c86a25 (patch) | |
tree | 189ee77539b86d30b8a13fdc8334efe97fdcee8d /parse-xml.c | |
parent | a0f5a74847942a7448d8a6aedc6277cf5436c19b (diff) | |
download | subsurface-0c8dbc2061acc92f674cf53b4fb20fafe8c86a25.tar.gz |
Simplify code
Since trimspace() null terminates the string, we can simply use strdup()
here.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'parse-xml.c')
-rw-r--r-- | parse-xml.c | 10 |
1 files changed, 3 insertions, 7 deletions
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 */ |