curl_global_init_mem: set function pointers before doing init
... as in the polarssl TLS backend for example it uses memory functions.
This commit is contained in:
parent
048f84637f
commit
6f8ecea059
21
lib/easy.c
21
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);
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user