summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorusa <usa@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2009-02-20 14:29:00 +0000
committerusa <usa@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2009-02-20 14:29:00 +0000
commit8563b285fb1bae6a9729a1583f1e6d8b8abf3a1b (patch)
tree0a36ac2cbf0467d1253ad0c8c2df7de1c42a5883
parent09396dcf21d6d769f0537aacce69369132e9a4eb (diff)
* util.c (rv_alloc, freedtoa): use our normal xmalloc()/xfree() because
couldn't free the returned pointer from ruby_dtoa(). * missing/vsnprintf.c (cvt): receive buffer and use/return it instead of returning the pointer returned from BSD__dtoa(). * missing/vsnprintf.c (BSD_vfprintf): pass buf to cvt() as the buffer. [ruby-core:22184] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@22471 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--ChangeLog11
-rw-r--r--missing/vsnprintf.c12
-rw-r--r--util.c15
3 files changed, 21 insertions, 17 deletions
diff --git a/ChangeLog b/ChangeLog
index 8b14190a3f..d02d3b491b 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,14 @@
+Fri Feb 20 23:28:11 2009 NAKAMURA Usaku <usa@ruby-lang.org>
+
+ * util.c (rv_alloc, freedtoa): use our normal xmalloc()/xfree() because
+ couldn't free the returned pointer from ruby_dtoa().
+
+ * missing/vsnprintf.c (cvt): receive buffer and use/return it instead
+ of returning the pointer returned from BSD__dtoa().
+
+ * missing/vsnprintf.c (BSD_vfprintf): pass buf to cvt() as the buffer.
+ [ruby-core:22184]
+
Thu Feb 19 22:59:09 2009 Tanaka Akira <akr@fsij.org>
* ext/socket/ancdata.c (make_io_for_unix_rights): cmsg_len may be
diff --git a/missing/vsnprintf.c b/missing/vsnprintf.c
index ac649a4670..a19ed5c6cc 100644
--- a/missing/vsnprintf.c
+++ b/missing/vsnprintf.c
@@ -494,7 +494,7 @@ BSD__ultoa(register u_long val, char *endp, int base, int octzero, const char *x
#define BUF (MAXEXP+MAXFRACT+1) /* + decimal point */
#define DEFPREC 6
-static char *cvt __P((double, int, int, char *, int *, int, int *));
+static char *cvt __P((double, int, int, char *, int *, int, int *, char *));
static int exponent __P((char *, int, int));
#else /* no FLOATING_POINT */
@@ -783,7 +783,7 @@ fp_begin: _double = va_arg(ap, double);
}
flags |= FPT;
cp = cvt(_double, prec, flags, &softsign,
- &expt, ch, &ndig);
+ &expt, ch, &ndig, buf);
if (ch == 'g' || ch == 'G') {
if (expt <= -4 || (expt > prec && expt > 1))
ch = (ch == 'g') ? 'e' : 'E';
@@ -1076,10 +1076,10 @@ error:
extern char *BSD__dtoa __P((double, int, int, int *, int *, char **));
static char *
-cvt(value, ndigits, flags, sign, decpt, ch, length)
+cvt(value, ndigits, flags, sign, decpt, ch, length, buf)
double value;
int ndigits, flags, *decpt, ch, *length;
- char *sign;
+ char *sign, *buf;
{
int mode, dsgn;
char *digits, *bp, *rve;
@@ -1098,6 +1098,10 @@ cvt(value, ndigits, flags, sign, decpt, ch, length)
*sign = '\000';
}
digits = BSD__dtoa(value, mode, ndigits, decpt, &dsgn, &rve);
+ memcpy(buf, digits, rve - digits);
+ xfree(digits);
+ rve = buf + (rve - digits);
+ digits = buf;
if (flags & ALT) { /* Print trailing zeros */
bp = digits + ndigits;
if (ch == 'f') {
diff --git a/util.c b/util.c
index dc85183b1e..4bc82f6d04 100644
--- a/util.c
+++ b/util.c
@@ -3058,20 +3058,11 @@ static char *dtoa_result;
static char *
rv_alloc(int i)
{
- int j, k, *r;
-
- j = sizeof(ULong);
- for (k = 0;
- sizeof(Bigint) - sizeof(ULong) - sizeof(int) + j <= i;
- j <<= 1)
- k++;
- r = (int*)Balloc(k);
- *r = k;
return
#ifndef MULTIPLE_THREADS
dtoa_result =
#endif
- (char *)(r+1);
+ xmalloc(i);
}
static char *
@@ -3096,9 +3087,7 @@ nrv_alloc(const char *s, char **rve, int n)
static void
freedtoa(char *s)
{
- Bigint *b = (Bigint *)((int *)s - 1);
- b->maxwds = 1 << (b->k = *(int*)b);
- Bfree(b);
+ xfree(s);
}
#endif