Will this function cause memory leak?
The function is :
double list(double *list2){
double *list3=(double *)malloc(sizeof(double));
some operations...
return *list3;
}
update:
could this help?
int main(){
operations...
double list4;
list4=list(&list4);
free(&list4);
return 0;
}
Yes, it does: it is returning a copy of the value of what is stored in the allocated memory, but the allocated memory itself is leaked (because the address has been "lost").
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With