== Quote from Andrei Alexandrescu ([email protected])'s article > bearophile wrote: > > Walter Bright: > > > >> A person using alloca is expecting stack allocation, and > >> that it goes away after the function exits. Switching arbitrarily to the > >> gc will not be detected and may hide a programming error (asking for a > >> gigantic piece of memory is not anticipated for alloca, and could be > >> caused by an overflow or logic error in calculating its size). > > > > There's another solution, that I'd like to see more often used in Phobos: > > you can add another function to Phobos, let's call it salloca (safe alloca) that does what Denis Koroskin asks for (it's a very simple function). > Can't be written. Try it. > Andrei
As a side note, my TempAlloc allocator was intended all along to be a safer and more flexible allocation scheme that was almost as efficient as call stack allocation, and does fall back on heap allocation, or creating a new non-contiguous chunk, when it runs out of space. Also, I think I'll be able to fix the GC scanning issue by fiddling with pointer offset info if/when my precise heap scanning patch gets into druntime. If/when TempAlloc can be made both safe and efficient w.r.t. GC scanning, I'd nominate it for inclusion in Phobos.
