PetscNew — PETSc 3.23.0 documentation

Skip to main content
`Ctrl`+`K`

# PetscNew

Allocates memory of a particular type, zeros the memory! Aligned to `PETSC_MEMALIGN`

## Synopsis

    #include <petscsys.h>
    PetscErrorCode PetscNew(type **result)

Not Collective

## Output Parameter

- result - memory allocated, sized to match pointer `type`

## Developer Note

Calls `PetscCalloc()` with the appropriate memory size obtained from `type`

## See Also

`PetscFree()`, `PetscMalloc()`, `PetscCall()`, `PetscCalloc1()`, `PetscMalloc1()`

## Level

beginner

## Location

include/petscsys.h

## Examples

src/ksp/ksp/tutorials/ex15.c
src/snes/tutorials/ex4.c
src/snes/tutorials/ex15.c
src/ksp/ksp/tutorials/ex42.c
src/tao/constrained/tutorials/tomographyADMM.c
src/sys/tutorials/ex7.c
src/snes/tutorials/ex58.c
src/snes/tutorials/ex48.c
src/snes/tutorials/ex28.c
src/snes/tutorials/ex30.c

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