:orphan:
# MatShellSetContextDestroy
sets the destroy function for a `MATSHELL` shell matrix context 
## Synopsis
```
#include "petscmat.h" 
PetscErrorCode MatShellSetContextDestroy(Mat mat, PetscErrorCode (*f)(void *))
```
Logically Collective


## Input Parameters

- ***mat -*** the shell matrix
- ***f -*** the context destroy function





## Note
If the `MatShell` is never duplicated, the behavior of this function is equivalent
to `MatShellSetOperation`(`Mat`,`MATOP_DESTROY`,f). However, `MatShellSetContextDestroy()`
ensures proper reference counting for the user provided context data in the case that
the `MATSHELL` is duplicated.


## See Also
 [](ch_matrices), `Mat`, `MATSHELL`, `MatCreateShell()`, `MatShellSetContext()`

## Level
advanced

## Location
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/mat/impls/shell/shell.c.html#MatShellSetContextDestroy">src/mat/impls/shell/shell.c</A>

## Implementations

<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/mat/impls/shell/shell.c.html#MatShellSetContextDestroy_Shell(Mat mat, PetscErrorCode (*f)">MatShellSetContextDestroy_Shell(Mat mat, PetscErrorCode (*f) in src/mat/impls/shell/shell.c</A><BR>


---
[Edit on GitLab](https://gitlab.com/petsc/petsc/-/edit/release/src/mat/impls/shell/shell.c)


[Index of all Mat routines](index.md)  
[Table of Contents for all manual pages](/manualpages/index.md)  
[Index of all manual pages](/manualpages/singleindex.md)  
