.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" 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
.Os
.Sh NAME
the specified
.Fa size .
.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
storage of any type of object.
.Pp
.Xr munmap 2 .
If
.Fa ptr
-is a
-.Dv NULL
-pointer, no action occurs.
+is
+.Dv NULL ,
+no action occurs.
If
.Fa ptr
was previously freed by
function is similar to
.Fn reallocarray
except it ensures newly allocated memory is cleared similar to
-.Xr calloc 3 .
+.Fn calloc .
Memory that becomes unallocated while shrinking or moving existing
allocations is explicitly discarded (meaning, pages of memory
are disposed via
.Xr explicit_bzero 3 ) .
If
.Fa ptr
-is a
-.Dv NULL
-pointer,
+is
+.Dv NULL ,
.Fa oldnmemb
is ignored and the call is equivalent to
.Fn calloc .
If
.Fa ptr
-is not a
-.Dv NULL
-pointer,
+is not
+.Dv NULL ,
.Fa oldnmemb
must be a value such that
.Fa oldnmemb
is discarded while deallocating the whole object originally allocated.
.Sh RETURN VALUES
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
-pointer is returned and
+is returned and
.Va errno
is set to
.Er ENOMEM .
.Pp
If
.Fa ptr
-is not NULL and multiplying
+is not
+.Dv NULL
+and multiplying
.Fa oldnmemb
and
.Fa size
option is specified it is an error for the allocation functions
to return
.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?)
An attempt to
.Fn free