<p>Ok these answer my question. Many thanks!</p>
<div class="gmail_quote">On Oct 2, 2011 6:07 PM, &quot;Barry Smith&quot; &lt;<a href="mailto:bsmith@mcs.anl.gov">bsmith@mcs.anl.gov</a>&gt; wrote:<br type="attribution">&gt; <br>&gt; On Oct 2, 2011, at 10:35 AM, Jed Brown wrote:<br>
&gt; <br>&gt;&gt; On Sun, Oct 2, 2011 at 04:46, Dominik Szczerba &lt;<a href="mailto:dominik@itis.ethz.ch">dominik@itis.ethz.ch</a>&gt; wrote:<br>&gt;&gt; if(object)<br>&gt;&gt;   KSP/Mat/Vec/etcDestroy(object)<br>&gt;&gt; <br>
&gt;&gt; Just call KSPDestroy(&amp;ksp);<br>&gt;&gt; <br>&gt;&gt; It doesn&#39;t matter if KSP is NULL or a valid object because this function checks. But note that if you just write<br>&gt;&gt; <br>&gt;&gt; KSP ksp;<br>&gt;&gt; <br>
&gt;&gt; or allocate similarly in part of malloc() --- with no memzero() or similar --- then the value of ksp is undefined.<br>&gt; <br>&gt; <br>&gt;    In other words, if you are sometimes not sure if you will ever create a certain object make sure you initialize it to 0 with<br>
&gt; <br>&gt;    Vec vec = 0;<br>&gt; <br>&gt;     .......<br>&gt; <br>&gt; <br>&gt;     VecDestroy(&amp;vec);<br>&gt; <br>&gt;      .....<br>&gt; <br>&gt; <br>&gt;      Note that we pass &amp;vec as the argument and all the destroys set the value to 0 so it cannot be accidently used again.<br>
&gt; <br>&gt;    Barry<br>&gt; <br>&gt;     <br>&gt; <br></div>