String memory problem
Posted on 1998-04-17
If I have:
and msgbuf contains something lets say "--ABCDEF";
Now in my program I do the following:
while((msgbuf != '-') &&(msgbuf != '-') &&(strcmp((strdup(msgbuf+2)),newboundvalue)))
/*Where newboundvalue is "ABCDEF" */
Now my question is :
strdup() returns a pointer to a new string that is a dupli-
cate of the string pointed to by s1.The space for the new string is obtained using malloc(3C). (Source : Man pages)
Now how do I free this memory ??? Because when I run purify
it says there is a memory leak due to the strdup command.
Any help will be appreciated.