> I don't know about "commonly". In my experience with embedded C, if you needed things you declared them statically and never used malloc.
I mean, it's common enough that MISRA, the JSF standard, and the NASA standard all specifically call it out to allow it under these conditions.
> It's not like you're calling alloca and letting those pointers escape -- any (valid) pointer you might have is to a static allocation or memory mapped address.
You only need to call alloca on dynamically sized stack allocations. You can always leak pointers to fixed size objects by:
void* woah_dont_do_this(void) {
int value = 0;
return &value;
}
and boom, the pointer that gets returned is pointing at invalid memory. Of course, no one would write it like this, but it's way easier than you might think to accidentally do this once there's some abstraction.