Hi Ahmad,<br /><br />
here is an example which is trying to show what happens using a vtkSmartPointer. Notes are in the comments.<br /><br />

<pre>#<span style=' color: Blue;'>include</span> &lt;vtkSmartPointer.h&gt;
#<span style=' color: Blue;'>include</span> &lt;vtkDoubleArray.h&gt;

<span style=' color: Blue;'>#define</span> PI <span style=' color: Maroon;'>3</span><span style=' color: Maroon;'>.14159</span>
   
   <span style=' color: Blue;'>void</span> myConsumerFunction(vtkDoubleArray* doubleArray) {
      <span style=' color: Green;'>// use your doubleArray or change it</span>
      <span style=' color: Green;'>// but don't use malloc or free on the array!</span>
   }


   <span style=' color: Blue;'>void</span> myProducerFunction() {
      <span style=' color: Blue;'>const</span> <span style=' color: Blue;'>int</span> numberOfValues = <span style=' color: Maroon;'>360</span>;
      vtkSmartPointer&lt;vtkDoubleArray&gt; myDoubleArray = vtkSmartPointer&lt;vtkDoubleArray&gt;::New();
      myDoubleArray-&gt;SetNumberOfComponents(<span style=' color: Maroon;'>1</span>);
      myDoubleArray-&gt;SetNumberOfTuples(numberOfValues);
      <span style=' color: Green;'>// fill array</span>
      <span style=' color: Blue;'>for</span>(<span style=' color: Blue;'>int</span> i = <span style=' color: Maroon;'>0</span>; i &lt; numberOfValues; i++)
         myDoubleArray-&gt;SetTuple1(i, sin(i/<span style=' color: Maroon;'>180</span>.*PI));
      myConsumerFunction(myDoubleArray);
   }



   <span style=' color: Blue;'>int</span> main(<span style=' color: Blue;'>int</span>, <span style=' color: Blue;'>char</span>*[])
   {
      myProducerFunction();
      <span style=' color: Green;'>// immediately after myProducerFunction() has returned</span>
      <span style=' color: Green;'>// myDoubleArray is out of scope and is being deleted automatically.</span>
      <span style=' color: Green;'>// There's no need to delete myDoubleArray explicitely anymore</span>
      <span style=' color: Green;'>//...</span>
      <span style=' color: Green;'>// more function calls</span>
      <span style=' color: Green;'>// ...</span>
      <span style=' color: Blue;'>return</span> EXIT_SUCCESS;
   }
</pre><br /><br />
with kind regards<br />
Jochen

        
<br/><hr align="left" width="300" />
View this message in context: <a href="http://vtk.1045678.n5.nabble.com/Unhandled-exception-at-the-time-of-Unregistering-vtkSmartPointer-tp5713691p5713775.html">Re: Unhandled exception at the time of Unregistering vtkSmartPointer</a><br/>
Sent from the <a href="http://vtk.1045678.n5.nabble.com/VTK-Users-f1224199.html">VTK - Users mailing list archive</a> at Nabble.com.<br/>