---
name: "alloc"
section: "3"
platform: "linux"
package: "qmail"
version: "1.06-6.2~deb10u1"
release: "Debian 10 (Buster)"
platforms: ["linux"]
url: "https://new.carta.tech/alloc/3"
---

# alloc(3)

allocate memory

## NAME

alloc - allocate memory

## SYNTAX

**#include \<alloc.h\>**

char \***alloc**(*new*);

void **alloc\_free**(*x*);

void **alloc\_re**(&*x*,*old*,*new*);

char \**x*;\
 unsigned int *old*;\
 unsigned int *new*;

## DESCRIPTION

**alloc** allocates enough space from the heap for *new* bytes of data, adequately aligned for any data type. *new* may be 0. **alloc** returns a pointer to the space. If space is not available, **alloc** returns 0, setting **errno** appropriately.

**alloc\_free** returns space to the heap.

**alloc\_re** expands the space allocated to *x* from *old* bytes to *new* bytes. It allocates new space, copies *old* bytes from the old space to the new space, returns the old space to the heap, and changes *x* to point to the new space. It then returns 1. If space is not available, **alloc\_re** returns 0, leaving the old space alone.

## SEE ALSO

[sbrk(2)](/sbrk/2.md), [malloc(3)](/malloc/3.md), [error(3)](/error/3.md)
