Artifact 70c3679214a698187a81d37aaa7b9e4a88a8afa860a52a134f6bb1c388d3132d:
- File mod/kmem/heapo.fn.c — part of check-in [709ffb094d] at 2019-08-22 04:31:43 on branch trunk — finish moving heap allocation/free functions to the posix syscall apparatus and deprecate the direct assembly implementations of platform_mmap; update the kmem docs to match new function signatures (and remove typos) (user: lexi, size: 496) [annotate] [blame] [check-ins using]
#include <k/core.h>
#include <k/mem.h>
/* heapo.fn.c - kmheapo() "allocate heap object"
* ~ lexi hale <lexi@hale.su>
* kmheapo() allocates a region in heap memory
* and returns a kmptr struct referencing that
* newly allocated region.
*/
kmcond kmheapo(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;
}