1CALLOC(3P)                 POSIX Programmer's Manual                CALLOC(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       calloc - a memory allocator
13

SYNOPSIS

15       #include <stdlib.h>
16
17       void *calloc(size_t nelem, size_t elsize);
18
19

DESCRIPTION

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

RETURN VALUE

39       Upon  successful  completion  with both nelem and elsize non-zero, cal‐
40       loc() shall return a pointer to the allocated space. If either nelem or
41       elsize  is 0, then either a null pointer or a unique pointer value that
42       can be successfully passed to free() shall be returned.  Otherwise,  it
43       shall return a null pointer  and set errno to indicate the error.
44

ERRORS

46       The calloc() function shall fail if:
47
48       ENOMEM Insufficient memory is available.
49
50
51       The following sections are informative.
52

EXAMPLES

54       None.
55

APPLICATION USAGE

57       There  is  now  no  requirement  for  the implementation to support the
58       inclusion of <malloc.h>.
59

RATIONALE

61       None.
62

FUTURE DIRECTIONS

64       None.
65

SEE ALSO

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