In cases were you have to return a pointer to memory that will not be modified outside its creating function, is it OK to use a static variable instead of calling malloc?
I'm fine with using malloc when I don't know the amount of memory I need before runtime, however, in cases where I do, I feel its wasteful -and not to mention more error prone- to use the heap when a simple static var would work. On the other hand, I don't like calling bzero to clear the static object on each subsequent call. I feel it goes against the purpose of the static variable, which is to hold its state between
calls.What do you guys think?