diff options
Diffstat (limited to 'lib/easy.c')
-rw-r--r-- | lib/easy.c | 22 |
1 files changed, 16 insertions, 6 deletions
diff --git a/lib/easy.c b/lib/easy.c index 2784db83f..9995bcdee 100644 --- a/lib/easy.c +++ b/lib/easy.c @@ -80,6 +80,7 @@ #include "getinfo.h" #include "hostip.h" #include "share.h" +#include "strdup.h" #include "memory.h" #include "progress.h" #include "easyif.h" @@ -182,18 +183,27 @@ static unsigned int initialized; static long init_flags; /* + * strdup (and other memory functions) is redefined in complicated + * ways, but at this point it must be defined as the system-supplied strdup + * so the callback pointer is initialized correctly. + */ +#if defined(_WIN32_WCE) +#define system_strdup _strdup +#elif !defined(HAVE_STRDUP) +#define system_strdup curlx_strdup +#else +#define system_strdup strdup +#endif + +/* * If a memory-using function (like curl_getenv) is used before * curl_global_init() is called, we need to have these pointers set already. */ -#ifdef _WIN32_WCE -#define strdup _strdup -#endif - curl_malloc_callback Curl_cmalloc = (curl_malloc_callback)malloc; curl_free_callback Curl_cfree = (curl_free_callback)free; curl_realloc_callback Curl_crealloc = (curl_realloc_callback)realloc; -curl_strdup_callback Curl_cstrdup = (curl_strdup_callback)strdup; +curl_strdup_callback Curl_cstrdup = (curl_strdup_callback)system_strdup; curl_calloc_callback Curl_ccalloc = (curl_calloc_callback)calloc; /** @@ -209,7 +219,7 @@ CURLcode curl_global_init(long flags) Curl_cmalloc = (curl_malloc_callback)malloc; Curl_cfree = (curl_free_callback)free; Curl_crealloc = (curl_realloc_callback)realloc; - Curl_cstrdup = (curl_strdup_callback)strdup; + Curl_cstrdup = (curl_strdup_callback)system_strdup; Curl_ccalloc = (curl_calloc_callback)calloc; if (flags & CURL_GLOBAL_SSL) |