-----BEGIN PGP SIGNED MESSAGE-----

Moin,

On Friday 10 December 2004 18:47, Tassilo von Parseval wrote:
> On Fri, Dec 10, 2004 at 02:26:37PM +0100 Tels wrote:
> > -----BEGIN PGP SIGNED MESSAGE-----
[schnipp]

This is just a followup to announce that I finally plugged the leak:

It turned out that the attached routine did leak, too. Devel::Leak always 
showed PVs that looked like '', so the output wasn't very helpfull (because 
the constructed PV was not "complete", e.g. I didnt set the proper length).

The caused memory loss was painfull, and it took quite a while to find out by 
binary searching the changed between versions where the leak exactly is.

However, what ends good is good :) So, thank you again, Tassilo!

If you run some older version of Math::BigInt::GMP, please upgrade to v1.17.

Best wishes,

Tels

Can you spot the leak:

##############################################################################
# _zeros() - return number of trailing zeros (in decimal form)

int
_zeros(Class,n)
        mpz_t*  n

  PREINIT:
    SV* TEMP;
    int len;
    char *buf;
    char *buf_end;

  CODE:
    /* len is always >= 1, and might be off (greater) by one than real len */
    len = mpz_sizeinbase(*n, 10);
    TEMP = newSV(len);                  /* alloc len +1 bytes */
    SvPOK_on(TEMP);                     /* make an PV */
    buf = SvPVX(TEMP);                  /* get ptr to storage */
    buf_end = buf + len - 1;            /* end of storage (-1)*/
    mpz_get_str(buf, 10, *n);           /* convert to decimal string */
    RETVAL = 0;
    if (*buf_end == 0)
      {
      buf_end--;                        /* ptr to last real digit */
      len --;                           /* got one shorter than expected */
      }
    if (len > 1)                        /* '0' has not trailing zeross! */
      {
      while (len-- > 0)
        {
        if (*buf_end-- != '0')
          {
          break;
          }
        RETVAL++;
        }
      }
  OUTPUT:
    RETVAL


- -- 
 Signed on Sat Jan  1 19:10:47 2005 with key 0x93B84C15.
 Visit my photo gallery at http://bloodgate.com/photos/
 PGP key on http://bloodgate.com/tels.asc or per email.

 "Any sufficiently rigged demo is indistinguishable from an advanced
 technology."  -- Don Quixote, slashdot guy

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.4 (GNU/Linux)

iQEVAwUBQdbnwHcLPEOTuEwVAQGl7gf9GHGUMBR6UPKtenKg4j/o8y+pRcaclPgI
7tw91rN78McmK4HDf3gEUXqMWPexBOqGmk3XvEmkh1x93uT+SQWAh3IZlQi5MsPo
SXhSExr1Fz2deFM8xKV8EmpDBCjo6Q4IJ/zSVs+rKljq838N2TcjQTxnL/3AWgbF
S9aMWB08fajVJzJ0iy6zj0Kxl7WfLW/xuhutC5MkD4pyuhPZQslCJcZjd5k2wltB
C+NXB6kPM66mYwBHW+kNNhVj/f/JAEFD+BnVjHzEvDRhuUr7Ahuz1Xprhdk15AfQ
pY8932tcypCAe473/osafHyHupysQVjcautYpgbu4D76zDCAWdopaQ==
=oRTm
-----END PGP SIGNATURE-----

Reply via email to