Originally Posted by ******
Globals are ALWAYS allocated, no matter how often you use them. Locals have memory allocated on, and freed from, the stack as and when (and if) it's needed. What's more, using locals reduces the number of bugs caused by functions accessing the same variables and "pollutes" the global namespace less, making naming collisions less likely. If you really want to statically allocate all your arrays, use static locals rather than full globals.
|
Originally Posted by ******
Locals are always better than globals (you can increase stack space if you need).
|