From: Bastian Dehn Date: Sun, 2 Feb 2025 15:33:54 +0000 (+0100) Subject: change curl global init with mem X-Git-Tag: v1.0.30^2~5 X-Git-Url: https://gitweb.hhaalo.de/?a=commitdiff_plain;h=9156e8ad4979b6593fdfeeed2aafa64c410e5d68;p=sane-kds-s2000w-net.git change curl global init with mem --- diff --git a/src/kds_s2000w_client.c b/src/kds_s2000w_client.c index a56902d..799b740 100644 --- a/src/kds_s2000w_client.c +++ b/src/kds_s2000w_client.c @@ -26,6 +26,31 @@ CURL* curl = NULL; program_config* config = NULL; char* errbuf = NULL; +void *_kds_s2000w_client_malloc_cb(size_t size) +{ + return malloc(size); +} +void _kds_s2000w_client_free_cb(void * ptr) +{ + free(ptr); +} +void *_kds_s2000w_client_realloc_cb(void * ptr, size_t size) +{ + return realloc(ptr, size); +} +char *_kds_s2000w_client_strdup_cb(const char * str) +{ + if (strlen(str) == 0) { + return '\0'; + } + + return strdup(str); +} +void *_kds_s2000w_client_calloc_cb(size_t nmemb, size_t size) +{ + return calloc(nmemb, size); +} + void _kds_s2000w_client_print_error_status(CURL* curl) { struct curl_header* header = NULL; @@ -67,7 +92,12 @@ void kds_s2000w_client_init() char* config_stream = kds_s2000w_config_read(CONFIG_FILE); config = kds_s2000w_load_config(config_stream); - curl_global_init(CURL_GLOBAL_ALL); + curl_global_init_mem(CURL_GLOBAL_DEFAULT, + _kds_s2000w_client_malloc_cb, + _kds_s2000w_client_free_cb, + _kds_s2000w_client_realloc_cb, + _kds_s2000w_client_strdup_cb, + _kds_s2000w_client_calloc_cb); curl = curl_easy_init(); errbuf = malloc(CURL_ERROR_SIZE); memset(errbuf, 0, CURL_ERROR_SIZE);