I am coding a download program with libcurl. libcurl provide a hook API, which can let you register your own callback function process the download data. Interface of that callback function is fwrite-like,for example:
Code:
size_t
my_write(const void *ptr, size_t size, size_t nmemb, FILE *stream);
You can just simplied register fwrite as the call back function, and it will call fwrite to write down the download data to disk.
My problem is I do not want to store the data, I just want to buffer them to a block of mem, so I can do sth with them.
In fact, I can store the data to a temp file, and read them into a mem block and then remove the temp file, but don't you think it rediculous and resource-watste?
I think anything like one of belows may make my work easier:
1) any thing like a virtual file stream, not a real stream, and I can just threat it as a mem block buffer?
2) or a fwrite-like memory-copying function?
3)your better solution!