Re: [PATCH v7 22/26] rust: alloc: implement `Cmalloc` in module allocator_test

Gary Guo
2024-09-28T19:35:57Z

On Thu, 12 Sep 2024 00:52:58 +0200
Danilo Krummrich <dakr@kernel.org> wrote:

> So far the kernel's `Box` and `Vec` types can't be used by userspace
> test cases, since all users of those types (e.g. `CString`) use kernel
> allocators for instantiation.
>
> In order to allow userspace test cases to make use of such types as
> well, implement the `Cmalloc` allocator within the allocator_test module
> and type alias all kernel allocators to `Cmalloc`. The `Cmalloc`
> allocator uses libc's realloc() function as allocator backend.

I think this needs an explaination of why it needs a complex
implementation instead of just using aligned_alloc and free.

>
> Signed-off-by: Danilo Krummrich <dakr@kernel.org>
> ---
> rust/kernel/alloc/allocator_test.rs | 193 +++++++++++++++++++++++++++-
> 1 file changed, 186 insertions(+), 7 deletions(-)