
Michael L. answered 09/30/20
Multiple Years Teaching Others & 4.0 Grades in Computer Science
Hello!
Patrick is absolutely right, this is a memory leak.
I explain in the video above, but essentially:
Just because p no longer points to the memory given to it by malloc(), does not mean that memory was "freed". This means that when you say p = NULL, you're saying p no longer points to that memory, but that memory still exists. However, it is no longer accessible (leaked memory).
Xiana Z.
Thank you very much for your amazing explanation !!!09/30/20