提交 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)
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;
}
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论