summaryrefslogtreecommitdiffstats
path: root/parse-xml.c
diff options
context:
space:
mode:
authorGravatar Dirk Hohndel <dirk@hohndel.org>2014-06-11 19:02:20 -0700
committerGravatar Dirk Hohndel <dirk@hohndel.org>2014-06-11 19:02:49 -0700
commit0c8dbc2061acc92f674cf53b4fb20fafe8c86a25 (patch)
tree189ee77539b86d30b8a13fdc8334efe97fdcee8d /parse-xml.c
parenta0f5a74847942a7448d8a6aedc6277cf5436c19b (diff)
downloadsubsurface-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.c10
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 */