Description

The umem_alloc() function returns a pointer to a block of size bytes suitably aligned for any variable type. The initial contents of memory allocated using umem_alloc() is undefined. The flags argument determines
the behavior of umem_alloc() if it is unable to fulfill the request. The flags argument can take the following values:

UMEM_DEFAULT

Return NULL on failure.

UMEM_NOFAIL

Call an optional callback (set with umem_nofail_callback()) on failure. The callback takes no arguments and can finish by:

returning UMEM_CALLBACK_RETRY, in which case the allocation will be retried. If the allocation fails, the callback will be invoked again.

returning UMEM_CALLBACK_EXIT(status), in which case exit(2) is invoked with status as
its argument. The exit() function is called only once. If multiple threads return from the UMEM_NOFAIL callback with UMEM_CALLBACK_EXIT(status), one will call exit() while the other blocks until
exit() terminates the program.

The umem_zalloc() function has the same semantics as umem_alloc(), but the block of memory is initialized to zeros before it is returned.

The umem_free() function frees blocks previously allocated using umem_alloc() and umem_zalloc(). The buffer address and size must exactly match the original allocation. Memory must not be returned piecemeal.

The umem_nofail_callback() function sets the process-wide UMEM_NOFAIL callback. See the description of UMEM_NOFAIL for more information.

The malloc(), calloc(), free(), memalign(), realloc(), and valloc() functions are as described in malloc(3C). The libumem library provides these functions for backwards-compatibility with the standard functions.

Environment Variables

See umem_debug(3MALLOC) for environment variables that effect the debugging features of the libumem library.

UMEM_OPTIONS

Contains a list of comma-separated options. Unrecognized options are ignored. The options that are supported are:

backend=sbrk

backend=mmap

Set the underlying function used to allocate memory. This option can be set to sbrk (the default) for an sbrk(2)–based
source or mmap for an mmap(2)–based source. If set to a value that is not supported, sbrk will be used.