提交 c17d58b8 authored 作者: Travis Cross's avatar Travis Cross

Refactor the curl PUT read callback

上级 2fea3528
...@@ -153,16 +153,11 @@ static size_t header_callback(void *ptr, size_t size, size_t nmemb, void *data) ...@@ -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;
} }
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论