pub struct BuddyAllocator<const N: usize, O: OligarchyCollection, B: BuddyCollection> { /* private fields */ }
Expand description

伙伴分配器。

Implementations

构造分配器。

返回分配器管理的总容量。

返回分配器剩余的空间容量。

运行时初始化。

设置分配器分配的最小阶数和基址。

将一个 ptr 指向的长度为 usize 的内存块转移给分配器。

Safety

调用者需要保证:

  • 这个内存块没有被其他任何对象引用;
  • 这个内存块和已经托管的内存块不重叠。

从分配器夺走一个对齐到 align_order 阶,长度为 size 的内存块。

分配可容纳 T 对象的内存块。

分配符合 layout 布局的内存块。

分配。

如果分配成功,返回一个 (指针, 长度) 二元组。

根据布局回收。

Safety

这个方法认为 ptr 是根据 layout 分配出来的, 因此长度不小于 layout.size() 并且对齐到 self.min_order

回收。

Notice

调用者需要保证 size 对齐了分配器的最小阶数。

Trait Implementations

Formats the value using the given formatter. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.