mirror of https://github.com/mkerrisk/man-pages
Explain what happens for malloc(0), or calloc() where one of the arguments is 0.
Add alloca(3) to SEE ALSO.
This commit is contained in:
parent
db7f6ee12b
commit
840b458135
|
@ -47,12 +47,30 @@ elements of
|
|||
.I size
|
||||
bytes each and returns a pointer to the allocated memory.
|
||||
The memory is set to zero.
|
||||
If
|
||||
.I nmemb
|
||||
or
|
||||
.I size
|
||||
is 0, then
|
||||
.BR calloc ()
|
||||
returns either NULL,
|
||||
.\" glibc does this:
|
||||
or a unique pointer value that can later be successfully passed to
|
||||
.BR free ().
|
||||
.PP
|
||||
.BR malloc ()
|
||||
allocates
|
||||
.I size
|
||||
bytes and returns a pointer to the allocated memory.
|
||||
The memory is not cleared.
|
||||
If
|
||||
.I size
|
||||
is 0, then
|
||||
.BR malloc ()
|
||||
returns either NULL,
|
||||
.\" glibc does this:
|
||||
or a unique pointer value that can later be successfully passed to
|
||||
.BR free ().
|
||||
.PP
|
||||
.BR free ()
|
||||
frees the memory space pointed to by
|
||||
|
@ -63,7 +81,7 @@ which must have been returned by a previous call to
|
|||
or
|
||||
.BR realloc ().
|
||||
Otherwise, or if
|
||||
.BI "free(" "ptr" )
|
||||
.IR free(ptr)
|
||||
has already been called before, undefined behavior occurs.
|
||||
If
|
||||
.I ptr
|
||||
|
@ -85,7 +103,7 @@ if
|
|||
.I size
|
||||
is equal to zero,
|
||||
the call is equivalent to
|
||||
.BI "free(" "ptr" ) .
|
||||
.IR free(ptr) .
|
||||
Unless
|
||||
.I ptr
|
||||
is NULL, it must have been returned by an earlier call to
|
||||
|
@ -94,7 +112,7 @@ is NULL, it must have been returned by an earlier call to
|
|||
or
|
||||
.BR realloc ().
|
||||
If the area pointed to was moved, a
|
||||
.BI "free(" "ptr" )
|
||||
.IR free(ptr)
|
||||
is done.
|
||||
.SH "RETURN VALUE"
|
||||
For
|
||||
|
@ -204,4 +222,5 @@ and
|
|||
.IR sysctl/vm.txt .
|
||||
.SH "SEE ALSO"
|
||||
.BR brk (2),
|
||||
.BR alloca (3),
|
||||
.BR posix_memalign (3)
|
||||
|
|
Loading…
Reference in New Issue