Re:Legitimate Use of Variable Length Arrays
by theamk on Monday October 28, 2019 @11:20AM
(#21377743)
Um, no? That COPY_MAX would still need a different value between small MCU and full-blown PC.
Not to mention that using stack allocation on low-memory device is extremely dangerous... at least with malloc you get a nice diagnostic, while alloca will just do random program damage.
Re:Legitimate Use of Variable Length Arrays
by lonelappde on Monday October 28, 2019 @05:03PM
(#21381636)
Isn't that like choosing your poison? If you have a low memory device, you need to statically guarantee safety and reject oversized inputs. Crashing your embedded device may work if your are a server with a client that knows to retry another backend, but isn't an elegant solution if it disables your car's brakes.
Et voilà, a library function that could have been portable between the smallest microcontroller and the largest workstation becomes restricted to a single application.