Remove bogus stuff about memory leaks - nothing in this testcase leaks.

git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11604 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
Olly Betts 2009-08-17 01:30:42 +00:00
commit c9635d6255
2 changed files with 8 additions and 36 deletions

View file

@ -1,6 +1,6 @@
/* File : example.i */ /* File : example.i */
/* This file has a few "typical" uses of C++ references. */ /* This file shows how to use %extend. */
%module example %module example

View file

@ -25,12 +25,8 @@ print "Adding a+b\n";
$c = example::addv($a, $b); $c = example::addv($a, $b);
print " a+b ={$c->as_string()}\n"; print " a+b ={$c->as_string()}\n";
# Note: Unless we free the result, a memory leak will occur
$c = None;
# ----- Create a vector array ----- # ----- Create a vector array -----
# Note: Using the high-level interface here
print "Creating an array of vectors\n"; print "Creating an array of vectors\n";
$va = new VectorArray(10); $va = new VectorArray(10);
@ -41,37 +37,13 @@ print " va: size={$va->size()}\n";
# These operators copy the value of $a and $b to the vector array # These operators copy the value of $a and $b to the vector array
$va->set(0, $a); $va->set(0, $a);
$va->set(1, $b); $va->set(1, $b);
$va->get(0);
# This will work, but it will cause a memory leak!
$va->set(2, addv($a, $b)); $va->set(2, addv($a, $b));
# The non-leaky way to do it
$c = addv($a,$b);
$va->set(3,$c);
$c = NULL;
# Get some values from the array # Get some values from the array
print "Getting some array values\n"; print "Getting some array values\n";
for ($i = 0; $i < 5; $i++) { for ($i = 0; $i < 5; $i++) {
print "do $i\n"; print " va[$i] = {$va->get($i)->as_string()}\n";
print " va($i) = {$va->get($i)->as_string()}\n";
} }
# Watch under resource meter to check on this
#print "Making sure we don't leak memory.\n";
#for ($i = 0; $i < 1000000; $i++) {
# $c = $va->get($i % 10);
#}
# ----- Clean up -----
print "Cleaning up\n";
# wants fixing FIXME
$va = NULL;
$a = NULL;
$b = NULL;
?> ?>