.TH kmem_zalloc() "" "" "DDI/DKI Kernel Routine"
.PC "Allocate space from kernel free memory"
.B "#include <sys/types.h>"
.B "#include <sys/kmem.h>"
\fBvoid *kmem_zalloc(\fIbytes\^\fB, \fIflag\^\fB)\fR
\fBsize_t \fIbytes\^\fB; int \fIflag\^\fB;\fR
.PP
.B kmem_zalloc()
allocates
.I bytes
of kernel memory and initializes them to zero.
.PP
.I flag
indicates whether the driver can sleep while waiting for memory.
.B KM_SLEEP
indicates that the driver will sleep, if necessary,
until the requested amount of memory is available; therefore,
.B kmem_zalloc()
waits until
.I bytes
of memory is available.
.B KM_NOSLEEP
indicates that it will not sleep; therefore,
.B kmem_zalloc()
returns NULL if the requested amount of memory is not available immediately.
.PP
.B kmem_zalloc()
returns a pointer to the newly allocated memory.
If
.I flag
is set to
.B KM_NOSLEEP
and
.I bytes
of memory is not available, it returns NULL.
It always returns NULL if you set
.I bytes
to zero.
.SH "See Also"
.B
DDI/DKI kernel routines,
kmem_alloc(),
kmem_free()
.R
.SH Notes
.B kmem_zalloc()
has base level only if
.I flag
equals
.BR KM_SLEEP ;
it has base or interrupt level if
.I flag
equals
.BR KM_NOSLEEP .
It can sleep if
.I flag
is set to
.BR KM_SLEEP .
.PP
A driver can hold a driver-defined basic lock or read/write lock across
a call to this function if
.I flag
is
.BR KM_NOSLEEP ,
but may not hold it if
.I flag
is
.BR KM_SLEEP .
It can hold a driver-defined sleep lock regardless of the value of
.IR flag .
