From 5b6027e5444dfe6a3d02673770347bb4e7fc0658 Mon Sep 17 00:00:00 2001 From: Xavier Leroy Date: Sun, 24 Jul 2016 18:37:26 +0200 Subject: test/raytracer: use our own strdup(), since this is not a standard function --- test/raytracer/gmllexer.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'test/raytracer') diff --git a/test/raytracer/gmllexer.c b/test/raytracer/gmllexer.c index a8594dd3..befad28d 100644 --- a/test/raytracer/gmllexer.c +++ b/test/raytracer/gmllexer.c @@ -147,6 +147,14 @@ static void get_number(int firstchar) exit(2); } +static char * my_strdup(char * s) +{ + size_t l = strlen(s); + char * t = malloc(l + 1); + if (t != NULL) memcpy(t, s, l + 1); + return t; +} + static void get_string() { int c, pos; @@ -159,7 +167,7 @@ static void get_string() } buffer[pos] = 0; current_lexeme.kind = STRING; - current_lexeme.u.s = strdup(buffer); + current_lexeme.u.s = my_strdup(buffer); return; bad_string: fprintf(stderr, "Illegal string literal\n"); -- cgit