From: Tels Date: Sat, 3 Mar 2007 17:09:58 +0000 (+0000) Subject: Math::BigInt::FastCalc 0.12 (plug leaks) X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=caa6400115a38c0669db5e1b28eaa0eb8d1aad26;p=p5sagit%2Fp5-mst-13.2.git Math::BigInt::FastCalc 0.12 (plug leaks) Message-Id: <200703031710.00203@bloodgate.com> p4raw-id: //depot/perl@30454 --- diff --git a/MANIFEST b/MANIFEST index 02a5fb5..ae6cedc 100644 --- a/MANIFEST +++ b/MANIFEST @@ -883,6 +883,7 @@ ext/Math/BigInt/FastCalc/Makefile.PL Math::BigInt::FastCalc extension ext/Math/BigInt/FastCalc/t/bigintfc.t Math::BigInt::FastCalc extension ext/Math/BigInt/FastCalc/t/bootstrap.t Math::BigInt::FastCalc extension ext/Math/BigInt/FastCalc/t/mbi_rand.t Math::BigInt::FastCalc extension +ext/Math/BigInt/FastCalc/t/leak.t test for memory leaks in Math::BigInt::FastCalc ext/MIME/Base64/Base64.pm MIME::Base64 extension ext/MIME/Base64/Base64.xs MIME::Base64 extension ext/MIME/Base64/Changes MIME::Base64 extension diff --git a/ext/Math/BigInt/FastCalc/FastCalc.pm b/ext/Math/BigInt/FastCalc/FastCalc.pm index e49f64e..23b9645 100644 --- a/ext/Math/BigInt/FastCalc/FastCalc.pm +++ b/ext/Math/BigInt/FastCalc/FastCalc.pm @@ -1,6 +1,6 @@ package Math::BigInt::FastCalc; -use 5.005; +use 5.006002; use strict; # use warnings; # dont use warnings for older Perls @@ -11,7 +11,7 @@ use vars qw/@ISA $VERSION $BASE $BASE_LEN/; @ISA = qw(DynaLoader); -$VERSION = '0.11'; +$VERSION = '0.12'; bootstrap Math::BigInt::FastCalc $VERSION; diff --git a/ext/Math/BigInt/FastCalc/FastCalc.xs b/ext/Math/BigInt/FastCalc/FastCalc.xs index f990171..152eb0b 100644 --- a/ext/Math/BigInt/FastCalc/FastCalc.xs +++ b/ext/Math/BigInt/FastCalc/FastCalc.xs @@ -230,51 +230,44 @@ _num(class,x) ############################################################################## -void -_zero(class) - INIT: - AV* a; +#define CONSTANT_OBJ(int) \ + RETVAL = newAV(); \ + sv_2mortal((SV*)RETVAL); \ + av_push (RETVAL, newSViv( int )); +AV * +_zero(class) CODE: - a = newAV(); - av_push (a, newSViv( 0 )); /* zero */ - ST(0) = newRV_noinc((SV*) a); + CONSTANT_OBJ(0) + OUTPUT: + RETVAL ############################################################################## -void +AV * _one(class) - INIT: - AV* a; - CODE: - a = newAV(); - av_push (a, newSViv( 1 )); /* one */ - ST(0) = newRV_noinc((SV*) a); + CONSTANT_OBJ(1) + OUTPUT: + RETVAL ############################################################################## -void +AV * _two(class) - INIT: - AV* a; - CODE: - a = newAV(); - av_push (a, newSViv( 2 )); /* two */ - ST(0) = newRV_noinc((SV*) a); + CONSTANT_OBJ(2) + OUTPUT: + RETVAL ############################################################################## -void +AV * _ten(class) - INIT: - AV* a; - CODE: - a = newAV(); - av_push (a, newSViv( 10 )); /* ten */ - ST(0) = newRV_noinc((SV*) a); + CONSTANT_OBJ(10) + OUTPUT: + RETVAL ############################################################################## @@ -388,15 +381,15 @@ _len(class,x) INIT: AV* a; SV* temp; - IV elems; + NV elems; STRLEN len; CODE: a = (AV*)SvRV(x); /* ref to aray, don't check ref */ - elems = av_len(a); /* number of elems in array */ + elems = (NV) av_len(a); /* number of elems in array */ temp = *av_fetch(a, elems, 0); /* fetch last element */ SvPV(temp, len); /* convert to string & store length */ - len += (IV) XS_BASE_LEN * elems; + len += XS_BASE_LEN * elems; ST(0) = newSViv(len); ##############################################################################