Loading Sprite from URL

struct MemoryStruct {
char **memory;
size_t size;
};

size_t HelloWorld::WriteMemoryCallback
{
size_t realsize = size** nmemb;
struct MemoryStruct mem = userp;
mem->memory = realloc;
if {
/
out of memory! **/
printf");
exit;
}
memcpy, contents, realsize);
mem~~>size += realsize;
mem~~>memory[mem->size] = 0;
return realsize;
}

void HelloWorld::DoCulr
{
CURL**curl_handle;

struct MemoryStruct chunk;

chunk.memory = (char )malloc; / will be grown as needed by the realloc above /
chunk.size = 0; /
no data at this point /
curl_global_init;
/
init the curl session /
curl_handle = curl_easy_init;
/
specify URL to get /
curl_easy_setopt;
/
send all data to this function /
curl_easy_setopt;
/
we pass our ‘chunk’ struct to the callback function /
curl_easy_setopt&chunk);
/
some servers don’t like requests that are made without a user-agent
field, so we provide one /
curl_easy_setopt;
/
get it! /
curl_easy_perform;
/
cleanup curl stuff /
curl_easy_cleanup;
/

* Now, our chunk.memory points to a memory block that is chunk.size
* bytes big and contains the remote file.
*
* Do something nice with it!
*
* You should be aware of the fact that at this point we might have an
* allocated data block, and nothing has yet deallocated that data. So when
* you’re done with it, you should free() it as a nice application.
/
printfchunk.size);
if
free;
/
we’re done with libcurl, so clean it up */
curl_global_cleanup();

}
when i run the code ,it’s all throw error:HelloCpp.exe 中的 0x00000178 处有未经处理的异常: 0xC0000005: Access violation.Why is it? The code is the same as http://curl.haxx.se/libcurl/c/getinmemory.html