While studying C++ (and C) I had some particular doubts regarding the working of stack allocation, that I can\'t find a solution to:
Does stack allocation c
Stack allocation is typically done in terms of alloca() or implicitly by the compiler. A well-done alloca() will only require a scant few instructions, and there is no cost (or even a need) to free it when you're done.
You can pass a pointer to memory allocated by alloca() to any other function/method that expects a pointer. You MUST NEVER return a pointer allocated by alloca().
Here are some advantages and disadvantages to using stack allocation.