summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdrian Johnson <ajohnson@redneon.com>2016-10-07 07:38:37 +1030
committerAdrian Johnson <ajohnson@redneon.com>2016-10-07 07:38:37 +1030
commit4790a3663d12cfbbe643023713477204d61b1c4a (patch)
tree64e3fba94ca3ababb5d3998159926c23f71a1df9
parent55f8c6d9f4161f5ee2a11fd068f0ccb25a5b3aed (diff)
strndup is not avuilable with MSVC
-rw-r--r--src/cairo-pdf-interchange.c12
-rw-r--r--test/pdf-tagged-text.c6
2 files changed, 15 insertions, 3 deletions
diff --git a/src/cairo-pdf-interchange.c b/src/cairo-pdf-interchange.c
index fc21b32c2..18dd4d8a8 100644
--- a/src/cairo-pdf-interchange.c
+++ b/src/cairo-pdf-interchange.c
@@ -627,8 +627,16 @@ split_label (const char* label, int *num)
if (i < len)
sscanf (label + i, "%d", num);
- if (i > 0)
- return strndup (label, i);
+ if (i > 0) {
+ char *s;
+ s = _cairo_malloc (i + 1);
+ if (!s)
+ return NULL;
+
+ memcpy (s, label, i);
+ s[i] = 0;
+ return s;
+ }
return NULL;
}
diff --git a/test/pdf-tagged-text.c b/test/pdf-tagged-text.c
index e8484f071..14dbad187 100644
--- a/test/pdf-tagged-text.c
+++ b/test/pdf-tagged-text.c
@@ -134,7 +134,11 @@ layout_paragraph (cairo_t *cr)
cairo_text_extents (cr, begin, &text_extents);
*end = ' ';
if (text_extents.width + 2*MARGIN > PAGE_WIDTH) {
- paragraph_text[paragraph_num_lines++] = strndup (begin, prev_end - begin);
+ int len = prev_end - begin;
+ char *s = malloc (len);
+ memcpy (s, begin, len);
+ s[0] = 0;
+ paragraph_text[paragraph_num_lines++] = s;
begin = prev_end + 1;
}
prev_end = end;