summaryrefslogtreecommitdiffstats
path: root/lib/libc/stdlib/netbsd_strtod.c
diff options
context:
space:
mode:
authortegge <tegge@FreeBSD.org>2001-02-15 22:12:50 +0000
committertegge <tegge@FreeBSD.org>2001-02-15 22:12:50 +0000
commit6a8ad1fd29cf8b7da27cdd40b7f2561db02f67a4 (patch)
tree2289e0be05fa981fe5e3711ecba0e98dc4d4abda /lib/libc/stdlib/netbsd_strtod.c
parent48633da620e77246fedda745c9d5b8d769693b32 (diff)
downloadFreeBSD-src-6a8ad1fd29cf8b7da27cdd40b7f2561db02f67a4.zip
FreeBSD-src-6a8ad1fd29cf8b7da27cdd40b7f2561db02f67a4.tar.gz
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
Diffstat (limited to 'lib/libc/stdlib/netbsd_strtod.c')
-rw-r--r--lib/libc/stdlib/netbsd_strtod.c45
1 files changed, 12 insertions, 33 deletions
diff --git a/lib/libc/stdlib/netbsd_strtod.c b/lib/libc/stdlib/netbsd_strtod.c
index a402b68..b48f827 100644
--- a/lib/libc/stdlib/netbsd_strtod.c
+++ b/lib/libc/stdlib/netbsd_strtod.c
@@ -142,7 +142,7 @@ __RCSID("$NetBSD: strtod.c,v 1.26 1998/02/03 18:44:21 perry Exp $");
#include "memory.h"
#endif
#endif
-char *__dtoa __P((double, int, int, int *, int *, char **));
+char *__dtoa __P((double, int, int, int *, int *, char **, char **));
#ifdef MALLOC
#ifdef KR_headers
@@ -382,8 +382,6 @@ Bigint {
typedef struct Bigint Bigint;
- static Bigint *freelist[Kmax+1];
-
static Bigint *
Balloc
#ifdef KR_headers
@@ -395,15 +393,10 @@ Balloc
int x;
Bigint *rv;
- if ((rv = freelist[k]) != NULL) {
- 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;
}
@@ -416,10 +409,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, \
@@ -1900,10 +1890,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
@@ -1953,15 +1944,6 @@ __dtoa
Bigint *mlo = NULL; /* pacify gcc */
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 */
@@ -2123,11 +2105,8 @@ __dtoa
if (i <= 0)
i = 1;
}
- j = sizeof(ULong);
- for(result_k = 0; sizeof(Bigint) - sizeof(ULong) + 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) {
OpenPOWER on IntegriCloud