From: Fletcher T. Penney Date: Tue, 4 Jul 2017 13:06:06 +0000 (-0400) Subject: UPDATE: Use custom strdup() replacement X-Git-Tag: 6.1.0^2~7 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=d793043b203728f72ff365fc1901b8138cddb9f0;p=multimarkdown UPDATE: Use custom strdup() replacement --- diff --git a/Sources/libMultiMarkdown/odf.c b/Sources/libMultiMarkdown/odf.c index 59810b2..0a8063a 100644 --- a/Sources/libMultiMarkdown/odf.c +++ b/Sources/libMultiMarkdown/odf.c @@ -74,6 +74,18 @@ #define print_localized(x) mmd_print_localized_char_odf(out, x, scratch) +/// strdup() not available on all platforms +static char * my_strdup(const char * source) { + char * result = malloc(strlen(source) + 1); + + if (result) { + strcpy(result, source); + } + + return result; +} + + void mmd_print_char_odf(DString * out, char c) { switch (c) { case '"': @@ -224,7 +236,7 @@ static char * correct_dimension_units(char *original) { char *result; int i; - result = strdup(original); + result = my_strdup(original); for (i = 0; result[i]; i++) result[i] = tolower(result[i]); @@ -1063,7 +1075,7 @@ void mmd_export_token_odf(DString * out, const char * source, token * t, scratch if (strcmp(temp_char2, "notcited") == 0) { free(temp_char); - temp_char = strdup(""); + temp_char = my_strdup(""); temp_bool = false; } @@ -1074,7 +1086,7 @@ void mmd_export_token_odf(DString * out, const char * source, token * t, scratch } else { // This is the actual citation (e.g. `[#foo]`) // No locator - temp_char = strdup(""); + temp_char = my_strdup(""); } // Classify this use