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

malloc.3p (3614B)


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