mirror of
https://github.com/signalwire/freeswitch.git
synced 2025-05-31 10:46:27 +00:00
Refactor the curl PUT read callback
This commit is contained in:
parent
2fea35282f
commit
c17d58b856
@ -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)
|
static size_t read_callback(void *ptr, size_t size, size_t nmemb, void *stream)
|
||||||
{
|
{
|
||||||
struct data_stream *dstream = (struct data_stream*)stream;
|
struct data_stream *dstream = (struct data_stream*)stream;
|
||||||
size_t nmax = size*nmemb, ncur = 0;
|
size_t nmax = size*nmemb;
|
||||||
if (dstream->length > nmax) {
|
size_t ncur = (dstream->length > nmax) ? nmax : dstream->length;
|
||||||
ncur = nmax;
|
|
||||||
dstream->length -= nmax;
|
|
||||||
} else {
|
|
||||||
ncur = dstream->length;
|
|
||||||
dstream->length = 0;
|
|
||||||
}
|
|
||||||
memmove(ptr, dstream->data, ncur);
|
memmove(ptr, dstream->data, ncur);
|
||||||
dstream->data += ncur;
|
dstream->data += ncur;
|
||||||
|
dstream->length -= ncur;
|
||||||
return ncur;
|
return ncur;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user