W3C home > Mailing lists > Public > www-lib@w3.org > April to June 1998

Re: chunk example crashing if iterated

From: Henrik Frystyk Nielsen <frystyk@w3.org>
Date: Mon, 01 Jun 1998 09:02:54 -0400
Message-Id: <3.0.5.32.19980601090254.00976100@localhost>
To: fil@cs.ucsd.edu (Filippo Menczer), www-lib@w3.org
Cc: fil@cs.ucsd.edu
At 20:47 5/30/98 -0400, Filippo Menczer wrote:
>Could someone help me figure out why this simple example is crashing?
>Basically I am calling the code in the "chunk" example multiple times
>by wrapping a loop around it. The first time it goes fine, the second
>causes a segmentation fault.

Try and move the profile stuff (which does all the initialization of libwww
outside your loop.

Henrik

*****

#include "WWWLib.h"
#include "WWWHTTP.h"
#include "WWWInit.h"

void mygetchunk(char *url)
{
    HTRequest *request = HTRequest_new();
    HTChunk *chunk = NULL;
    HTRequest_setOutputFormat(request, WWW_SOURCE);
    if (url) {
        char *cwd = HTGetCurrentDirectoryURL();
        char *absolute_url = HTParse(url, cwd, PARSE_ALL);
        chunk = HTLoadToChunk(absolute_url, request);
        HT_FREE(absolute_url);
        HT_FREE(cwd);
        printf("%s\n", chunk ? "OK-FIRST-TIME" : "NO DATA");
    }
    HTRequest_delete(request);
}

main()
{
    /* Start libwww */
    HTProfile_newPreemptiveClient("TestApp", "1.0");
    HTSetTraceMessageMask("sop");

    /* Do the gets */
    mygetchunk("http://www.cs.ucsd.edu/~fil/agents");
    mygetchunk("http://www.cs.ucsd.edu/~fil/agents"); /* any URL here */

    /* Close libwww down */
    HTProfile_delete();
}

--
Henrik Frystyk Nielsen,
World Wide Web Consortium
http://www.w3.org/People/Frystyk
Received on Monday, 1 June 1998 09:02:34 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Monday, 23 April 2007 18:18:27 GMT