PaulS:
If buffer is declared outside the function, it is global. What use is it to return a pointer to a global variable?
It's one way to have the callee not be responsible for freeing the memory. It is a global variable but the static keyword makes the compiler not export the variable in the object file. In other words, it is global to only the functions in the same compilation/translation unit.