From: Travis Cross Date: Fri, 4 Jul 2014 07:47:04 +0000 (+0000) Subject: Refactor the curl PUT read callback X-Git-Tag: v1.5.13~44 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c17d58b8562495d4e835d9541254936f82c248d9;p=thirdparty%2Ffreeswitch.git Refactor the curl PUT read callback --- diff --git a/src/mod/applications/mod_curl/mod_curl.c b/src/mod/applications/mod_curl/mod_curl.c index 87e01ec35a..43229180fd 100644 --- a/src/mod/applications/mod_curl/mod_curl.c +++ b/src/mod/applications/mod_curl/mod_curl.c @@ -153,16 +153,11 @@ static size_t header_callback(void *ptr, size_t size, size_t nmemb, void *data) static size_t read_callback(void *ptr, size_t size, size_t nmemb, void *stream) { struct data_stream *dstream = (struct data_stream*)stream; - size_t nmax = size*nmemb, ncur = 0; - if (dstream->length > nmax) { - ncur = nmax; - dstream->length -= nmax; - } else { - ncur = dstream->length; - dstream->length = 0; - } + size_t nmax = size*nmemb; + size_t ncur = (dstream->length > nmax) ? nmax : dstream->length; memmove(ptr, dstream->data, ncur); dstream->data += ncur; + dstream->length -= ncur; return ncur; }