diff options
author | Daniel Stenberg <daniel@haxx.se> | 2001-09-12 07:57:33 +0000 |
---|---|---|
committer | Daniel Stenberg <daniel@haxx.se> | 2001-09-12 07:57:33 +0000 |
commit | 07de3c9df0fb3e84c5e12c3c5d647944a46141e6 (patch) | |
tree | 48fe68296b52656ce0b093bbddcf4db3be84607b /lib | |
parent | 8950a2dfa1c9f4dda56624a0813c860df561b97e (diff) |
T. Bharath's patch that sets up a few necessary buffers in the duphandle()
function
Diffstat (limited to 'lib')
-rw-r--r-- | lib/easy.c | 46 |
1 files changed, 39 insertions, 7 deletions
diff --git a/lib/easy.c b/lib/easy.c index 07a0aa8b1..a0def11e6 100644 --- a/lib/easy.c +++ b/lib/easy.c @@ -255,7 +255,8 @@ CURL *curl_easy_duphandle(CURL *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) return NULL; /* failure */ @@ -263,17 +264,48 @@ CURL *curl_easy_duphandle(CURL *incurl) /* start with clearing the entire new struct */ 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 */ 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' */ - outcurl->change.url = strdup(data->change.url); - outcurl->change.proxy = strdup(data->change.proxy); - outcurl->change.referer = strdup(data->change.referer); - /* set all the alloc-bits */ - outcurl->change.url_alloc = - outcurl->change.proxy_alloc = + if(data->change.url) { + outcurl->change.url = strdup(data->change.url); + outcurl->change.url_alloc = TRUE; + } + if(data->change.proxy) { + 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; + } return outcurl; } |