On 15-Mar-2000 Evan Moore wrote: > I am writting a small network deamon in c, and just dowloaded a copy of > lclint, which told me that I have a memory leak, great I say, I look at > the code and realize duh, how did i miss that of course i defined a > variable hostinfo of type struct hostent then let gethostbyname fill it > up. So i try to free hostinfo and it complains that it was not allocated > by malloc. So how do I free this memory? >
lclint while handy is not omniscient. You can free() the memory, vut lclint never sees it get alloc'ed. So you fix an error and get a spurious warning. Part of using any memory checker is knowing when to follow their advice and when to say "I am the coder, I know what I am doing".