Quote:
|
Originally Posted by rwaliany
Oh yeah, I couldn't find malloc or calloc, it's driving me crazy, C WITH NO MALLOC AAAAAAAAAAAAH!
|
Ryan,
Just to amplify what Jim said, malloc() is really, really evil for small, embedded systems. It's a better practice to allocate all memory at run time (the stack is a special case) so that you are guaranteed to live (execute) within your means. For many reasons (e.g., fragmentation), memory managment without a real hardware memory managment unit (MMU) is a really tough problem. The size of the stack can be tweaked by initializing the stack to a fixed value (not zero) at runtime (see _startup() in ifi_startup.c), exercising all aspects of your code, and then examining the stack space to see where the "high water mark" is located. If you see that you came really close to using all of the stack space, you can allocate more at run time. Conversely, if you have a bunch of unused stack, you can free up some of that memory for other uses.
-Kevin