From c17d58b8562495d4e835d9541254936f82c248d9 Mon Sep 17 00:00:00 2001 From: Travis Cross Date: Fri, 4 Jul 2014 07:47:04 +0000 Subject: [PATCH] Refactor the curl PUT read callback --- src/mod/applications/mod_curl/mod_curl.c | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) 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; }