diff options
author | Xavier Leroy <xavier.leroy@inria.fr> | 2016-07-24 18:37:26 +0200 |
---|---|---|
committer | Xavier Leroy <xavier.leroy@inria.fr> | 2016-07-24 18:37:26 +0200 |
commit | 5b6027e5444dfe6a3d02673770347bb4e7fc0658 (patch) | |
tree | fe10d57d0184f1d2dba8b674a171ac087bc136e6 /test/raytracer/gmllexer.c | |
parent | 04941b3cb8712cee9c3b0806cfe7aa76287c40e8 (diff) | |
download | compcert-5b6027e5444dfe6a3d02673770347bb4e7fc0658.tar.gz compcert-5b6027e5444dfe6a3d02673770347bb4e7fc0658.zip |
test/raytracer: use our own strdup(), since this is not a standard function
Diffstat (limited to 'test/raytracer/gmllexer.c')
-rw-r--r-- | test/raytracer/gmllexer.c | 10 |
1 files changed, 9 insertions, 1 deletions
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"); |