diff options
author | Daniel Stenberg <daniel@haxx.se> | 2020-05-28 18:30:47 +0200 |
---|---|---|
committer | Daniel Stenberg <daniel@haxx.se> | 2020-05-30 23:14:33 +0200 |
commit | c4e6968127e876b01e5e0b4b7cdbc49d5267530c (patch) | |
tree | 7d74ba1d30f99ac91b050fbb6c5b44338c56e88f /lib/easy.c | |
parent | 842f73de58f38bd6e285e08bbd1adb6c17cb62cd (diff) | |
download | curl-c4e6968127e876b01e5e0b4b7cdbc49d5267530c.tar.gz |
url: alloc the download buffer at transfer start
... and free it as soon as the transfer is done. It removes the extra
alloc when a new size is set with setopt() and reduces memory for unused
easy handles.
In addition: the closure_handle now doesn't use an allocated buffer at
all but the smallest supported size as a stack based one.
Closes #5472
Diffstat (limited to 'lib/easy.c')
-rw-r--r-- | lib/easy.c | 17 |
1 files changed, 0 insertions, 17 deletions
diff --git a/lib/easy.c b/lib/easy.c index 1deedb265..f58c4521a 100644 --- a/lib/easy.c +++ b/lib/easy.c @@ -829,9 +829,6 @@ struct Curl_easy *curl_easy_duphandle(struct Curl_easy *data) * the likeliness of us forgetting to init a buffer here in the future. */ outcurl->set.buffer_size = data->set.buffer_size; - outcurl->state.buffer = malloc(outcurl->set.buffer_size + 1); - if(!outcurl->state.buffer) - goto fail; /* copy all userdefined values */ if(dupset(outcurl, data)) @@ -947,8 +944,6 @@ struct Curl_easy *curl_easy_duphandle(struct Curl_easy *data) */ void curl_easy_reset(struct Curl_easy *data) { - long old_buffer_size = data->set.buffer_size; - Curl_free_request_state(data); /* zero out UserDefined data: */ @@ -972,18 +967,6 @@ void curl_easy_reset(struct Curl_easy *data) #if !defined(CURL_DISABLE_HTTP) && !defined(CURL_DISABLE_CRYPTO_AUTH) Curl_http_auth_cleanup_digest(data); #endif - - /* resize receive buffer */ - if(old_buffer_size != data->set.buffer_size) { - char *newbuff = realloc(data->state.buffer, data->set.buffer_size + 1); - if(!newbuff) { - DEBUGF(fprintf(stderr, "Error: realloc of buffer failed\n")); - /* nothing we can do here except use the old size */ - data->set.buffer_size = old_buffer_size; - } - else - data->state.buffer = newbuff; - } } /* |