News for hackers. Stuff that matters.
Re:Rust on AVR: Safer microcontrollers almost here by taneq on Saturday February 11, 2017 @03:05AM (#13621675)
> For example, there is no double free() because heap memory is not a thing.

This was my experience back when I first did embedded stuff. These days unless you're programming something that costs less than a dollar to make, you've probably got at least double digit KBs of RAM and a C compiler. Not saying it's good practice to be using malloc() in this environment but you'll get away with it.

Re:Rust on AVR: Safer microcontrollers almost here by kosma on Saturday February 11, 2017 @07:30AM (#13622327)
> Not saying it's good practice to be using malloc() in this environment but you'll get away with it.

Actually, for the sake of keeping code modular and portable, it's fine to malloc() once on boot and never free(). It's the "dynamic" part of memory management that's dangerous on MCUs, especially on those without an MMU (as fragmentation gets in the way very often and you can't really reason about memory usage anymore).

Re:Rust on AVR: Safer microcontrollers almost here by wyager on Saturday February 11, 2017 @12:36PM (#13623640)
If you're using malloc on boot only, you can almost always replace that with a static data declaration, which usually gets put in the same space the heap would otherwise use. It's better because the compiler can drop malloc, saving you some flash space, and static analysis tools can see how much RAM you're using (and if something is clearly going to blow up).