阅读背景:

指针是realloc没有分配。

来源:互联网 
size_t writeFunctionHandler(char *contents,size_t size,size_t nmemb,void *userdata) {
  // size of the storedSize
  static size_t storedSize = 0;

  // the size of data available
  size_t realSize = size * nmemb;

  char *dataBuffer = (char *) userdata;

  // realloc the buffer buffer
  dataBuffer = realloc(dataBuffer,storedSize + realSize);

  if (dataBuffer == NULL) {
    printf("Could not allocate memory \n");
    return 0;
  }

  // store the contents of realSize from last storedSize
  memcpy(&(dataBuffer[storedSize]),contents,realSize);

  storedSize += realSize;
  return realSize;
}
size_t writeFunctionHandler(char *contents,size



你的当前访问异常,请进行认证后继续阅读剩余内容。

分享到: