On Tue, Feb 15, 2011 at 7:58 PM, Barry Smith <span dir="ltr"><<a href="mailto:bsmith@mcs.anl.gov">bsmith@mcs.anl.gov</a>></span> wrote:<br><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<div class="im"><br>
On Feb 15, 2011, at 5:26 PM, Matthew Knepley wrote:<br>
<br>
> On Tue, Feb 15, 2011 at 4:47 PM, Barry Smith <<a href="mailto:bsmith@mcs.anl.gov">bsmith@mcs.anl.gov</a>> wrote:<br>
><br>
> In MPI one calls MPI_Comm_free(&comm) to allow the MPI implementation to set the pointer explicitly to 0 after the object is destroyed.<br>
><br>
> In Petsc XXXDestroy() does not pass the pointer (because it seemed too unnatural to me in 1994) thus not allowing 0ing the pointer.<br>
><br>
> Was this a bad design decision? Should it be revisited?<br>
><br>
> Barry<br>
><br>
> Two use cases<br>
><br>
> 1) error detection when someone tries to reuse a freed object<br>
><br>
> We catch this with other error detection. I do not think we would gain much here.<br>
<br>
</div> No really. If I do MatDestroy(mat); MatMult(mat,x,y); then it is possible that MatMutl() will crash while looking around inside where mat points. If MatDestroy(&mat); zeroed mat then MatMult(mat,x,y) could do the safe test of if (!mat) nice error message.</blockquote>
<div><br></div><div>I agree, but the immediate type test at the start of MatMult() has caught most things for me. I do not consider</div><div>double-free a recoverable error, so a SEGV is alright here as well.</div><div><br>
</div><div> Matt</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;"><font color="#888888"><br>
Barry<br>
</font><div><div></div><div class="h5"><br>
><br>
> 2) when removing some objects from a data structure that will be used data one currently needs to do<br>
><br>
> XXXXDestroy(mystruct->something);CHKERRQ(ierr); mystruct->something = 0;<br>
><br>
> instead of the cleaner XXXDestroy(&mystruct->something);CHKERRQ(ierr);<br>
><br>
> True, but again I do not think the win is large.<br>
><br>
> Matt<br>
><br>
> --<br>
> What most experimenters take for granted before they begin their experiments is infinitely more interesting than any results to which their experiments lead.<br>
> -- Norbert Wiener<br>
<br>
</div></div></blockquote></div><br><br clear="all"><br>-- <br>What most experimenters take for granted before they begin their experiments is infinitely more interesting than any results to which their experiments lead.<br>
-- Norbert Wiener<br>