2 ms·
Yeah, sharing objects on the thread-local stack is definitely a bad idea. But as long as the alloca'd memory is only accessed from within the same thread, it i
by pavlov 17y ago
Yeah, sharing objects on the thread-local stack is definitely a bad idea.
But as long as the alloca'd memory is only accessed from within the same thread, it is -- AFAIK -- safe to call alloca() simultaneously from multiple threads, the same as malloc(). I think that qualifies as thread-safety by the usual definition: i.e. the function doesn't access statics or globals.
(Of course this will vary depending on the CRT. I don't think any UNIXes nowadays ship without threading support in the CRT, but Microsoft Visual C++ used to have separate thread-safe and non-thread-safe C libraries.)