Auto-merging (0, 27433) /local/Math-BigInt-FastCalc to /vendor/Math-BigInt-FastCalc (base /vendor/Math-BigInt-FastCalc:27431).
A t/leak.t
U FastCalc.xs
==== Patch <-> level 1
Source: 9c88509d-e914-0410-b01c-b9530614cbfe:/local/Math-BigInt-FastCalc:27433
Target: 9c88509d-e914-0410-b01c-b9530614cbfe:/vendor/Math-BigInt-FastCalc:27431
Log:
r27432@windhund: schwern | 2007-02-20 20:12:29 -0800
Local copy
r27433@windhund: schwern | 2007-02-20 20:46:46 -0800
Fix the memory leak in _zero, _one, _two and _ten. I suspect the whole
module leaks like this.
=== t/leak.t
==================================================================
--- t/leak.t (revision 27431)
+++ t/leak.t (patch - level 1)
@@ -0,0 +1,24 @@
+#!/usr/bin/perl -w
+
+use Test::More tests => 4;
+use strict;
+
+# Test for memory leaks.
+
+package Math::BigInt::FastCalc::LeakCheck;
+use base qw(Math::BigInt::FastCalc);
+
+my $destroyed = 0;
+sub DESTROY { $destroyed++ }
+
+
+package main;
+
+for my $method (qw(_zero _one _two _ten)) {
+ $destroyed = 0;
+ {
+ my $num = Math::BigInt::FastCalc::LeakCheck->$method();
+ bless $num, "Math::BigInt::FastCalc::LeakCheck";
+ }
+ is $destroyed, 1, "$method does not leak memory";
+}
=== FastCalc.xs
==================================================================
--- FastCalc.xs (revision 27431)
+++ FastCalc.xs (patch - level 1)
@@ -230,51 +230,44 @@
##############################################################################
-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
##############################################################################
==== BEGIN SVK PATCH BLOCK ====
Version: svk v2.0.0 (darwin)
eJyNlV9v2zYQwP2sx27AXtlU3ew2ikVKsi0FNZwmdtemTdrGNTYgq6A/51iILLoSbTcri9UO0hX7
HNvLMOxlz/sc28fZSaqHBFuaCIRMmXe/u+Mdj720v9mhst3WpUp1eTDYdZynnghGt6kp1YaEMBI8
VS0Zwwxi1ZAxP1JNmXhjwNWMT9MgnwgvPQKRT6LgGES7TRHXKnHdArHCFlTfEzzJVLvAuyIFUKk0
O5bsGPlwVWrLDHClwLopzKIs4gm6wZqmYaAIylPU5xNI3JRz8e8Sy7V1GcQ8AzfH50grl2cqhlQo
hFEKAfp0gv+KgrTSLgTNFXgYxegYlT0vE9teHGy8zi5IF55aH22dh1J0o9PIWYbakl4YlqiWFPUY
vOON3ChzVSY1ejmElZBi1ZtM4hNXwGsRQiy8HOy6qmE2cYv3KpXKKTxb/PB797Oful/82dM+DF7+
vLuonT3q/9jd/vXZoraz/Ly3vLGzpDuL+Mz/bvlgwZe95Zc7y1dn3WXr1Hu5wK9Fd/nVEtXef73g
H7pPHvTObt2sT7O07kdJfQJpTLS5okwzIH3IhOM84SkQgdOM3GsTczMTaRSITUW5RYY8JWMYYxwk
jzfbUJSJFxx7R0CeeGLkOPejo4cJMlY76ziPUW57BMGx76GFV/NqDUnjE6KGaCHlJxCSe0TfVLKp
T3a6B/3n+9+SN3fvkrfK2Is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