1MALLOC(3P)                 POSIX Programmer's Manual                MALLOC(3P)
2
3
4

PROLOG

6       This  manual  page is part of the POSIX Programmer's Manual.  The Linux
7       implementation of this interface may differ (consult the  corresponding
8       Linux  manual page for details of Linux behavior), or the interface may
9       not be implemented on Linux.
10

NAME

12       malloc - a memory allocator
13

SYNOPSIS

15       #include <stdlib.h>
16
17       void *malloc(size_t size);
18
19

DESCRIPTION

21       The malloc() function shall allocate unused space for an  object  whose
22       size in bytes is specified by size and whose value is unspecified.
23
24       The  order  and  contiguity of storage allocated by successive calls to
25       malloc() is unspecified. The pointer returned if  the  allocation  suc‐
26       ceeds shall be suitably aligned so that it may be assigned to a pointer
27       to any type of object and then used to access such  an  object  in  the
28       space  allocated  (until the space is explicitly freed or reallocated).
29       Each such allocation shall yield a pointer to an object  disjoint  from
30       any other object. The pointer returned points to the start (lowest byte
31       address) of the allocated space. If the space cannot  be  allocated,  a
32       null  pointer  shall be returned. If the size of the space requested is
33       0, the behavior is implementation-defined: the value returned shall  be
34       either a null pointer or a unique pointer.
35

RETURN VALUE

37       Upon  successful  completion  with  size not equal to 0, malloc() shall
38       return a pointer to the allocated space. If size is 0,  either  a  null
39       pointer  or  a unique pointer that can be successfully passed to free()
40       shall be returned. Otherwise, it shall return a null pointer   and  set
41       errno to indicate the error.
42

ERRORS

44       The malloc() function shall fail if:
45
46       ENOMEM Insufficient storage space is available.
47
48
49       The following sections are informative.
50

EXAMPLES

52       None.
53

APPLICATION USAGE

55       None.
56

RATIONALE

58       None.
59

FUTURE DIRECTIONS

61       None.
62

SEE ALSO

64       calloc(),   free(),   realloc(),   the   Base   Definitions  volume  of
65       IEEE Std 1003.1-2001, <stdlib.h>
66
68       Portions of this text are reprinted and reproduced in  electronic  form
69       from IEEE Std 1003.1, 2003 Edition, Standard for Information Technology
70       -- Portable Operating System Interface (POSIX),  The  Open  Group  Base
71       Specifications  Issue  6,  Copyright  (C) 2001-2003 by the Institute of
72       Electrical and Electronics Engineers, Inc and The Open  Group.  In  the
73       event of any discrepancy between this version and the original IEEE and
74       The Open Group Standard, the original IEEE and The Open Group  Standard
75       is  the  referee document. The original Standard can be obtained online
76       at http://www.opengroup.org/unix/online.html .
77
78
79
80IEEE/The Open Group                  2003                           MALLOC(3P)
Impressum