Now, I've been thinking about using
alloca()
to allocate stack space. This would ensure that firstly, I don't have to new anything and worry about keeping it around, and secondly, having my shiz on the actual C++ stack would improve memory locality- something I could sure use if I plan on abusing virtual functions like I am. However, there's a problem with this - alloca()
isn't Standard. I really want to keep this Standard.Now, I know that MSVC and GCC both support it, so I won't be doing too much harm to my more common target platforms. But I don't like the idea of depending on platform-specific behaviour in what should be really platform-independent code.
Perhaps you can allocate memory on the stack using a char array and then use placement new to construct objects. A wrapper utility could provide some syntactic sugar to make it appear cleaner.
ReplyDeleteBut I'll only know how much I need at run-time, because it's interpreted.
ReplyDeleteLol, I forgot about that.
ReplyDelete