If you must use malloc() on an AVR, you should strongly consider writing
some stub functions that permit your C code to compile on a PC platform
where you can stress test it under observation of serious tools like
Valgrind.
My observation (from watching a few hundred students) is that debugging on
an MCU is so hard that once you have added a few nasty pointer bugs into
your code base, your chances of getting back to a totally reliable piece
of software are not that good.
Also in the code you sent, you did not check the return value from
malloc() for null. On a small-memory platform this kind of check is not
optional.
John Regehr
_______________________________________________
AVR-GCC-list mailing list
[email protected]
http://lists.nongnu.org/mailman/listinfo/avr-gcc-list