libcurl CURLOPT_WRITEFUNCTION 回调函数多次触发导致数据错乱的问题
记录一下自己犯的错误,回调函数本身就会提供数据大小,自己算反而出了问题。
size_t Get_Receive_Data(void* buffer, size_t size, size_t nmemb, char **stream) { //int len = strlen((char*)buffer); int len = size * nmemb; if(NULL != *stream) { *stream = (char*)realloc(*stream, len + strlen(*stream)); memcpy(*stream + strlen(*stream), (char*)buffer,len); } else { *stream = (char*)malloc(len); memcpy(*stream,(char*)buffer, len); } //memcpy(stream,temp,strlen(temp)); return size * nmemb; }
相关推荐
ILVNMM 2020-10-26
Seandba 2020-08-16
徐建岗网络管理 2020-07-28
lynjay 2020-06-14
AaronPlay 2020-06-13
88384957 2020-06-12
herohope 2020-06-10
adwen00 2020-06-09
KilluaZoldyck 2020-06-06
hitxueliang 2020-06-05
lightindark 2020-06-03
baishuwei 2020-06-03
jediaellu 2020-05-31
twater000 2020-05-29
ItBJLan 2020-05-11
韩学敏 2020-05-09
阿亮 2020-05-06