Annotation of cci/usr/src/man/man3/malloc.3, revision 1.1

1.1     ! root        1: .TH MALLOC 3  "19 January 1983"
        !             2: .UC 4
        !             3: .SH NAME
        !             4: malloc, free, realloc, calloc, alloca \- memory allocator
        !             5: .SH SYNOPSIS
        !             6: .nf
        !             7: .B char *malloc(size)
        !             8: .B unsigned size;
        !             9: .PP
        !            10: .B free(ptr)
        !            11: .B char *ptr;
        !            12: .PP
        !            13: .B char *realloc(ptr, size)
        !            14: .B char *ptr;
        !            15: .B unsigned size;
        !            16: .PP
        !            17: .B char *calloc(nelem, elsize)
        !            18: .B unsigned nelem, elsize;
        !            19: .PP
        !            20: .B char *alloca(size)
        !            21: .B int size;
        !            22: .fi
        !            23: .SH DESCRIPTION
        !            24: .I Malloc
        !            25: and
        !            26: .I free
        !            27: provide a simple general-purpose memory allocation package.
        !            28: .I Malloc
        !            29: returns a pointer to a block of at least
        !            30: .I size
        !            31: bytes beginning on a word boundary.
        !            32: .PP
        !            33: The argument to
        !            34: .I free
        !            35: is a pointer to a block previously allocated by
        !            36: .IR malloc ;
        !            37: this space is made available for further allocation,
        !            38: but its contents are left undisturbed.
        !            39: .PP
        !            40: Needless to say, grave disorder will result if the space assigned by
        !            41: .I malloc
        !            42: is overrun or if some random number is handed to
        !            43: .IR free .
        !            44: .PP
        !            45: .I Malloc
        !            46: maintains multiple lists of free blocks according to size,
        !            47: allocating space from the appropriate list.
        !            48: It calls
        !            49: .I sbrk
        !            50: (see
        !            51: .IR brk (2))
        !            52: to get more memory from the system when there is no
        !            53: suitable space already free.
        !            54: .PP
        !            55: .I Realloc
        !            56: changes the size of the block pointed to by
        !            57: .I ptr
        !            58: to
        !            59: .I size
        !            60: bytes and returns a pointer to the (possibly moved) block.
        !            61: The contents will be unchanged up to the lesser of the new and old sizes.
        !            62: .PP
        !            63: In order to be compatible with older versions,
        !            64: .I realloc
        !            65: also works if
        !            66: .I ptr
        !            67: points to a block freed since the last call of
        !            68: .I malloc, realloc
        !            69: or
        !            70: .IR calloc ;
        !            71: sequences of
        !            72: .I free, malloc
        !            73: and
        !            74: .I realloc
        !            75: were previously used to attempt storage compaction.
        !            76: This procedure is no longer recommended.
        !            77: .PP
        !            78: .I Calloc
        !            79: allocates space for an array of
        !            80: .I nelem
        !            81: elements of size
        !            82: .I elsize.
        !            83: The space is initialized to zeros.
        !            84: .PP
        !            85: .I Alloca
        !            86: allocates 
        !            87: .I size
        !            88: bytes of space in the stack frame of the caller.
        !            89: This temporary space is automatically freed on
        !            90: return.
        !            91: .PP
        !            92: Each of the allocation routines returns a pointer
        !            93: to space suitably aligned (after possible pointer coercion)
        !            94: for storage of any type of object.
        !            95: .SH DIAGNOSTICS
        !            96: .I Malloc, realloc
        !            97: and
        !            98: .I calloc
        !            99: return a null pointer (0) if there is no available memory or if the arena
        !           100: has been detectably corrupted by storing outside the bounds of a block.
        !           101: .I Malloc
        !           102: may be recompiled to check the arena very stringently on every transaction;
        !           103: those sites with a source code license may check the source code to see
        !           104: how this can be done.
        !           105: .SH BUGS
        !           106: When
        !           107: .I realloc
        !           108: returns 0, the block pointed to by
        !           109: .I ptr
        !           110: may be destroyed.
        !           111: .PP
        !           112: .I Alloca
        !           113: is machine dependent; it's use is discouraged.

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.