Hello,
For my program, I need to allocate a big (as big as possible, at least 1KB) read-write buffer.
What's the best way to do it? From heap? Stack?
How do I know if I have overflowed the stack?
I have a Duemilanove with 328P.
Thanks!
Hello,
For my program, I need to allocate a big (as big as possible, at least 1KB) read-write buffer.
What's the best way to do it? From heap? Stack?
How do I know if I have overflowed the stack?
I have a Duemilanove with 328P.
Thanks!
You can use malloc(1000) and it will fail gracefully if the storage isn't available.
If it were me i'd just define a global char(or whatever) array and use that. I'd also carefully add up all my ram use and make sure i was well under 2k.
Other than probing with malloc i don't think there's any way to know if your out of memory other than your program behaving oddly.
Thanks for the suggestion!
Turned out I can allocate 1823 bytes with nothing else.
But I guess that would be bad, since stack will eat into the heap, so I think I will still only allocate 1024.
Thanks again!