Friday, 24 June 2011

Exams over

So then now that my exams are over, it's time to get cracking on some coding. I've decided to drop graphics programming for a while, I tend to take breaks between large code revisions, and I'm going to resume work on the interpreted language that I've been cooking in my huge, incredible brain for a little while.

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.

3 comments:

  1. 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.

    ReplyDelete
  2. But I'll only know how much I need at run-time, because it's interpreted.

    ReplyDelete