Stack or Heap

S

Skarmander

pete said:
I would actually expect VLA's to implemented under the hood,
as a malloc call with a free at the end of the block,
and some kludge to accomodate the sizeof operator.
Unless the platform has the equivalent of alloca(), of course.

Even without it, it is very likely that for local allocations
specialized versions of malloc() will provide some benefit.

S.
 
K

Keith Thompson

pete said:
I would actually expect VLA's to implemented under the hood,
as a malloc call with a free at the end of the block,
and some kludge to accomodate the sizeof operator.

I wouldn't, though it's certainly a possible implementation. I'd
expect VLAs to be implemented on most platforms by extending the
stack, in a manner very similar to allocating an ordinary (fixed-size)
stack frame or calling the non-standard function alloca().
 
J

jacob navia

pete a écrit :
I would actually expect VLA's to implemented under the hood,
as a malloc call with a free at the end of the block,
and some kludge to accomodate the sizeof operator.
lcc-win32 implements it by extending the stack. This is tricky
under windows since if you allocate more than 4096 bytes you
should implement a loop touching each page at least once to make the
stack grow...
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,011
Latest member
AjaUqq1950

Latest Threads

Top