I know that this warning was subject of many topics here, but i have a question about the solution for that.
Let`s say I have a function which reads data from a socket (just example).
I did read, that the best way to avoid returning a local variable is to pass a char pointer to the function in which the data will be stored.
But in your oppinion, where exactly should I allocate the necessary memory for this variable.
Should I allocate the memory before I pass the variable to the function (but in this case, i don`t know how many bytes long is the received data. I can write a function which returns the size of the data, but this means that i have to cycle two times through the data), or to pass a null pointer to the function, and use realloc internally?
The only problem is, that as I know, realloc doesn`t return all the time the same pointer, so this can be an error source.
What do you think?