mirror of
https://github.com/305a385/ytfind.git
synced 2024-09-07 21:03:27 +00:00
22 lines
484 B
C
22 lines
484 B
C
#include "util.h"
|
|
|
|
size_t WriteMemoryCallback(void *contents, size_t size, size_t nmemb, void *userp) {
|
|
size_t realsize = size * nmemb;
|
|
struct MemoryStruct *mem = (struct MemoryStruct *)userp;
|
|
|
|
char *ptr = realloc(mem->memory, mem->size + realsize + 1);
|
|
if(ptr == NULL) {
|
|
printf("error: not enough memory\n");
|
|
return 0;
|
|
}
|
|
|
|
mem->memory = ptr;
|
|
memcpy(&(mem->memory[mem->size]), contents, realsize);
|
|
mem->size += realsize;
|
|
mem->memory[mem->size] = 0;
|
|
|
|
return realsize;
|
|
}
|
|
|
|
|