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:
parent
3e2753ad2e
commit
8a677a6e80
1 changed files with 11 additions and 1 deletions
12
mjit.c
12
mjit.c
|
@ -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
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue