libwww: memory problems

"Paul Accosta" <[email protected]>
Newsgroups gmane.comp.lib.libwww
Message-ID <[email protected]>
I have a program that is continuously posting data and getting a
response. The problem is as the program continues to run it start eating
up memory and processor time. After a while my simple post functions
takes minutes to complete. Im new to libwww but I thougth I had picked
it up pretty good from the examples. Does anyone have any idea what this
could be? Ill post my function below if that helps.

char * large_post(char * auth, char * dst_str, char *key[10], char
*value[10], int numfields)
{
	HTChunk * chunk = NULL;
	HTRequest * POSTrequest = NULL;
    HTAnchor * dst = NULL;
	HTAssocList * formfields = NULL;
	char * cwd;
	char  data[64];
	int x=0;
	unsigned char *ct;
	char ci[512];
	char co[544];
	char * ddata=NULL;
	char *content;

	ct = (unsigned char *)malloc(sizeof(unsigned char)*32);
	memcpy(ct,"foo:foobar",13);			
	//-- SET SSL PROTO --//
	HTSSL_protMethod_set(HTSSL_V23);
    HTSSL_verifyDepth_set(2);
	//-- REGISTER SSL --//
    HTSSLhttps_init(NO);
	HTUU_encode(ct, strlen((char *)ct), ci);
	strcpy(co, "Basic ");
	strcat(co, ci);
	formfields = HTAssocList_new();
    HTProfile_newNoCacheClient("MY_CLIENT", "2.0");
	HTHost_setEventTimeout(100000);

    if (data && *data && dst_str && *dst_str) 
	{
		cwd = HTGetCurrentDirectoryURL();
		for(x=0;x<numfields;x++)
		{
			HTAssocList_addObject(formfields,key[x],value[x]);
		}
		POSTrequest = HTRequest_new();
		HTRequest_setOutputFormat(POSTrequest,WWW_SOURCE);
		HTRequest_addConnection(POSTrequest, "close", "");
		HTRequest_addCredentials(POSTrequest, "Authorization", co);
		dst = HTAnchor_findAddress(dst_str);
		chunk = HTPostFormAnchorToChunk(formfields,dst,POSTrequest);
		HT_FREE(cwd);

	if (chunk) {		
            HTEventList_loop(POSTrequest);
            ddata = HTChunk_toCString(chunk);
            content=ddata;
        
        }
     }
	HTAssocList_delete(formfields);
	HTRequest_delete(POSTrequest);
	HTSSLhttps_terminate();
	HTProfile_delete();

	free(ct);
	return ddata;
}

int terminate_handler (HTRequest * request, HTResponse * response, void
* param, int status)
{
	HTEventList_stopLoop();
	return 0;
}
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.