*** UNIX MANUAL PAGE BROWSER ***

A Nergahak database for man pages research.

Navigation

Directory Browser

1Browse 4.4BSD4.4BSD
1Browse Digital UNIXDigital UNIX 4.0e
1Browse FreeBSDFreeBSD 14.3
1Browse MINIXMINIX 3.4.0rc6-d5e4fc0
1Browse NetBSDNetBSD 10.1
1Browse OpenBSDOpenBSD 7.7
1Browse UNIX v7Version 7 UNIX
1Browse UNIX v10Version 10 UNIX

Manual Page Search

Manual Page Result

0 Command: malloc | Section: 3 | Source: UNIX v10 | File: malloc.3
MALLOC(3) Library Functions Manual MALLOC(3) NAME malloc, free, realloc, calloc, cfree - memory allocator SYNOPSIS char *malloc(size) unsigned size; free(ptr) char *ptr; char *realloc(ptr, size) char *ptr; unsigned size; char *calloc(nelem, elsize) unsigned nelem, elsize; cfree(ptr) char *ptr; DESCRIPTION Malloc and free provide a simple memory allocation package. Malloc re- turns a pointer to a new block of at least size bytes. The block is suitably aligned for storage of any type of object. No two active pointers from malloc will have the same value. The argument to free is a pointer to a block previously allocated by malloc; this space is made available for further allocation. Realloc changes the size of the block pointed to by ptr to size bytes and returns a pointer to the (possibly moved) block. The contents will be unchanged up to the lesser of the new and old sizes. The call real- loc((char*)0, size) means the same as Calloc allocates space for an array of nelem elements of size elsize. The space is initialized to zeros. Cfree frees such a block. SEE ALSO galloc(3), brk(2), pool(3), block(3) DIAGNOSTICS Malloc, realloc and calloc return 0 if there is no available memory or if the arena has been detectably corrupted. BUGS When realloc returns 0, the block pointed to by ptr may have been de- stroyed. User errors can corrupt the storage arena. The most common gaffes are (1) freeing an already freed block, (2) storing beyond the bounds of an allocated block, and (3) freeing data that was not obtained from the allocator. To help find such errors, a diagnosing allocator may be loaded; use flag -ldmalloc of cc(1). An even more stringently checking version may be created by recompilation; see the source. MALLOC(3)

Navigation Options