1.\" Copyright (c) 1980, 1991 Regents of the University of California. 2.\" All rights reserved. 3.\" 4.\" This code is derived from software contributed to Berkeley by 5.\" the American National Standards Committee X3, on Information 6.\" Processing Systems. 7.\" 8.\" %sccs.include.redist.man% 9.\" 10.\" @(#)malloc.3 6.7 (Berkeley) 06/29/91 11.\" 12.Dd 13.Dt MALLOC 3 14.Os BSD 4 15.Sh NAME 16.Nm malloc , 17.Nd general memory allocation function 18.Sh SYNOPSIS 19.Fd #include <stdlib.h> 20.Ft void * 21.Fn malloc "size_t size" 22.Sh DESCRIPTION 23The 24.Fn malloc 25function allocates uninitialized space for an object whose 26size is specified by 27.Fa size . 28The 29.Fn malloc 30function maintains multiple lists of free blocks according to size, allocating 31space from the appropriate list. 32.Pp 33The allocated space is 34suitably aligned (after possible pointer 35coercion) for storage of any type of object. If the space is of 36.Em pagesize 37or larger, the memory returned will be page-aligned. 38.Sh RETURN VALUES 39The 40.Fn malloc 41function returns 42a pointer to the allocated space if successful; otherwise 43a null pointer is returned. 44.Sh SEE ALSO 45.Xr brk 2 , 46.Xr pagesize 2 , 47.Xr free 3 , 48.Xr calloc 3 , 49.Xr alloca 3 , 50.Xr realloc 3 , 51.Xr memory 3 52.Sh STANDARDS 53The 54.Fn malloc 55function conforms to 56.St -ansiC . 57.Sh BUGS 58The current implementation of 59.Xr malloc 60does not always fail gracefully when system 61memory limits are approached. 62It may fail to allocate memory when larger free blocks could be broken 63up, or when limits are exceeded because the size is rounded up. 64It is optimized for sizes that are powers of two. 65