When memory is allocated using malloc() in any function ,it returns a pointer to the start of the data………and again we free the memory using free() wit the help of pointer.but it should be used b4 we leave the function.n if it’s not used the pointer is lost and there is no way to clr the memory and it can never be used.
tis is called MEMORY LEAK………
ptr = NULL;
ptr = strdup(“HI”);
// ptr = NULL;
It will show memory leak of 3 bytes.
now Uncomment the commented lines, no memory leak will be there.