clients/c/sky-island.c
/* curl_callback is a callback for curl fetch */
curl_callback is a callback for curl fetch
curl_callback is a callback for curl fetch
size_t curl_callback(void* contents, size_t size, size_t nmemb, void* userp) {
  size_t realsize = size * nmemb;
  struct curl_fetch_st* p = (struct curl_fetch_st*)userp;
  p->payload = (char*)realloc(p->payload, p->size + realsize + 1);
  if (p->payload == NULL) {
    fprintf(stderr, "ERROR: Failed to expand buffer in curl_callback");
    free(p->payload);
    return -1;
  }
  memcpy(&(p->payload[p->size]), contents, realsize);
  p->size += realsize;
  p->payload[p->size] = 0;
  return realsize;
}
size_t curl_callback ( void * contents , size_t size , size_t nmemb , void * userp ) { size_t realsize = size * nmemb ; struct curl_fetch_st * p = ( struct curl_fetch_st * ) userp ; p -> payload = ( char * ) realloc ( p -> payload , p -> size + realsize + 1 ) ; if ( p -> payload == NULL ) { fprintf ( stderr , " " ) ; free ( p -> payload ) ; return -1 ; } memcpy ( & ( p -> payload [ p -> size ] ) , contents , realsize ) ; p -> size += realsize ; p -> payload [ p -> size ] = 0 ; return realsize ; }
curl_callback is a callback for curl fetch
curl_callback is a callback for curl fetch
// copy contents to buffer // set new buffer size