Skip to main content
`Ctrl`+`K`

# PetscMallocA

Allocate and optionally clear one or more memory locations, possibly using coalesced malloc

## Synopsis

    #include "petscsys.h"
    PetscErrorCode PetscMallocA(int n, PetscBool clear, int lineno, const char *function, const char *filename, size_t bytes0, void *ptr0, ...)

Not Collective

## Input Parameters

- n - number of objects to allocate (at least 1)

- clear - use `calloc()` to allocate space initialized to zero

- lineno - line number to attribute allocation (typically `__LINE__`)

- function - function to attribute allocation (typically `PETSC_FUNCTION_NAME`)

- filename - file name to attribute allocation (typically `__FILE__`)

- bytes0 - first of `n` object sizes

## Output Parameter

- ptr0 - first of `n` pointers to allocate

## Note

This function is not normally called directly by users, but rather via the macros `PetscMalloc1()`, `PetscMalloc2()`, or `PetscCalloc1()`, etc.

## See Also

`PetscMallocAlign()`, `PetscMallocSet()`, `PetscMalloc1()`, `PetscMalloc2()`, `PetscMalloc3()`, `PetscMalloc4()`, `PetscMalloc5()`, `PetscMalloc6()`, `PetscMalloc7()`, `PetscCalloc1()`, `PetscCalloc2()`, `PetscCalloc3()`, `PetscCalloc4()`, `PetscCalloc5()`, `PetscCalloc6()`, `PetscCalloc7()`, `PetscFreeA()`

## Level

developer

## Location

src/sys/memory/mal.c

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