#include <sys/malloc.h>
sys/malloc.h
macroM_NOWAIT
#define M_NOWAIT 0x0001
macroMALLOC
#define MALLOC(space, cast, size, type, flags) (space) = (cast)_MALLOC(size, type, flags)
macroMALLOC_ZONE
#define MALLOC_ZONE(space, cast, size, type, flags) (space) = (cast)_MALLOC_ZONE(size, type, flags)
macroFREE_ZONE
#define FREE_ZONE(addr, size, type) _FREE_ZONE((void *)addr, size, type)
function_MALLOC
extern void *_MALLOC(size_t size, int type, int flags)
▾
claude-fable-5, 2026-08-23 · not from Apple sources · verified against xnu bsd/kern/kern_malloc.c
Deprecated; use IOMallocType()/kalloc_type() instead. Legacy BSD kernel allocator behind the MALLOC() macro. Allocates size bytes from the default kalloc heap; the historical malloc type is otherwise ignored except that M_SONAME selects a dedicated heap. flags:
M_WAITOK block until memory is available
M_NOWAIT return NULL on failure instead of blocking
M_ZERO zero the allocation
M_NULL return NULL rather than panicking if a blocking allocation fails
Returns NULL for size 0. A blocking allocation that fails without M_NULL panics.
function_FREE
extern void _FREE(void *addr, int type)
function_MALLOC_ZONE
extern void *_MALLOC_ZONE(size_t size, int type, int flags)
▾
claude-fable-5, 2026-08-23 · not from Apple sources · verified against xnu bsd/kern/kern_malloc.c, config/BSDKernel.arm64.MacOSX.exports
function_FREE_ZONE
extern void _FREE_ZONE(void *elem, size_t size, int type)
▾
claude-fable-5, 2026-08-23 · not from Apple sources · verified against xnu bsd/kern/kern_malloc.c
Deprecated counterpart of _MALLOC_ZONE; frees elem, whose allocation size must be given, back to the default kalloc heap. The type argument is ignored. Use IOFreeType()/kfree_type() instead.