From 6a8ad1fd29cf8b7da27cdd40b7f2561db02f67a4 Mon Sep 17 00:00:00 2001 From: tegge Date: Thu, 15 Feb 2001 22:12:50 +0000 Subject: Remove freelists managed by Balloc/Bfree. Change __dtoa to not free the string it allocated the previous time it was called. The caller now frees the string after usage if appropiate. PR: 15070 Reviewed by: deischen --- lib/libc/stdlib/strtod.c | 42 +++++++++++------------------------------- 1 file changed, 11 insertions(+), 31 deletions(-) (limited to 'lib/libc/stdlib/strtod.c') diff --git a/lib/libc/stdlib/strtod.c b/lib/libc/stdlib/strtod.c index 742398e..1ed622c 100644 --- a/lib/libc/stdlib/strtod.c +++ b/lib/libc/stdlib/strtod.c @@ -372,8 +372,6 @@ Bigint { typedef struct Bigint Bigint; - static Bigint *freelist[Kmax+1]; - static Bigint * Balloc #ifdef KR_headers @@ -385,14 +383,10 @@ Balloc int x; Bigint *rv; - if ( (rv = freelist[k]) ) { - freelist[k] = rv->next; - } else { - x = 1 << k; - rv = (Bigint *)malloc(sizeof(Bigint) + (x-1)*sizeof(long)); - rv->k = k; - rv->maxwds = x; - } + x = 1 << k; + rv = (Bigint *)malloc(sizeof(Bigint) + (x-1)*sizeof(long)); + rv->k = k; + rv->maxwds = x; rv->sign = rv->wds = 0; return rv; } @@ -405,10 +399,7 @@ Bfree (Bigint *v) #endif { - if (v) { - v->next = freelist[v->k]; - freelist[v->k] = v; - } + free(v); } #define Bcopy(x,y) memcpy((char *)&x->sign, (char *)&y->sign, \ @@ -1844,10 +1835,11 @@ quorem char * __dtoa #ifdef KR_headers - (d, mode, ndigits, decpt, sign, rve) - double d; int mode, ndigits, *decpt, *sign; char **rve; + (d, mode, ndigits, decpt, sign, rve, resultp) + double d; int mode, ndigits, *decpt, *sign; char **rve, **resultp; #else - (double d, int mode, int ndigits, int *decpt, int *sign, char **rve) + (double d, int mode, int ndigits, int *decpt, int *sign, char **rve, + char **resultp) #endif { /* Arguments ndigits, decpt, sign are similar to those @@ -1895,15 +1887,6 @@ __dtoa Bigint *b, *b1, *delta, *mlo, *mhi, *S; double d2, ds, eps; char *s, *s0; - static Bigint *result; - static int result_k; - - if (result) { - result->k = result_k; - result->maxwds = 1 << result_k; - Bfree(result); - result = 0; - } if (word0(d) & Sign_bit) { /* set sign for everything, including 0's and NaNs */ @@ -2062,11 +2045,8 @@ __dtoa if (i <= 0) i = 1; } - j = sizeof(unsigned long); - for (result_k = 0; sizeof(Bigint) - sizeof(unsigned long) + j < i; - j <<= 1) result_k++; - result = Balloc(result_k); - s = s0 = (char *)result; + *resultp = (char *) malloc(i + 1); + s = s0 = *resultp; if (ilim >= 0 && ilim <= Quick_max && try_quick) { -- cgit v1.1