: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
src/mat/impls/shell/shell.c
## Implementations
MatShellSetContextDestroy_Shell(Mat mat, PetscErrorCode (*f) in src/mat/impls/shell/shell.c
---
[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)