4 ms·
There's several projects that have seen the need to allocate variable length things on the stack, Chromium was one[1]. A quick googling sends me to [2] as well.
by flebron 14y ago
There's several projects that have seen the need to allocate variable length things on the stack, Chromium was one[1]. A quick googling sends me to [2] as well.
I haven't ever found myself in a situation where I _needed_ my stuff to be stack allocated, but then again I've never done really low level programming or embedded code, and I guess it could happen there.
[1] http://src.chromium.org/viewvc/chrome/trunk/src/base/stack_container.h http://src.chromium.org/viewvc/chrome/trunk/src/base/stack_c...
[2] http://home.roadrunner.com/~hinnant/stack_alloc.html http://home.roadrunner.com/~hinnant/stack_alloc.html
- cygx 14y agoThese just allocate a fixed-sized stack buffer and overflow to the heap - no variable-length stack allocation happens.
- flebron 14y agoRight, because alloca is the only thing (as far as I know) that can resize the stack. There is not going to be anything else that does the same thing. The best one can do is those stack allocators which overflow to heap, or an alloca-based stack allocator. There's an interesting discussion[1] at comp.std.c++ about implementing VLAs in C++0x, and the issues with dynamic stack resizing. [1] https://groups.google.com/forum/?fromgroups=#!topic/comp.std.c++/K_4lgA1JYeg https://groups.google.com/forum/?fromgroups=#!topic/comp.std...