3 ms·
The APIs do tell you how many bytes are actually allocated. For instance, in the following fn allocate(&self, layout: Layout) -> Result<NonNull<[u8]>, Allo
by pitaj 2y ago
The APIs do tell you how many bytes are actually allocated. For instance, in the following
fn allocate(&self, layout: Layout) -> Result<NonNull<[u8]>, AllocError>;
You can get the length of the returned byte slice (`[u8]`) to know how many bytes were actually allocated.
- tialaramex 2y agoThat's the (nightly) Allocator::allocate, but the API we were looking at is (stable) GlobalAlloc::alloc Yes I'm aware that I can ask how long a slice is.
- pitaj 2y agoAh gotcha. Yeah `GlobalAlloc` is known to be non-ideal. Hopefully we can get a better API soon.