On 15 February 2011 19:47, Barry Smith <bsmith at mcs.anl.gov> wrote:
>
> ?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.
>
> ?In Petsc XXXDestroy() does not pass the pointer (because it seemed too 
> unnatural to me in 1994) thus not allowing 0ing the pointer.
>
> ? Was this a bad design decision? Should it be revisited?
>

This is what I needed in petsc4py, so I had to write my own wrapper
routines: 
http://code.google.com/p/petsc4py/source/browse/src/PETSc/petscobj.pxi#35


> ? Barry
>
> ?Two use cases
>
> 1) error detection when someone tries to reuse a freed object
>
> 2) when removing some objects from a data structure that will be used data 
> one currently needs to do
>
> ?XXXXDestroy(mystruct->something);CHKERRQ(ierr); mystruct->something = 0;
>
> instead of the cleaner XXXDestroy(&mystruct->something);CHKERRQ(ierr);
>

I think (2) is the more compelling use case...



-- 
Lisandro Dalcin
---------------
CIMEC (INTEC/CONICET-UNL)
Predio CONICET-Santa Fe
Colectora RN 168 Km 472, Paraje El Pozo
3000 Santa Fe, Argentina
Tel: +54-342-4511594 (ext 1011)
Tel/Fax: +54-342-4511169

Reply via email to