logo

oasis-root

Compiled tree of Oasis Linux based on own branch at <https://hacktivis.me/git/oasis/> git clone https://anongit.hacktivis.me/git/oasis-root.git

calloc.3p (3765B)


  1. '\" et
  2. .TH CALLOC "3P" 2017 "IEEE/The Open Group" "POSIX Programmer's Manual"
  3. .\"
  4. .SH PROLOG
  5. This manual page is part of the POSIX Programmer's Manual.
  6. The Linux implementation of this interface may differ (consult
  7. the corresponding Linux manual page for details of Linux behavior),
  8. or the interface may not be implemented on Linux.
  9. .\"
  10. .SH NAME
  11. calloc
  12. \(em a memory allocator
  13. .SH SYNOPSIS
  14. .LP
  15. .nf
  16. #include <stdlib.h>
  17. .P
  18. void *calloc(size_t \fInelem\fP, size_t \fIelsize\fP);
  19. .fi
  20. .SH DESCRIPTION
  21. The functionality described on this reference page is aligned with the
  22. ISO\ C standard. Any conflict between the requirements described here and the
  23. ISO\ C standard is unintentional. This volume of POSIX.1\(hy2017 defers to the ISO\ C standard.
  24. .P
  25. The
  26. \fIcalloc\fR()
  27. function shall allocate unused space for an array of
  28. .IR nelem
  29. elements each of whose size in bytes is
  30. .IR elsize .
  31. The space shall be initialized to all bits 0.
  32. .P
  33. The order and contiguity of storage allocated by successive calls to
  34. \fIcalloc\fR()
  35. is unspecified. The pointer returned if the allocation succeeds shall
  36. be suitably aligned so that it may be assigned to a pointer to any type
  37. of object and then used to access such an object or an array of such
  38. objects in the space allocated (until the space is explicitly freed or
  39. reallocated). Each such allocation shall yield a pointer to an object
  40. disjoint from any other object. The pointer returned shall point to the
  41. start (lowest byte address) of the allocated space. If the space cannot
  42. be allocated, a null pointer shall be returned. If the size of the
  43. space requested is 0, the behavior is implementation-defined: either a
  44. null pointer shall be returned, or the behavior shall be as if the
  45. size were some non-zero value, except that the behavior is undefined
  46. if the returned pointer is used to access an object.
  47. .SH "RETURN VALUE"
  48. Upon successful completion with both
  49. .IR nelem
  50. and
  51. .IR elsize
  52. non-zero,
  53. \fIcalloc\fR()
  54. shall return a pointer to the allocated space. If either
  55. .IR nelem
  56. or
  57. .IR elsize
  58. is 0, then either:
  59. .IP " *" 4
  60. A null pointer shall be returned
  61. and
  62. .IR errno
  63. may be set to an implementation-defined value,
  64. or
  65. .IP " *" 4
  66. A pointer to the allocated space shall be returned. The application
  67. shall ensure that the pointer is not used to access an object.
  68. .P
  69. Otherwise, it shall return a null pointer
  70. and set
  71. .IR errno
  72. to indicate the error.
  73. .SH ERRORS
  74. The
  75. \fIcalloc\fR()
  76. function shall fail if:
  77. .TP
  78. .BR ENOMEM
  79. Insufficient memory is available.
  80. .LP
  81. .IR "The following sections are informative."
  82. .SH EXAMPLES
  83. None.
  84. .SH "APPLICATION USAGE"
  85. There is now no requirement for the implementation to support the
  86. inclusion of
  87. .IR <malloc.h> .
  88. .SH RATIONALE
  89. None.
  90. .SH "FUTURE DIRECTIONS"
  91. None.
  92. .SH "SEE ALSO"
  93. .IR "\fIfree\fR\^(\|)",
  94. .IR "\fImalloc\fR\^(\|)",
  95. .IR "\fIrealloc\fR\^(\|)"
  96. .P
  97. The Base Definitions volume of POSIX.1\(hy2017,
  98. .IR "\fB<stdlib.h>\fP"
  99. .\"
  100. .SH COPYRIGHT
  101. Portions of this text are reprinted and reproduced in electronic form
  102. from IEEE Std 1003.1-2017, Standard for Information Technology
  103. -- Portable Operating System Interface (POSIX), The Open Group Base
  104. Specifications Issue 7, 2018 Edition,
  105. Copyright (C) 2018 by the Institute of
  106. Electrical and Electronics Engineers, Inc and The Open Group.
  107. In the event of any discrepancy between this version and the original IEEE and
  108. The Open Group Standard, the original IEEE and The Open Group Standard
  109. is the referee document. The original Standard can be obtained online at
  110. http://www.opengroup.org/unix/online.html .
  111. .PP
  112. Any typographical or formatting errors that appear
  113. in this page are most likely
  114. to have been introduced during the conversion of the source files to
  115. man page format. To report such errors, see
  116. https://www.kernel.org/doc/man-pages/reporting_bugs.html .