:orphan: # PetscMalloc1 Allocates an array of memory aligned to `PETSC_MEMALIGN` ## Synopsis ``` #include PetscErrorCode PetscMalloc1(size_t m1,type **r1) ``` Not Collective ## Input Parameter - ***m1 -*** number of elements to allocate (may be zero) ## Output Parameter - ***r1 -*** memory allocated ## Note This uses the sizeof() of the memory type requested to determine the total memory to be allocated, therefore you should not multiply the number of elements requested by the `sizeof()` the type. For example use ```none PetscInt *id; PetscMalloc1(10,&id); ``` not ```none PetscInt *id; PetscMalloc1(10*sizeof(PetscInt),&id); ``` Does not zero the memory allocated, use `PetscCalloc1()` to obtain memory that has been zeroed. ## See Also `PetscFree()`, `PetscNew()`, `PetscMalloc()`, `PetscCalloc1()`, `PetscMalloc2()` ## Level beginner ## Location include/petscsys.h ## Examples src/dm/field/tutorials/ex1.c
src/dm/impls/plex/tutorials/ex10.c
src/dm/impls/plex/tutorials/ex6.c
src/dm/impls/stag/tutorials/ex4.c
src/dm/tutorials/ex20.c
src/dm/tutorials/ex26.c
src/dm/tutorials/ex6.c
src/dm/tutorials/swarm_ex1.c
src/dm/tutorials/swarm_ex3.c
src/ksp/ksp/tutorials/ex13.c
src/ksp/ksp/tutorials/ex21.c
--- [Edit on GitLab](https://gitlab.com/petsc/petsc/-/edit/release/include/petscsys.h) [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)