зеркало из https://github.com/github/ruby.git
Workaround missing strndup on Windows
https://ci.appveyor.com/project/ruby/ruby/builds/29230976/job/c910t37313edb97k
This commit is contained in:
Родитель
3e2753ad2e
Коммит
8a677a6e80
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
|
||||
}
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче