1
0
mirror of https://github.com/moparisthebest/curl synced 2024-10-31 15:45:12 -04:00

T. Bharath's patch that sets up a few necessary buffers in the duphandle()

function
This commit is contained in:
Daniel Stenberg 2001-09-12 07:57:33 +00:00
parent 8950a2dfa1
commit 07de3c9df0

View File

@ -255,7 +255,8 @@ CURL *curl_easy_duphandle(CURL *incurl)
{ {
struct SessionHandle *data=(struct SessionHandle *)incurl; struct SessionHandle *data=(struct SessionHandle *)incurl;
struct SessionHandle *outcurl = malloc(sizeof(struct SessionHandle)); struct SessionHandle *outcurl = (struct SessionHandle *)
malloc(sizeof(struct SessionHandle));
if(NULL == outcurl) if(NULL == outcurl)
return NULL; /* failure */ return NULL; /* failure */
@ -263,17 +264,48 @@ CURL *curl_easy_duphandle(CURL *incurl)
/* start with clearing the entire new struct */ /* start with clearing the entire new struct */
memset(outcurl, 0, sizeof(struct SessionHandle)); memset(outcurl, 0, sizeof(struct SessionHandle));
/*
* We setup a few buffers we need. We should probably make them
* get setup on-demand in the code, as that would probably decrease
* the likeliness of us forgetting to init a buffer here in the future.
*/
outcurl->state.headerbuff=(char*)malloc(HEADERSIZE);
if(!outcurl->state.headerbuff) {
free(outcurl); /* free the memory again */
return NULL;
}
outcurl->state.headersize=HEADERSIZE;
/* copy all userdefined values */ /* copy all userdefined values */
outcurl->set = data->set; outcurl->set = data->set;
outcurl->state.numconnects = data->state.numconnects;
outcurl->state.connects = (struct connectdata **)
malloc(sizeof(struct connectdata *) * outcurl->state.numconnects);
if(!outcurl->state.connects) {
free(outcurl->state.headerbuff);
free(outcurl);
return NULL;
}
memset(outcurl->state.connects, 0,
sizeof(struct connectdata *)*outcurl->state.numconnects);
outcurl->progress.flags = data->progress.flags;
outcurl->progress.callback = data->progress.callback;
/* duplicate all values in 'change' */ /* duplicate all values in 'change' */
outcurl->change.url = strdup(data->change.url); if(data->change.url) {
outcurl->change.proxy = strdup(data->change.proxy); outcurl->change.url = strdup(data->change.url);
outcurl->change.referer = strdup(data->change.referer); outcurl->change.url_alloc = TRUE;
/* set all the alloc-bits */ }
outcurl->change.url_alloc = if(data->change.proxy) {
outcurl->change.proxy_alloc = outcurl->change.proxy = strdup(data->change.proxy);
outcurl->change.proxy_alloc = TRUE;
}
if(data->change.referer) {
outcurl->change.referer = strdup(data->change.referer);
outcurl->change.referer_alloc = TRUE; outcurl->change.referer_alloc = TRUE;
}
return outcurl; return outcurl;
} }