kmem_zalloc(9F)
NAME
kmem_zalloc − allocate and clear space from kernel free memory
SYNOPSIS
#include <sys/types.h>
#include <sys/kmem.h>
void ∗kmem_zalloc(size_t size, int flags);
ARGUMENTS
size Number of bytes to allocate.
flags Determines if caller may sleep to wait for free space. Possible flags are KM_SLEEP to sleep while waiting for free space, and KM_NOSLEEP to return NULL if space is not available.
INTERFACE LEVEL
Architecture independent level 1 (DDI/DKI).
DESCRIPTION
This function allocates size bytes of storage from kernel free space, clears it, and returns a pointer to the allocated memory. If flags has KM_SLEEP set, the caller may sleep until free space is available. If flags has KM_NOSLEEP set and space is not available, NULL will be returned.
RETURN VALUES
kmem_zalloc() returns NULL if memory cannot be allocated. Otherwise, it returns a pointer to the allocated space.
CONTEXT
kmem_zalloc() can be called from interrupt context only if the KM_NOSLEEP flag is set. It can be called from user context with any valid flags.
SEE ALSO
freerbuf(9F), getrbuf(9F), kmem_alloc(9F), kmem_free(9F)
Writing Device Drivers
WARNINGS
Memory allocated by kmem_zalloc() is not paged. Available memory is therefore limited. Excessive use of this memory is likely to affect overall system performance.
SunOS 5.4 — Last change: 11 Apr 1991