зеркало из https://github.com/github/ruby.git
Use free with ruby_dtoa
In ae0ceafb0c0d05cc80623b525070255e3abb34ef ruby_dtoa was switched to use malloc instead of xmalloc, which means that consumers should be using free instead of xfree. Otherwise we will artificially shrink oldmalloc_increase_bytes.
This commit is contained in:
Родитель
5f81f58b26
Коммит
0c3593b657
|
@ -466,7 +466,7 @@ w_float(double d, struct dump_arg *arg)
|
|||
memcpy(buf + len, p, digs);
|
||||
len += digs;
|
||||
}
|
||||
xfree(p);
|
||||
free(p);
|
||||
w_bytes(buf, len, arg);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1078,7 +1078,7 @@ flo_to_s(VALUE flt)
|
|||
s = sign ? rb_usascii_str_new_cstr("-") : rb_usascii_str_new(0, 0);
|
||||
if ((digs = (int)(e - p)) >= (int)sizeof(buf)) digs = (int)sizeof(buf) - 1;
|
||||
memcpy(buf, p, digs);
|
||||
xfree(p);
|
||||
free(p);
|
||||
if (decpt > 0) {
|
||||
if (decpt < digs) {
|
||||
memmove(buf + decpt + 1, buf + decpt, digs - decpt);
|
||||
|
|
|
@ -1255,8 +1255,8 @@ cvt(double value, int ndigits, int flags, char *sign, int *decpt, int ch, int *l
|
|||
}
|
||||
buf[0] = 0; /* rve - digits may be 0 */
|
||||
memcpy(buf, digits, rve - digits);
|
||||
xfree(digits);
|
||||
rve = buf + (rve - digits);
|
||||
free(digits);
|
||||
digits = buf;
|
||||
if (flags & ALT) { /* Print trailing zeros */
|
||||
bp = digits + ndigits;
|
||||
|
|
Загрузка…
Ссылка в новой задаче