Properly implement liballoc_free ()

This commit is contained in:
2026-01-16 22:09:16 +01:00
parent ab8093cc6c
commit 9a7dbf0594
12 changed files with 142 additions and 24 deletions

View File

@@ -6,7 +6,7 @@
static int liballoc_mutex;
static uintptr_t liballoc_map_base = PROC_MAP_BASE;
static int mem_rid_base = 10000;
static int mem_rid_base = 1000000;
void liballoc_init (void) { liballoc_mutex = proc_create_resource_mutex (100, RV_PRIVATE); }
@@ -36,7 +36,20 @@ void* liballoc_alloc (int pages) {
return (void*)old_base;
}
int liballoc_free (void* ptr, int pages) { return 0; }
int liballoc_free (void* ptr, int pages) {
int res;
uintptr_t out_paddr;
res = proc_translate_v2p ((uintptr_t)ptr, &out_paddr);
if (res < 0)
return res;
res = proc_unmap ((uintptr_t)ptr, pages);
if (res < 0)
return res;
return proc_mem_unref (out_paddr, pages);
}
/** Durand's Ridiculously Amazing Super Duper Memory functions. */