{ int ptr = (int)malloc(sizeof(int));
ptr=NULL;
free(ptr);
}
Why is this code the case of memory leak?
Memory leak happens when we forget to deallocate the memory and here we have done that.
{ int ptr = (int)malloc(sizeof(int));
ptr=NULL;
free(ptr);
}
Why is this code the case of memory leak?
Memory leak happens when we forget to deallocate the memory and here we have done that.