From 6f8ecea0594faa24e738be53dbf2b512f2168a04 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Fri, 9 Oct 2015 16:04:11 +0200 Subject: curl_global_init_mem: set function pointers before doing init ... as in the polarssl TLS backend for example it uses memory functions. --- lib/easy.c | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/lib/easy.c b/lib/easy.c index 316acb1d1..8b1fc0371 100644 --- a/lib/easy.c +++ b/lib/easy.c @@ -292,8 +292,6 @@ CURLcode curl_global_init_mem(long flags, curl_malloc_callback m, curl_free_callback f, curl_realloc_callback r, curl_strdup_callback s, curl_calloc_callback c) { - CURLcode result = CURLE_OK; - /* Invalid input, return immediately */ if(!m || !f || !r || !s || !c) return CURLE_FAILED_INIT; @@ -306,17 +304,16 @@ CURLcode curl_global_init_mem(long flags, curl_malloc_callback m, return CURLE_OK; } - /* Call the actual init function first */ - result = curl_global_init(flags); - if(!result) { - Curl_cmalloc = m; - Curl_cfree = f; - Curl_cstrdup = s; - Curl_crealloc = r; - Curl_ccalloc = c; - } + /* set memory functions before global_init() in case it wants memory + functions */ + Curl_cmalloc = m; + Curl_cfree = f; + Curl_cstrdup = s; + Curl_crealloc = r; + Curl_ccalloc = c; - return result; + /* Call the actual init function */ + return curl_global_init(flags); } /** -- cgit v1.2.3