Kernel/LibC: add free function for FixedWidthAllocator

I have to rework the syscall API and allocators in process. For
now this works well enough :)
This commit is contained in:
Bananymous
2023-05-07 01:21:50 +03:00
parent 890aa9aa15
commit 12e42f40c5
9 changed files with 112 additions and 45 deletions

View File

@@ -79,7 +79,9 @@ void* calloc(size_t nmemb, size_t size)
return ptr;
}
void free(void*)
void free(void* ptr)
{
if (ptr == nullptr)
return;
syscall(SYS_FREE, ptr);
}

View File

@@ -74,6 +74,12 @@ long syscall(long syscall, ...)
ret = Kernel::syscall(SYS_ALLOC, bytes);
break;
}
case SYS_FREE:
{
void* ptr = va_arg(args, void*);
ret = Kernel::syscall(SYS_FREE, ptr);
break;
}
default:
puts("LibC: Unhandeled syscall");
}