diff options
author | Curl Upstream <curl-library@cool.haxx.se> | 2020-06-23 21:41:50 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2020-06-24 11:55:09 (GMT) |
commit | 5717fdc114a704cddae629e20e6588191360e98a (patch) | |
tree | 36545299412c5cafb4d3e3eb464598af465ea4c8 /lib/sendf.c | |
parent | 735ea3001ae98636a4cb7caf15a40960c0da39a1 (diff) | |
download | CMake-5717fdc114a704cddae629e20e6588191360e98a.zip CMake-5717fdc114a704cddae629e20e6588191360e98a.tar.gz CMake-5717fdc114a704cddae629e20e6588191360e98a.tar.bz2 |
curl 2020-06-23 (e9db32a0)
Code extracted from:
https://github.com/curl/curl.git
at commit e9db32a09af03f27e86d1251a9e68e9b7486d371 (curl-7_71_0).
Diffstat (limited to 'lib/sendf.c')
-rw-r--r-- | lib/sendf.c | 36 |
1 files changed, 6 insertions, 30 deletions
diff --git a/lib/sendf.c b/lib/sendf.c index 6ef47aa..147ecbf 100644 --- a/lib/sendf.c +++ b/lib/sendf.c @@ -267,7 +267,7 @@ void Curl_failf(struct Curl_easy *data, const char *fmt, ...) size_t len; char error[CURL_ERROR_SIZE + 2]; va_start(ap, fmt); - mvsnprintf(error, CURL_ERROR_SIZE, fmt, ap); + (void)mvsnprintf(error, CURL_ERROR_SIZE, fmt, ap); len = strlen(error); if(data->set.errorbuffer && !data->state.errorbuf) { @@ -498,7 +498,6 @@ static CURLcode pausewrite(struct Curl_easy *data, is again enabled */ struct SingleRequest *k = &data->req; struct UrlState *s = &data->state; - char *dupl; unsigned int i; bool newtype = TRUE; @@ -518,44 +517,21 @@ static CURLcode pausewrite(struct Curl_easy *data, else i = 0; - if(!newtype) { - /* append new data to old data */ - - /* figure out the new size of the data to save */ - size_t newlen = len + s->tempwrite[i].len; - /* allocate the new memory area */ - char *newptr = realloc(s->tempwrite[i].buf, newlen); - if(!newptr) - return CURLE_OUT_OF_MEMORY; - /* copy the new data to the end of the new area */ - memcpy(newptr + s->tempwrite[i].len, ptr, len); - - /* update the pointer and the size */ - s->tempwrite[i].buf = newptr; - s->tempwrite[i].len = newlen; - - len = newlen; /* for the debug output below */ - } - else { - dupl = Curl_memdup(ptr, len); - if(!dupl) - return CURLE_OUT_OF_MEMORY; - + if(newtype) { /* store this information in the state struct for later use */ - s->tempwrite[i].buf = dupl; - s->tempwrite[i].len = len; + Curl_dyn_init(&s->tempwrite[i].b, DYN_PAUSE_BUFFER); s->tempwrite[i].type = type; if(newtype) s->tempcount++; } + if(Curl_dyn_addn(&s->tempwrite[i].b, (unsigned char *)ptr, len)) + return CURLE_OUT_OF_MEMORY; + /* mark the connection as RECV paused */ k->keepon |= KEEP_RECV_PAUSE; - DEBUGF(infof(data, "Paused %zu bytes in buffer for type %02x\n", - len, type)); - return CURLE_OK; } |