summaryrefslogtreecommitdiff
path: root/out_str.c
diff options
context:
space:
mode:
authorzimmerma <zimmerma@280ebfd0-de03-0410-8827-d642c229c3f4>2001-02-18 12:12:21 +0000
committerzimmerma <zimmerma@280ebfd0-de03-0410-8827-d642c229c3f4>2001-02-18 12:12:21 +0000
commit9885105786ab8a968511c8ed077b6dff137506ba (patch)
tree2d1d9865dc02782675aa750f9d078fe5f383eaee /out_str.c
parent017d73c4dc7aea0664c4c52d5cfdfe4cfbdd364f (diff)
downloadmpfr-9885105786ab8a968511c8ed077b6dff137506ba.tar.gz
size of freed block by __gmp_free_func was wrong
git-svn-id: svn://scm.gforge.inria.fr/svn/mpfr/trunk@1002 280ebfd0-de03-0410-8827-d642c229c3f4
Diffstat (limited to 'out_str.c')
-rw-r--r--out_str.c16
1 files changed, 10 insertions, 6 deletions
diff --git a/out_str.c b/out_str.c
index 3f7ebbbcb..95c2ac930 100644
--- a/out_str.c
+++ b/out_str.c
@@ -56,16 +56,20 @@ mpfr_out_str (stream, base, n_digits, op, rnd_mode)
s0 = s;
/* for op=3.1416 we have s = "31416" and e = 1 */
- l = strlen(s)+1;
- if (*s == '-') fputc(*s++, stream);
+ l = strlen (s) + 1; /* size of allocated block returned by mpfr_get_str */
+ if (*s == '-')
+ fputc (*s++, stream);
- fputc(*s++, stream); e--; /* writes leading digit */
- fputc('.', stream); /* decimal point */
- fputs(s, stream); /* rest of mantissa */
+ /* outputs mantissa */
+ fputc (*s++, stream); e--; /* leading digit */
+ fputc ('.', stream); /* decimal point */
+ fputs (s, stream); /* rest of mantissa */
+ (*__gmp_free_func) (s0, l);
+
+ /* outputs exponent */
if (e) {
l += fprintf (stream, (base <= 10 ? "e%ld" : "@%ld"), e);
}
- (*__gmp_free_func)(s0, l);
return l;
}