]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
Refactor the curl PUT read callback
authorTravis Cross <tc@traviscross.com>
Fri, 4 Jul 2014 07:47:04 +0000 (07:47 +0000)
committerTravis Cross <tc@traviscross.com>
Fri, 4 Jul 2014 07:47:04 +0000 (07:47 +0000)
src/mod/applications/mod_curl/mod_curl.c

index 87e01ec35a582446582bd14b10c7e72ad4b1e83e..43229180fdbe572c5ce9f9b4f5e39e26cbc65dc4 100644 (file)
@@ -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;
 }