summaryrefslogtreecommitdiffstats
path: root/save-xml.c
diff options
context:
space:
mode:
authorGravatar Dirk Hohndel <dirk@hohndel.org>2015-05-31 23:12:30 -0700
committerGravatar Dirk Hohndel <dirk@hohndel.org>2015-05-31 23:14:56 -0700
commite84d8624bb1790ae46d3c7a7b642effb9090b65d (patch)
treecc565f9b92c7244f0ff5fb6429b5ce33faf0dab0 /save-xml.c
parent5bbcc7f16ddb1315dbd4a7a43034cddf8c9f2a36 (diff)
downloadsubsurface-e84d8624bb1790ae46d3c7a7b642effb9090b65d.tar.gz
Add strndup.h header so we can use this useful function
It's missing on Windows... we had this helper in liquivision.c but since I used the function in git-access.c I figured I should just turn it into a little helper. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'save-xml.c')
-rw-r--r--save-xml.c5
1 files changed, 2 insertions, 3 deletions
diff --git a/save-xml.c b/save-xml.c
index 15c667d35..173f6a8ec 100644
--- a/save-xml.c
+++ b/save-xml.c
@@ -10,6 +10,7 @@
#include "dive.h"
#include "device.h"
#include "membuffer.h"
+#include "strndup.h"
/*
* We're outputting utf8 in xml.
@@ -45,9 +46,7 @@ static void show_utf8(struct membuffer *b, const char *text, const char *pre, co
return;
while (len && isascii(text[len - 1]) && isspace(text[len - 1]))
len--;
- /* strndup would be easier, but that doesn't appear to exist on Windows / Mac */
- cleaned = strdup(text);
- cleaned[len] = '\0';
+ cleaned = strndup(text, len);
put_string(b, pre);
quote(b, cleaned, is_attribute);
put_string(b, post);