Re: Memory leaks

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);
    }

    ...........
} 

Received on Monday, 30 September 2002 07:03:51 UTC