From 0c3593b6573b4186c980fb4ea7635bf95261c749 Mon Sep 17 00:00:00 2001 From: John Hawthorn Date: Wed, 6 Dec 2023 19:29:06 -0800 Subject: [PATCH] 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. --- marshal.c | 2 +- numeric.c | 2 +- vsnprintf.c | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/marshal.c b/marshal.c index a715479ca0..2774db07fd 100644 --- a/marshal.c +++ b/marshal.c @@ -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); } } diff --git a/numeric.c b/numeric.c index 0fd1802601..d56cf18ff2 100644 --- a/numeric.c +++ b/numeric.c @@ -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); diff --git a/vsnprintf.c b/vsnprintf.c index 212bb06c5e..ecd5573dd5 100644 --- a/vsnprintf.c +++ b/vsnprintf.c @@ -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;