---
name: "malloc_zone_malloc"
section: "3"
platform: "macos"
package: "libmalloc"
version: "812.100.31"
release: "macOS 26.5"
platforms: ["macos"]
url: "https://new.carta.tech/malloc_zone_malloc"
---

# malloc\_zone\_malloc(3)

zone-based memory allocation

## NAME

**malloc\_create\_zone**, **malloc\_destroy\_zone**, **malloc\_default\_zone**, **malloc\_zone\_from\_ptr**, **malloc\_zone\_malloc**, **malloc\_zone\_calloc**, **malloc\_zone\_valloc**, **malloc\_zone\_realloc**, **malloc\_zone\_memalign**, **malloc\_zone\_free** – zone-based memory allocation

## SYNOPSIS

**#include \<malloc/malloc.h\>**

*malloc\_zone\_t* *\**\

**malloc\_create\_zone**(*vm\_size\_t start\_size*, *unsigned flags*);

*void*\

**malloc\_destroy\_zone**(*malloc\_zone\_t \*zone*);

*malloc\_zone\_t* *\**\

**malloc\_default\_zone**(*void*);

*malloc\_zone\_t* *\**\

**malloc\_zone\_from\_ptr**(*const void \*ptr*);

*void* *\**\

**malloc\_zone\_malloc**(*malloc\_zone\_t \*zone*, *size\_t size*);

*void* *\**\

**malloc\_zone\_calloc**(*malloc\_zone\_t \*zone*, *size\_t num\_items*, *size\_t size*);

*void* *\**\

**malloc\_zone\_valloc**(*malloc\_zone\_t \*zone*, *size\_t size*);

*void* *\**\

**malloc\_zone\_realloc**(*malloc\_zone\_t \*zone*, *void \*ptr*, *size\_t size*);

*void* *\**\

**malloc\_zone\_memalign**(*malloc\_zone\_t \*zone*, *size\_t alignment*, *size\_t size*);

*void*\

**malloc\_zone\_free**(*malloc\_zone\_t \*zone*, *void \*ptr*);

## DESCRIPTION

The **malloc\_create\_zone**() function creates a malloc zone, advising an initial allocation of *start\_size* bytes, and specifying  *flags* The returned malloc zone can be used to provide custom allocation and  deallocation behavior, and to retrieve additional information about the allocations in that zone. At present there are no client settable flag values recognized by malloc\_create\_zone(), the flags argument should always be passed as zero.

The **malloc\_destroy\_zone**() function deallocates all memory associated with objects in  *zone* as well as  *zone* itself.

The **malloc\_default\_zone**() function returns the default system malloc zone, used by [malloc(3)](/malloc/3.md), and [free(3)](/free/3.md).

The **malloc\_zone\_from\_ptr**() function returns a pointer to the malloc zone which contains *ptr* or NULL, if the pointer does not point to an allocated object in any current malloc zone.

The **malloc\_zone\_malloc**(), **malloc\_zone\_calloc**(), **malloc\_zone\_valloc**(), **malloc\_zone\_realloc**(), **malloc\_zone\_memalign**(), and **malloc\_zone\_free**() perform the same task on *zone* as their non-prefixed variants,  [malloc(3)](/malloc/3.md), [calloc(3)](/calloc/3.md), [valloc(3)](/valloc/3.md), [realloc(3)](/realloc/3.md), [posix\_memalign(3)](/posix_memalign/3.md), and  [free(3)](/free/3.md) perform on the default system malloc zone.

## RETURN VALUES

The  **malloc\_create\_zone**(), **malloc\_default\_zone**(), and **malloc\_zone\_from\_ptr**() functions return a pointer to a malloc\_zone\_t structure, or NULL if there was an error.

The  **malloc\_zone\_malloc**(), **malloc\_zone\_calloc**(), **malloc\_zone\_valloc**(), **malloc\_zone\_realloc**(), and **malloc\_zone\_memalign**() functions return a pointer to allocated memory.  If there is an error, they  return a NULL pointer.  They are not required to set  *errno*.

## SEE ALSO

[malloc(3)](/malloc/3.md), [posix\_memalign(3)](/posix_memalign/3.md)
