fitzgen / bumpalo

A fast bump allocation arena for Rust
https://docs.rs/bumpalo
Apache License 2.0
1.35k stars 110 forks source link

chunk_capacity() does not decrement as expected #185

Closed jgraettinger closed 1 year ago

jgraettinger commented 1 year ago

Documentation for chunk_capacity() says:

Gets the remaining capacity in the current chunk (in bytes).

However:

#[test]
fn test_chunk_capacity() {
    let alloc = bumpalo::Bump::with_capacity(1 << 15);
    assert_eq!(alloc.chunk_capacity(), 36800);

    // Allocation which fits within the current chunk.
    alloc.alloc_str("hello world");

    // Expect chunk capacity is lower than before, because of the allocation.
    assert_ne!(alloc.chunk_capacity(), 36800);
}

Actual output as of release 3.11.0 is:

running 1 test
thread 'test_chunk_capacity' panicked at 'assertion failed: `(left != right)`
  left: `36800`,
 right: `36800`', my_test.rs
msullivan commented 1 year ago

I think #209 fixed this