mem_cb(void *contents, size_t size, size_t nmemb, void *userp)
size_t realsize = size * nmemb;
struct response *mem = (struct response *)userp;
char *ptr = realloc(mem->memory, mem->size + realsize + 1);
printf("not enough memory (realloc returned NULL)\n");
memcpy(&(mem->memory[mem->size]), contents, realsize);
mem->memory[mem->size] = 0;
struct response chunk = {.memory = malloc(0),
/* send all data to this function */
curl_easy_setopt(curl_handle, CURLOPT_WRITEFUNCTION, mem_cb);
/* we pass our 'chunk' to the callback function */
curl_easy_setopt(curl_handle, CURLOPT_WRITEDATA, (void *)&chunk);