Your "fun" function assisns to *pLSPoints. The pLSPoints parameter is an output of the function. Therefore, you need to call LSPoints->Delete() *before* calling fun in the calling function...<div><br></div><div>
<br><div class="gmail_quote">2008/12/23 chensiqi <span dir="ltr"><<a href="mailto:pidanchen@hotmail.com">pidanchen@hotmail.com</a>></span><br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<div>
Hi, vtkers.<br>
<br>
I have a question regarding pointer new and delete. Here is the code<br>
<br>
main(){<br>
....<br>
vtkPoints *LSPoints = vtkPoints::New();<br> fun ( LSV, &LSPoints );<br>
std::cout<< LSPoints->GetNumberOfPoints()<<std::endl;.......................................(1)<br>
....<br>
LSPoints->Delete();<br>
}<br>
<br>
fun( vtkImage LSV, vtkPoints **pLSPoints )<br>
{<br>
vtkContourFilter *LSFilter = vtkContourFilter::New();<br> LSFilter->SetInput( vtkLSV );<br> LSFilter->SetValue( 0, 0 ); <br> LSFilter->Update();<br>
*pLSPoints = LSFilter->GetOutput()->GetPoints(); <br>
std::cout<< (*pLSPoints)->GetNumberOfPoints()<<std::endl;.................................(2)<br> LSFilter->Delete();<br>
}<br>
<br>
The output at position 2 is correct where as the output at position 1 is destroyed. <br>
If I comment "LSfilter->Delete()", then the output at both locations are correct. But I think I need to release the memory of LSFilter here.<br>
<br>
pls point out where I am wrong.<br>
<br>
Thanks for any input.<br>
Siqi<br>
<br>
<br>
<br>
<br><br><hr>更多热辣资讯尽在新版MSN首页! <a href="http://cn.msn.com/" target="_blank">立刻访问!</a></div>
<br>_______________________________________________<br>
This is the private VTK discussion list.<br>
Please keep messages on-topic. Check the FAQ at: <a href="http://www.vtk.org/Wiki/VTK_FAQ" target="_blank">http://www.vtk.org/Wiki/VTK_FAQ</a><br>
Follow this link to subscribe/unsubscribe:<br>
<a href="http://www.vtk.org/mailman/listinfo/vtkusers" target="_blank">http://www.vtk.org/mailman/listinfo/vtkusers</a><br>
<br></blockquote></div><br></div>