Reference

memory(3)

memory management functions

NAME

aligned_alloc, alloca, calloc, free, free_sized, free_aligned_sized, malloc, posix_memalign, realloc, reallocf, valloc, mmap, munmap – memory management functions

LIBRARY

Standard C Library (libc, -lc)

SYNOPSIS

#include <stdlib.h>

void *

aligned_alloc(size_t alignment, size_t size);

void *

alloca(size_t size);

void *

calloc(size_t nelem, size_t elsize);

void

free(void *ptr);

void

free_sized(void *ptr, size_t size);

void

free_aligned_sized(void *ptr, size_t alignment, size_t size);

void *

malloc(size_t size);

int

posix_memalign(void **ptr, size_t alignment, size_t size);

void *

realloc(void *ptr, size_t size);

void *

reallocf(void *ptr, size_t size);

void *

valloc(size_t size);

#include <sys/types.h>

#include <sys/mman.h>

void *

mmap(void * addr, size_t len, int prot, int flags, int fd, off_t offset);

int

munmap(void *addr, size_t len);

DESCRIPTION

These functions allocate and free memory for the calling process. They are described in the individual manual pages.

SEE ALSO

mmap(2), aligned_alloc(3), alloca(3), calloc(3), free(3), free_aligned_sized(3), free_sized(3), malloc(3), posix_memalign(3), realloc(3), reallocf(3), valloc(3)

STANDARDS

The calloc(), free(), malloc(), and realloc() functions conform to ISO/IEC 9899:1990 (“ISO C90”).

The mmap(), munmap(), and posix_memalign() functions conform to IEEE Std 1003.1-2001 (“POSIX.1”).

The free_sized() and free_aligned_sized() functions conform to ISO/IEC 9899:2024 (“ISO C23”).

History