🌸

allocator_api

github.compull doc.rust-lang.orgAllocator in std::alloc - RustAn implementation of `Allocator` can allocate, grow, shrink, and deallocate arbitrary blocks of data described via `Layout`.
allocator.rs
unsafe trait Allocator {
    fn allocate(
        &self,
        layout: Layout,
    ) -> Result<NonNull<[u8]>, AllocError>;

    unsafe fn deallocate(
        &self,
        ptr: NonNull<u8>,
        layout: Layout,
    );

    fn allocate_zeroed(...);
    unsafe fn grow(...);
    unsafe fn grow_zeroed(...);
    unsafe fn shrink(...);
}
作成
更新