Browse Source

consictently use .Dv NULL and a few other tweaks; ok schwarze@

OPENBSD_6_2
otto 7 years ago
parent
commit
6746db08da
1 changed files with 17 additions and 20 deletions
  1. +17
    -20
      src/lib/libc/stdlib/malloc.3

+ 17
- 20
src/lib/libc/stdlib/malloc.3 View File

@ -30,9 +30,9 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE. .\" SUCH DAMAGE.
.\" .\"
.\" $OpenBSD: malloc.3,v 1.112 2017/04/13 18:32:55 otto Exp $
.\" $OpenBSD: malloc.3,v 1.113 2017/04/17 18:07:15 otto Exp $
.\" .\"
.Dd $Mdocdate: April 13 2017 $
.Dd $Mdocdate: April 17 2017 $
.Dt MALLOC 3 .Dt MALLOC 3
.Os .Os
.Sh NAME .Sh NAME
@ -76,8 +76,8 @@ function allocates uninitialized space for an object of
the specified the specified
.Fa size . .Fa size .
.Fn malloc .Fn malloc
maintains multiple lists of free blocks according to size, allocating
space from the appropriate list.
maintains multiple lists of free objects according to size, allocating
from the appropriate list or requesting memory from the kernel.
The allocated space is suitably aligned (after possible pointer coercion) for The allocated space is suitably aligned (after possible pointer coercion) for
storage of any type of object. storage of any type of object.
.Pp .Pp
@ -128,9 +128,9 @@ allocation or, when appropriate, to be returned to the kernel using
.Xr munmap 2 . .Xr munmap 2 .
If If
.Fa ptr .Fa ptr
is a
.Dv NULL
pointer, no action occurs.
is
.Dv NULL ,
no action occurs.
If If
.Fa ptr .Fa ptr
was previously freed by was previously freed by
@ -158,7 +158,7 @@ the
function is similar to function is similar to
.Fn reallocarray .Fn reallocarray
except it ensures newly allocated memory is cleared similar to except it ensures newly allocated memory is cleared similar to
.Xr calloc 3 .
.Fn calloc .
Memory that becomes unallocated while shrinking or moving existing Memory that becomes unallocated while shrinking or moving existing
allocations is explicitly discarded (meaning, pages of memory allocations is explicitly discarded (meaning, pages of memory
are disposed via are disposed via
@ -167,17 +167,15 @@ and smaller allocations are cleared with
.Xr explicit_bzero 3 ) . .Xr explicit_bzero 3 ) .
If If
.Fa ptr .Fa ptr
is a
.Dv NULL
pointer,
is
.Dv NULL ,
.Fa oldnmemb .Fa oldnmemb
is ignored and the call is equivalent to is ignored and the call is equivalent to
.Fn calloc . .Fn calloc .
If If
.Fa ptr .Fa ptr
is not a
.Dv NULL
pointer,
is not
.Dv NULL ,
.Fa oldnmemb .Fa oldnmemb
must be a value such that must be a value such that
.Fa oldnmemb .Fa oldnmemb
@ -214,9 +212,9 @@ with length
is discarded while deallocating the whole object originally allocated. is discarded while deallocating the whole object originally allocated.
.Sh RETURN VALUES .Sh RETURN VALUES
Upon successful completion, the allocation functions Upon successful completion, the allocation functions
return a pointer to the allocated space; otherwise, a
return a pointer to the allocated space; otherwise,
.Dv NULL .Dv NULL
pointer is returned and
is returned and
.Va errno .Va errno
is set to is set to
.Er ENOMEM . .Er ENOMEM .
@ -249,7 +247,9 @@ to
.Pp .Pp
If If
.Fa ptr .Fa ptr
is not NULL and multiplying
is not
.Dv NULL
and multiplying
.Fa oldnmemb .Fa oldnmemb
and and
.Fa size .Fa size
@ -444,9 +444,6 @@ If the
option is specified it is an error for the allocation functions option is specified it is an error for the allocation functions
to return to return
.Dv NULL . .Dv NULL .
.It Dq malloc init mmap failed
This is a rather weird condition that is most likely to indicate a
seriously overloaded system or a ulimit restriction.
.It Dq bogus pointer (double free?) .It Dq bogus pointer (double free?)
An attempt to An attempt to
.Fn free .Fn free


Loading…
Cancel
Save