KMEM_ALLOC(9)

NAME
kmem_alloc - allocate kernel wired memory

SYNOPSIS
#include <sys/kmem.h>
void *
kmem_alloc(size_t size, km_flag_t kmflags);

DESCRIPTION
kmem_alloc() allocates kernel wired memory. It takes the following arguments.

size
    Specify the size of allocation in bytes.

kmflags
    Either of the following:
    KM_SLEEP
        Can sleep until enough memory is available.
    KM_NOSLEEP
        Don't sleep. Immediately return NULL if there is not enough memory available.

The contents of allocated memory are uninitialized.

RETURN VALUES
On success, kmem_alloc() returns a pointer to allocated memory. Otherwise, it returns NULL.

SEE ALSO
intro(9), kmem_free(9), kmem_zalloc(9), malloc(9)

CAVEATS
kmem_alloc() can not be used from interrupt context.

SECURITY CONSIDERATION
As the allocated memory is uninitialized, it can contain security-sensitive data left by its previous user. It's the caller's responsibility not to expose it to the world.