Skip to main content
`Ctrl`+`K`

# PetscCalloc

Allocates a cleared (zeroed) memory region aligned to `PETSC_MEMALIGN`, similar to `PetscMalloc()`

## Synopsis

    #include <petscsys.h>
    PetscErrorCode PetscCalloc(size_t m,void **result)

Not Collective

## Input Parameter

- m - number of bytes to allocate

## Output Parameter

- result - memory allocated

## Notes

Memory is always allocated at least double aligned. This macro is useful in allocating memory pointed by void pointers

It is safe to allocate with an m of 0 and pass the resulting pointer (which may or may not be `NULL`) to `PetscFree()`.

However, the pointer should never be dereferenced or the program will crash.

## Developer Note

All `PetscCallocN()` routines call `PetscCalloc()` behind the scenes.

## See Also

`PetscFree()`, `PetscNew()`, `PetscMalloc()`

## Level

beginner

## Location

include/petscsys.h

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