1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

Workaround missing strndup on Windows

https://ci.appveyor.com/project/ruby/ruby/builds/29230976/job/c910t37313edb97k
This commit is contained in:
Takashi Kokubun 2019-12-01 01:35:30 -08:00
parent 3e2753ad2e
commit 8a677a6e80
No known key found for this signature in database
GPG key ID: 6FFC433B12EE23DD

12
mjit.c
View file

@ -700,6 +700,16 @@ start_worker(void)
return true;
}
// There's no strndup on Windows
static char*
ruby_strndup(char *str, size_t n)
{
char *ret = xmalloc(n + 1);
memcpy(ret, str, n);
ret[n] = '\0';
return ret;
}
// Convert "foo bar" to {"foo", "bar", NULL} array. Caller is responsible for
// freeing a returned buffer and its elements.
static char **
@ -716,7 +726,7 @@ split_flags(char *flags)
}
else {
if (next > flags)
buf[i++] = strndup(flags, next - flags);
buf[i++] = ruby_strndup(flags, next - flags);
next++; // skip space
}
}