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:
parent
089b226b80
commit
c9635d6255
2 changed files with 8 additions and 36 deletions
|
|
@ -1,6 +1,6 @@
|
|||
/* File : example.i */
|
||||
|
||||
/* This file has a few "typical" uses of C++ references. */
|
||||
/* This file shows how to use %extend. */
|
||||
|
||||
%module example
|
||||
|
||||
|
|
|
|||
|
|
@ -7,8 +7,8 @@ require "example.php";
|
|||
# ----- Object creation -----
|
||||
|
||||
print "Creating some objects:\n";
|
||||
$a = new Vector(3,4,5);
|
||||
$b = new Vector(10,11,12);
|
||||
$a = new Vector(3, 4, 5);
|
||||
$b = new Vector(10, 11, 12);
|
||||
|
||||
print " Created a: {$a->as_string()}\n";
|
||||
print " Created b: {$b->as_string()}\n";
|
||||
|
|
@ -22,15 +22,11 @@ print " Created b: {$b->as_string()}\n";
|
|||
# It returns a new allocated object.
|
||||
|
||||
print "Adding a+b\n";
|
||||
$c = example::addv($a,$b);
|
||||
$c = example::addv($a, $b);
|
||||
print " a+b ={$c->as_string()}\n";
|
||||
|
||||
# Note: Unless we free the result, a memory leak will occur
|
||||
$c = None;
|
||||
|
||||
# ----- Create a vector array -----
|
||||
|
||||
# Note: Using the high-level interface here
|
||||
print "Creating an array of vectors\n";
|
||||
$va = new VectorArray(10);
|
||||
|
||||
|
|
@ -39,39 +35,15 @@ print " va: size={$va->size()}\n";
|
|||
# ----- Set some values in the array -----
|
||||
|
||||
# These operators copy the value of $a and $b to the vector array
|
||||
$va->set(0,$a);
|
||||
$va->set(1,$b);
|
||||
|
||||
$va->get(0);
|
||||
# This will work, but it will cause a memory leak!
|
||||
|
||||
$va->set(2,addv($a,$b));
|
||||
|
||||
# The non-leaky way to do it
|
||||
|
||||
$c = addv($a,$b);
|
||||
$va->set(3,$c);
|
||||
$c = NULL;
|
||||
$va->set(0, $a);
|
||||
$va->set(1, $b);
|
||||
$va->set(2, addv($a, $b));
|
||||
|
||||
# Get some values from the array
|
||||
|
||||
print "Getting some array values\n";
|
||||
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;
|
||||
|
||||
?>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue