Re: [petsc-dev] XXXDestroy() mistaken design in PETSc
15 Feb
2011
15 Feb
'11
8:03 p.m.
This also applies to PetscFree() On Feb 15, 2011, at 4:47 PM, Barry Smith 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?
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);
5655
Age (days ago)
5655
Last active (days ago)
0 comments
1 participants
participants (1)
-
Barry Smith