Closed
Description
For usability purposes, I'm proposing that the following implementation be added:
unsafe impl<A> AllocRef for &'_ mut A where A: AllocRef {
fn alloc(&mut self, layout: Layout, init: AllocInit) -> Result<MemoryBlock, AllocErr> {
A::alloc(self, layout, init)
}
unsafe fn dealloc(&mut self, ptr: NonNull<u8>, layout: Layout) {
A::dealloc(self, ptr, layout)
}
unsafe fn grow(&mut self, ptr: NonNull<u8>, layout: Layout, new_size: usize, placement: ReallocPlacement, init: AllocInit) -> Result<MemoryBlock, AllocErr> {
A::grow(self,ptr, layout, new_size, placement, init)
}
unsafe fn shrink(&mut self, ptr: NonNull<u8>, layout: Layout, new_size: usize, placement: ReallocPlacement) -> Result<MemoryBlock, AllocErr> {
A::shrink(self, ptr, layout, new_size, placement)
}
}
Without this implementation, I believe it's impossible to implement composable allocators, as I have started doing in this gist: https://gist.github.com/lachlansneff/8f59278bccb82ec5b36c359f385b7e3f.
Metadata
Metadata
Assignees
Labels
No labels