Re: Memory leaks

Alex Woo-Hyun Kim <[email protected]>
Newsgroups gmane.comp.lib.libwww
Message-ID <[email protected]>



There are some memory leaks in showlinks.c.
You can rewrite as followings :

-------------------------------------------------------
PRIVATE int terminate_handler (HTRequest * request, HTResponse * 
response,void * param, int status)
{
    /* We are done with this request */
    HTRequest_delete(request);

    /* Terminate libwww */
    HTProfile_delete();

    /* rewritten by woorung */
    //exit(0);
    HTEventList_stopLoop();
    return 0;
}
--------------------------------------------------------
int main(int argc,char *argv[])
{
    ...........

    if (uri) {
        HTRequest * request = NULL;
        HTAnchor * anchor = NULL;
        BOOL status = NO;

        /* Create a request */
        request = HTRequest_new();

        /* Get an anchor object for the URI */
        anchor = HTAnchor_findAddress(uri);

        /* inserted by woorung */
        printf("escape : [%s]\n",uri);

        /* Issue the GET and store the result in a chunk */
        status = HTLoadAnchor(anchor, request);

        /* Go into the event loop... */
        if (status == YES) HTEventList_loop(request);

        /* inserted by woorung to keep from leaking of memory */
        HTAnchor_deleteAll(NULL);
    }

    ...........
}
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.