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
11

NAME

13       malloc — a memory allocator
14

SYNOPSIS

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

DESCRIPTION

21       The functionality described on this reference page is aligned with  the
22       ISO C  standard.  Any  conflict between the requirements described here
23       and the ISO C standard is unintentional. This  volume  of  POSIX.1‐2008
24       defers to the ISO C standard.
25
26       The  malloc()  function shall allocate unused space for an object whose
27       size in bytes is specified by size and whose value is unspecified.
28
29       The order and contiguity of storage allocated by  successive  calls  to
30       malloc()  is  unspecified.  The pointer returned if the allocation suc‐
31       ceeds shall be suitably aligned so that it may be assigned to a pointer
32       to  any  type  of  object and then used to access such an object in the
33       space allocated (until the space is explicitly freed  or  reallocated).
34       Each  such  allocation shall yield a pointer to an object disjoint from
35       any other object. The pointer returned points to the start (lowest byte
36       address)  of  the  allocated space. If the space cannot be allocated, a
37       null pointer shall be returned. If the size of the space  requested  is
38       0,  the behavior is implementation-defined: the value returned shall be
39       either a null pointer or a unique pointer.
40

RETURN VALUE

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

ERRORS

49       The malloc() function shall fail if:
50
51       ENOMEM Insufficient storage space is available.
52
53       The following sections are informative.
54

EXAMPLES

56       None.
57

APPLICATION USAGE

59       None.
60

RATIONALE

62       None.
63

FUTURE DIRECTIONS

65       None.
66

SEE ALSO

68       calloc(), free(), getrlimit(), posix_memalign(), realloc()
69
70       The Base Definitions volume of POSIX.1‐2008, <stdlib.h>
71
73       Portions of this text are reprinted and reproduced in  electronic  form
74       from IEEE Std 1003.1, 2013 Edition, Standard for Information Technology
75       -- Portable Operating System Interface (POSIX),  The  Open  Group  Base
76       Specifications Issue 7, Copyright (C) 2013 by the Institute of Electri‐
77       cal and Electronics Engineers,  Inc  and  The  Open  Group.   (This  is
78       POSIX.1-2008  with  the  2013  Technical Corrigendum 1 applied.) In the
79       event of any discrepancy between this version and the original IEEE and
80       The  Open Group Standard, the original IEEE and The Open Group Standard
81       is the referee document. The original Standard can be  obtained  online
82       at http://www.unix.org/online.html .
83
84       Any  typographical  or  formatting  errors that appear in this page are
85       most likely to have been introduced during the conversion of the source
86       files  to  man page format. To report such errors, see https://www.ker
87       nel.org/doc/man-pages/reporting_bugs.html .
88
89
90
91IEEE/The Open Group                  2013                           MALLOC(3P)
Impressum