зеркало из https://github.com/github/ruby.git
avoid large alloca on Complex/Rational calls
* complex.c (parse_comp): replace ALLOCA_N with ALLOCV_N/ALLOCV_END [Bug #9608] * rational.c (read_digits): ditto git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45793 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
Родитель
0989529f88
Коммит
a9befcdb08
|
@ -1,3 +1,9 @@
|
||||||
|
Sat May 3 04:04:16 2014 Eric Wong <e@80x24.org>
|
||||||
|
|
||||||
|
* complex.c (parse_comp): replace ALLOCA_N with ALLOCV_N/ALLOCV_END
|
||||||
|
[Bug #9608]
|
||||||
|
* rational.c (read_digits): ditto
|
||||||
|
|
||||||
Sat May 3 00:06:30 2014 Naohisa Goto <ngotogenome@gmail.com>
|
Sat May 3 00:06:30 2014 Naohisa Goto <ngotogenome@gmail.com>
|
||||||
|
|
||||||
* file.c (HAVE_STRUCT_STATVFS_F_BASETYPE): File::Statfs#fstypename
|
* file.c (HAVE_STRUCT_STATVFS_F_BASETYPE): File::Statfs#fstypename
|
||||||
|
|
23
complex.c
23
complex.c
|
@ -1726,19 +1726,26 @@ parse_comp(const char *s, int strict,
|
||||||
VALUE *num)
|
VALUE *num)
|
||||||
{
|
{
|
||||||
char *buf, *b;
|
char *buf, *b;
|
||||||
|
VALUE tmp;
|
||||||
|
int ret = 1;
|
||||||
|
|
||||||
buf = ALLOCA_N(char, strlen(s) + 1);
|
buf = ALLOCV_N(char, tmp, strlen(s) + 1);
|
||||||
b = buf;
|
b = buf;
|
||||||
|
|
||||||
skip_ws(&s);
|
skip_ws(&s);
|
||||||
if (!read_comp(&s, strict, num, &b))
|
if (!read_comp(&s, strict, num, &b)) {
|
||||||
return 0;
|
ret = 0;
|
||||||
skip_ws(&s);
|
}
|
||||||
|
else {
|
||||||
|
skip_ws(&s);
|
||||||
|
|
||||||
if (strict)
|
if (strict)
|
||||||
if (*s != '\0')
|
if (*s != '\0')
|
||||||
return 0;
|
ret = 0;
|
||||||
return 1;
|
}
|
||||||
|
ALLOCV_END(tmp);
|
||||||
|
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static VALUE
|
static VALUE
|
||||||
|
|
|
@ -2136,13 +2136,14 @@ read_digits(const char **s, int strict,
|
||||||
{
|
{
|
||||||
char *b, *bb;
|
char *b, *bb;
|
||||||
int us = 1, ret = 1;
|
int us = 1, ret = 1;
|
||||||
|
VALUE tmp;
|
||||||
|
|
||||||
if (!isdecimal(**s)) {
|
if (!isdecimal(**s)) {
|
||||||
*num = ZERO;
|
*num = ZERO;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
bb = b = ALLOCA_N(char, strlen(*s) + 1);
|
bb = b = ALLOCV_N(char, tmp, strlen(*s) + 1);
|
||||||
|
|
||||||
while (isdecimal(**s) || **s == '_') {
|
while (isdecimal(**s) || **s == '_') {
|
||||||
if (**s == '_') {
|
if (**s == '_') {
|
||||||
|
@ -2169,6 +2170,7 @@ read_digits(const char **s, int strict,
|
||||||
conv:
|
conv:
|
||||||
*b = '\0';
|
*b = '\0';
|
||||||
*num = rb_cstr_to_inum(bb, 10, 0);
|
*num = rb_cstr_to_inum(bb, 10, 0);
|
||||||
|
ALLOCV_END(tmp);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Загрузка…
Ссылка в новой задаче