fitzgen / bumpalo

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

Add custom allocator support for Bump #115

Closed EliaGeretto closed 3 months ago

EliaGeretto commented 3 years ago

This pull requests adds support for specifying a custom allocator that Bump should use to allocate new chunks. This should provide a reasonable interface for situations in which memory should not be retrieved from the Global allocator and swapping the whole allocator using #[global_allocator] is not possible.

I have taken care to make this compile both with nightly and stable Rust, albeit some nasty generics workarounds were necessary.

This PR should, ideally, solve #100.

EliaGeretto commented 3 years ago

Could you please tell me if you would be willing to merge this and, in that case, provide some comments?

fitzgen commented 3 years ago

Thanks for making this pull request and giving us an idea of what changes are required to support generic backing allocators in bumpalo.

Could you please tell me if you would be willing to merge this and, in that case, provide some comments?

Unlike implementing the allocator API, this support for being parameterized by an allocator is rather invasive with all those cfgs. Therefore, I'd prefer to wait until the allocator API stabilizes -- and bumpalo can always be parameterized by an allocator, rather than only being parameterized in some build configurations -- before adding this support.

EliaGeretto commented 3 years ago

I can understand. I need this for my own project, so I am planning to keep my branch reasonably up-to-date. I will leave the PR here in case someone else needs this functionality.

EliaGeretto commented 3 years ago

I am not sure why, but to compile correctly my code requires at least Rust 1.48.

fitzgen commented 3 months ago

Closing old pull requests.