From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: Kevin Ryde Newsgroups: gmane.lisp.guile.devel Subject: integer-expt dup init/clear Date: Sat, 15 Nov 2003 07:21:35 +1000 Sender: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Message-ID: <87wua27ijk.fsf@zip.com.au> NNTP-Posting-Host: deer.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Trace: sea.gmane.org 1068850602 898 80.91.224.253 (14 Nov 2003 22:56:42 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Fri, 14 Nov 2003 22:56:42 +0000 (UTC) Original-X-From: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Fri Nov 14 23:56:40 2003 Return-path: Original-Received: from monty-python.gnu.org ([199.232.76.173]) by deer.gmane.org with esmtp (Exim 3.35 #1 (Debian)) id 1AKmrn-0005fn-00 for ; Fri, 14 Nov 2003 23:56:39 +0100 Original-Received: from localhost ([127.0.0.1] helo=monty-python.gnu.org) by monty-python.gnu.org with esmtp (Exim 4.24) id 1AKnot-0001Xm-8G for guile-devel@m.gmane.org; Fri, 14 Nov 2003 18:57:43 -0500 Original-Received: from list by monty-python.gnu.org with tmda-scanned (Exim 4.24) id 1AKnmO-0000h7-Ow for guile-devel@gnu.org; Fri, 14 Nov 2003 18:55:08 -0500 Original-Received: from mail by monty-python.gnu.org with spam-scanned (Exim 4.24) id 1AKnln-0000QI-3Y for guile-devel@gnu.org; Fri, 14 Nov 2003 18:55:02 -0500 Original-Received: from [199.232.41.8] (helo=mx20.gnu.org) by monty-python.gnu.org with esmtp (TLSv1:DES-CBC3-SHA:168) (Exim 4.24) id 1AKnlm-0000ON-RW for guile-devel@gnu.org; Fri, 14 Nov 2003 18:54:30 -0500 Original-Received: from [61.8.0.36] (helo=snoopy.pacific.net.au) by mx20.gnu.org with esmtp (Exim 4.24) id 1AKmdx-0005sf-Uw for guile-devel@gnu.org; Fri, 14 Nov 2003 17:42:22 -0500 Original-Received: from mongrel.pacific.net.au (mongrel.pacific.net.au [61.8.0.107]) by snoopy.pacific.net.au (8.12.3/8.12.3/Debian-6.6) with ESMTP id hAEMMJV0015726 for ; Sat, 15 Nov 2003 09:22:19 +1100 Original-Received: from localhost (ppp22.dyn228.pacific.net.au [203.143.228.22]) by mongrel.pacific.net.au (8.12.3/8.12.3/Debian-6.6) with ESMTP id hAEML0DK006450 for ; Sat, 15 Nov 2003 09:21:02 +1100 Original-Received: from gg by localhost with local (Exim 3.35 #1 (Debian)) id 1AKlO2-0004rB-00; Sat, 15 Nov 2003 07:21:50 +1000 Original-To: guile-devel@gnu.org Mail-Copies-To: never User-Agent: Gnus/5.1003 (Gnus v5.10.3) Emacs/21.3 (gnu/linux) X-BeenThere: guile-devel@gnu.org X-Mailman-Version: 2.1.2 Precedence: list List-Id: Developers list for Guile, the GNU extensibility library List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Xref: main.gmane.org gmane.lisp.guile.devel:3026 X-Report-Spam: http://spam.gmane.org/gmane.lisp.guile.devel:3026 --=-=-= A bit of an init/clear gremlin in integer-expt, * numbers.c (scm_integer_expt): Don't mpz_init after scm_i_clonebig or scm_i_mkbig, since they do so already. Don't mpz_clear a bignum SCM, since gc does this. The bad cases are a bignum exponent and a flonum exponent bigger than a fixnum, so (integer-expt 0.5 (ash 1 128)) (gc) (gc) and (integer-expt 0.5 (exact->inexact (ash 1 128))) (gc) (gc) Run under your favourite malloc debugger to see the duplicate mpz_clear free when the gc gets around to releasing z_i2. --=-=-= Content-Disposition: attachment; filename=numbers.c.integer-expt.diff --- numbers.c.~1.206.~ 1970-01-01 10:00:01.000000000 +1000 +++ numbers.c 2003-11-13 11:47:30.000000000 +1000 @@ -1355,7 +1355,6 @@ else if (SCM_BIGP (k)) { z_i2 = scm_i_clonebig (k, 1); - mpz_init_set (SCM_I_BIG_MPZ (z_i2), SCM_I_BIG_MPZ (k)); scm_remember_upto_here_1 (k); i2_is_big = 1; } @@ -1367,7 +1366,7 @@ if ((r > SCM_MOST_POSITIVE_FIXNUM) || (r < SCM_MOST_NEGATIVE_FIXNUM)) { z_i2 = scm_i_mkbig (); - mpz_init_set_d (SCM_I_BIG_MPZ (z_i2), r); + mpz_set_d (SCM_I_BIG_MPZ (z_i2), r); i2_is_big = 1; } else @@ -1389,12 +1388,10 @@ { if (mpz_sgn(SCM_I_BIG_MPZ (z_i2)) == 0) { - mpz_clear (SCM_I_BIG_MPZ (z_i2)); return acc; } if (mpz_cmp_ui(SCM_I_BIG_MPZ (z_i2), 1) == 0) { - mpz_clear (SCM_I_BIG_MPZ (z_i2)); return scm_product (acc, n); } if (mpz_tstbit(SCM_I_BIG_MPZ (z_i2), 0)) --=-=-= Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Guile-devel mailing list Guile-devel@gnu.org http://mail.gnu.org/mailman/listinfo/guile-devel --=-=-=--