MALLOC(3) BSD Programmer's Manual MALLOC(3) NNAAMMEE mmaalllloocc, - general memory allocation function SSYYNNOOPPSSIISS ##iinncclluuddee <> _v_o_i_d _* mmaalllloocc(_s_i_z_e___t _s_i_z_e); DDEESSCCRRIIPPTTIIOONN The mmaalllloocc() function allocates uninitialized space for an object whose size is specified by _s_i_z_e. The mmaalllloocc() 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 _p_a_g_e_s_i_z_e or larger, the memory returned will be page-aligned. RREETTUURRNN VVAALLUUEESS The mmaalllloocc() function returns a pointer to the allocated space if suc- cessful; otherwise a null pointer is returned. SSEEEE AALLSSOO brk(2), pagesize(2), free(3), calloc(3), alloca(3), realloc(3), memory(3) SSTTAANNDDAARRDDSS The mmaalllloocc() function conforms to ANSI C X3.159-1989 (``ANSI C ''). BBUUGGSS 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 be- cause the size is rounded up. It is optimized for sizes that are powers of two. 4th Berkeley Distribution June 4, 1993 1