PinkBean 2020-08-19
记录一下自己犯的错误,回调函数本身就会提供数据大小,自己算反而出了问题。
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; }