-
-
Notifications
You must be signed in to change notification settings - Fork 169
UEFI Allocator: Implement core
s allocator_api
#1632
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
core
s allocator_api
core
s allocator_api
core
s allocator_api
a1fca2f
to
81b2d33
Compare
No need for this so far, but this provides downstream users more flexibility.
81b2d33
to
04e87f7
Compare
uefi/src/allocator.rs
Outdated
#[cfg(feature = "unstable")] | ||
unsafe impl core::alloc::Allocator for Allocator { | ||
fn allocate(&self, layout: Layout) -> Result<NonNull<[u8]>, core::alloc::AllocError> { | ||
let ptr = unsafe { <Allocator as GlobalAlloc>::alloc(self, layout) }; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need to do something here to handle ZSTs? I'm not familiar with the details of the Allocator
trait, but I noticed this in the documentation:
In contrast to
GlobalAlloc
,Allocator
allows zero-sized allocations. If an underlying allocator does not support this (like jemalloc) or responds by returning a null pointer (such aslibc::malloc
), this must be caught by the implementation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I'm just not sure how to handle it :D but I can figure it out, I guess
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice use case but you're right. I added it in a dedicated commit
We used std::alloc::System as template. [0] https://doc.rust-lang.org/src/std/alloc.rs.html#137
Implement the allocator API (of
core
) for the UEFI allocator.Checklist