:orphan:
# PetscMallocSet
Sets the underlying allocation routines used by `PetscMalloc()` and `PetscFree()` 
## Synopsis
```
#include "petscsys.h"   
PetscErrorCode PetscMallocSet(PetscErrorCode (*imalloc)(size_t, PetscBool, int, const char[], const char[], void **), PetscErrorCode (*ifree)(void *, int, const char[], const char[]), PetscErrorCode (*iralloc)(size_t, int, const char[], const char[], void **))
```
Not Collective


## Input Parameters

- ***imalloc -*** the routine that provides the `malloc()` implementation (also provides `calloc()`, which is used depending on the second argument)
- ***ifree -*** the routine that provides the `free()` implementation
- ***iralloc -*** the routine that provides the `realloc()` implementation





## Note
This routine MUST be called before `PetscInitialize()` and may be
called only once.


## See Also
 `PetscMallocClear()`, `PetscInitialize()`, `PetscMalloc()`, `PetscFree()`

## Level
developer

## Location
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/sys/memory/mal.c.html#PetscMallocSet">src/sys/memory/mal.c</A>


---
[Edit on GitLab](https://gitlab.com/petsc/petsc/-/edit/release/src/sys/memory/mal.c)


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