4 ms·
It's quite possible to not use alloca(), but just use C++'s placement new operator to re-use memory already allocated on the stack. I'm not sure if Rust has so
by berkut 12y ago
It's quite possible to not use alloca(), but just use C++'s placement new operator to re-use memory already allocated on the stack.
I'm not sure if Rust has something similar to placement new, but I'm sure custom allocators (for memory arenas) are possible in Rust.
- CyberDildonics 12y agoThat is a valid and useful technique, but being able to dynamically allocate stack memory in the first place is separate from using placement new on stack memory.
- berkut 12y agoOf course, I was just pointing out it's not always necessary to use alloca - I've written a production-level path-tracer without needing to allocate stack memory dynamically.
- steveklabnik 12y agoUser-defined placement new and custom allocators for existing data structures are still being worked on. `box` can do a form of placement new already, and while you can use your own allocator, you can't use it with already-existing types.