int subroutine (char *input, float *buffer)
{
*buffer = malloc(...)
buffer is calculated from input
}
or
flot subroutine (char *input)
{
*output = malloc(...)
buffer is calculated from input
return(buffer);
}
int main(int argc, char *argv[])
{
float *data;
subroutine(argv[] ...)
...
free(data)
}
1) which subroutine is recommended?
2) If I malloc-ed the buffer in subroutine, where do I have to free it?
3) Is freeing data in the main sufficient?
4) Do I have to free the buffer in subroutine?