File mod/kmem/heapao.fn.c artifact e98ef79662 part of check-in e50a476efe
#include <k/core.h> #include <k/mem.h> /* heapao.fn.c - kmheapao() "allocate heap object" * ~ lexi hale <lexi@hale.su> * kmheapao() allocates a region in heap memory * and returns a kmptr struct referencing that * newly allocated region. */ kmcond kmheapao(kmptr* where, sz size) { void* ptr; kmcond e = kmheapa(&ptr, size); if (e != kmcond_ok) return e; kmptr p = { .kind = (ptr != null ? kmkind_heap : kmkind_fail), .ref = ptr, .shred = false, }; *where = p; return kmcond_ok; }