man.bsd.lv manual page server

Manual Page Search Parameters

MALLOC(3) Library Functions Manual MALLOC(3)

malloc, — general memory allocation function

#include <stdlib.h>

void *
malloc(size_t size);

The () function allocates uninitialized space for an object whose size is specified by size. The malloc() function maintains multiple lists of free blocks according to size, allocating space from the appropriate list.

The allocated space is suitably aligned (after possible pointer coercion) for storage of any type of object. If the space is of or larger, the memory returned will be page-aligned.

The malloc() function returns a pointer to the allocated space if successful; otherwise a null pointer is returned.

brk(2), pagesize(2), free(3), calloc(3), alloca(3), realloc(3), memory(3)

The malloc() function conforms to ANSI X3.159-1989 (“ANSI C89”).

The current implementation of malloc does not always fail gracefully when system memory limits are approached. It may fail to allocate memory when larger free blocks could be broken up, or when limits are exceeded because the size is rounded up. It is optimized for sizes that are powers of two.

BSD 4 June 4, 1993 MALLOC(3)