guile-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: ratio implementation


From: Rob Browning
Subject: Re: ratio implementation
Date: Fri, 17 Oct 2003 10:04:43 -0500
User-agent: Gnus/5.1002 (Gnus v5.10.2) Emacs/21.3 (gnu/linux)

Marius Vollmer <address@hidden> writes:

> Yes, that's what I was looking for.  I now have in scm_inexact_to_exact
>
>   else if (SCM_REALP (z))
>     {
>       mpq_t frac;
>       SCM q;
>       mpq_init (frac);
>       mpq_set_d (frac, SCM_REAL_VALUE (z));

Do you need a scm_remember_upto_here1(z) here, or is z already
protected?

>       q = scm_make_ratio (scm_i_mpz2num (mpq_numref (frac)),
>                         scm_i_mpz2num (mpq_denref (frac)));

Also, can scm_make_ratio throw?  If so, then I'm wondering if frac
might be a potential memory leak, in which case, one solution would be
to just allocate frac via scm_i_mkbig().

>       mpq_clear (frac);
>       return q;
>     }

-- 
Rob Browning
rlb @defaultvalue.org and @debian.org; previously @cs.utexas.edu
GPG starting 2002-11-03 = 14DD 432F AE39 534D B592  F9A0 25C8 D377 8C7E 73A4




reply via email to

[Prev in Thread] Current Thread [Next in Thread]