bumpalo icon indicating copy to clipboard operation
bumpalo copied to clipboard

Allow creation of allocator from slice

Open vinaychandra opened this issue 3 years ago • 1 comments

The current new methods use Global allocator for the allocator to work with. Provide an unsafe way to create a bump allocator which will allow to create the allocator from a slice denoting unused memory.

vinaychandra avatar Mar 07 '21 16:03 vinaychandra

It is a pretty fundamental assumption in this implementation that chunks of memory come from the global allocator, that we can request new chunks as needed, and that we deallocate the chunks when the Bump itself is deallocated.

Changing this assumption would require either dynamic checks or making the whole crate parameterized by another allocator (which would dole out portions of a given slice for your requested feature). The first option is unacceptable. The second is possible, but would require some care and thought, and I'm not totally sure would be worth it or not. I also don't have the cycles to explore the second option right now.

The easiest thing to do for your use case would probably be to write a specialized crate for exactly what you're trying to do (possibly forking/borrowing code from this crate).

fitzgen avatar Mar 08 '21 18:03 fitzgen