If I want to return a pointer from a function, what would be better and safer?
void pro_register_application(WNDCLASS* wc); /* use wc in function */
or
WNDCLASS* pro_register_application(void)
{
WNDCLASS* wc = malloc( sizeof(WNDCLASS) );
...
return wc;
}
As long as you appropriately doccument the details of ownership of the buffer being handled both are same and which one to choose depends on matter of choice.
Users of the second sample would need to be clearly told that the ownership of the buffer is transferred to them and so is the responsibility of deallocating it.