Mail Archives: djgpp/1995/06/14/01:35:24
>>>>> "Ron" == Ron Grunwald <RGRUNWAL AT wasp DOT cs DOT cowan DOT edu DOT au> writes:
Ron> Doing around 1/2 million function calls to malloc(), isn't
Ron> that a bit inefficient, considering the enourmous execution
Ron> thread the system has to follow to allocate a single block of
Ron> memory?
Ron> Using the stack might be a much faster method as you only
Ron> need 3 assembly language instructions for the same task.
Ron didn't mention it, but "alloca" is the function to use when you
want to quickly allocate space on the stack. There is no way to free
such space; it is automatically freed on function exit at zero cost.
For very large allocations, you should use malloc since stack space
may be limited (isn't the default stack size something like 256K under
djgpp V2?) Under V2 I've blown the stack with huge alloca's.
-Mat
- Raw text -