libk  Artifact [cc32756862]

Artifact cc32756862a7a376e969afd5f98e4f3541fb2bc9cbeb0764067d9337b1a4465c:


#include <k/mem.h>
#include <k/core.h>
#include <k/def.h>
#include <k/type.h>

/* free.fn.c - kmfree() "arbitrary free"
 * ~ lexi hale <lexi@hale.su>
 * kmfree() frees memory allocated in any manner.
 * it ignores non-dynamically allocated memory,
 * returning kmcond_unnecessary. to check for
 * success, compare result < kmcond_fail.
 */

kmcond kmfree(kmptr ptr) {
	if (ptr.kind <= kmkind_fail) return kmcond_unnecessary;
	switch (ptr.kind) {
		case kmkind_heap: return kmheapf(ptr.ref);
	}

	return kmcond_unhandled;
}