bump_recycle 0.1.0

Bump allocator that can reuse deallocated memory.
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
use std::alloc::Allocator;
use crate::ReBump;

unsafe impl<Alloc: crate::alloc::Allocator> Allocator for ReBump<Alloc>{
    #[inline(always)]
    fn allocate(&self, layout: std::alloc::Layout)
        -> Result<std::ptr::NonNull<[u8]>, std::alloc::AllocError>
    {
        Self::allocate(self, layout).ok_or(std::alloc::AllocError)
    }

    #[inline(always)]
    unsafe fn deallocate(
        &self, ptr: std::ptr::NonNull<u8>, layout: std::alloc::Layout
    ) {
        unsafe{ Self::deallocate(self, ptr, layout) }
    }
}