PetscMalloc#
Allocates memory for use with PETSc. One should use PetscNew()
, PetscMalloc1()
or PetscCalloc1()
usually instead of PetscMalloc()
Synopsis#
#include <petscsys.h>
PetscErrorCode PetscMalloc(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
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 the PetscMallocN()
routines actually call PetscMalloc()
behind the scenes.
Except for data structures that store information about the PETSc options database all memory allocated by PETSc is
obtained with PetscMalloc()
or PetscCalloc()
See Also#
PetscFree()
, PetscNew()
, PetscCalloc()
Level#
beginner
Location#
Examples#
src/ts/utils/dmplexlandau/tutorials/ex2.c
src/ts/tutorials/ex11.c
src/ksp/ksp/tutorials/ex35.cxx
src/ts/tutorials/ex8.c
src/ksp/ksp/tutorials/ex36.cxx
src/ts/utils/dmplexlandau/tutorials/ex1.c
src/tao/tutorials/ex3.c
src/snes/tutorials/ex63.c
src/ts/tutorials/ex11_sa.c
Index of all Sys routines
Table of Contents for all manual pages
Index of all manual pages