PetscCtxDestroyFn#

A prototype of a PetscErrorCode (*)(PetscCtxRt) function that is used to free application contexts

Synopsis#

PETSC_EXTERN_TYPEDEF typedef PetscErrorCode PetscCtxDestroyFn(PetscCtxRt);

Notes#

Used in the prototype of functions such as DMSetApplicationContextDestroy()

The function argument is a PetscCtxRt which is psychologically equivalent to a void ** meaning that this function is called with a pointer to the application context (which is itself a pointer) thus the destroy implementation must first reference the context via, for example, *(AppCtx **)arg. Note that syntactically PetscCtxRt is defined as a void *, this is because C++ does not accept passing a pointer to a pointer to a void** but it does accept passing a pointer to a pointer to void *.

PETSc destroy functions take the address of the context (rather than just the context) so that that the destroy function can “zero the pointer” when appropriate, preventing accidental later use of a dangling pointer.

See Also#

PetscObject, PetscCtxDestroyDefault(), PetscObjectDestroy(), DMSetApplicationContextDestroy()

Level#

intermediate

Location#

include/petscsys.h

Examples#

src/ksp/ksp/tutorials/ex65.c


Index of all Sys routines
Table of Contents for all manual pages
Index of all manual pages