-
, : , , - , ; , , , malloc-ed malloc-ed, .
, , . , : free , : free(ptr); . , , .
Please also note that if the memory is automatically freed when the pointer to it goes out of scope, it will be freed from the copy function itself and you will return an invalid pointer; and then there would be many double free and identical, every time the pointer goes beyond! Fortunately, this does not happen, since the memory you got with malloc should be explicitly freed with free.
source
share