On Sat, Feb 19, 2011 at 10:08 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;">
<br>
What about<br>
<br>
extern PetscErrorCode VecDestroy_(Vec);<br>
#define VecDestroy(a) (VecDestroy_(a) || (((a) = 0),0))<br>
<br>
Not exactly PETSc style, but allows the switch without changing the API.</blockquote><div><br></div><div>Why not let VecDestroy_() take the pointer?</div><div><br></div><div>Also, what about having a configure mode that goes back to the old interface (on by default),</div>
<div>but allow the new one to be configured. Might involve putting in #define stuff, or changing</div><div>files a little, but it seems cleaner.</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 class="im"><br>
On Feb 15, 2011, at 4:47 PM, Barry Smith wrote:<br>
<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>
</div><div><div></div><div class="h5">> 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>
</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>