From 1258b0166dc6e68c2592be3410e54d5cb19bc04b Mon Sep 17 00:00:00 2001 From: Fedor Indutny Date: Thu, 4 Feb 2016 16:34:47 -0500 Subject: deps: sync with upstream bagder/c-ares@2bae2d5 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit PR-URL: https://github.com/nodejs/node/pull/5090 Reviewed-By: Saúl Ibarra Corretgé --- deps/cares/src/ares_library_init.c | 27 ++++++++++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-) (limited to 'deps/cares/src/ares_library_init.c') diff --git a/deps/cares/src/ares_library_init.c b/deps/cares/src/ares_library_init.c index 9114f62614..049dc3d7fa 100644 --- a/deps/cares/src/ares_library_init.c +++ b/deps/cares/src/ares_library_init.c @@ -34,6 +34,11 @@ fpGetAdaptersAddresses_t ares_fpGetAdaptersAddresses = ZERO_NULL; static unsigned int ares_initialized; static int ares_init_flags; +/* library-private global vars with visibility across the whole library */ +void *(*ares_malloc)(size_t size) = malloc; +void *(*ares_realloc)(void *ptr, size_t size) = realloc; +void (*ares_free)(void *ptr) = free; + #ifdef USE_WINSOCK static HMODULE hnd_iphlpapi; static HMODULE hnd_advapi32; @@ -45,7 +50,7 @@ static int ares_win32_init(void) #ifdef USE_WINSOCK hnd_iphlpapi = 0; - hnd_iphlpapi = LoadLibraryW(L"iphlpapi.dll"); + hnd_iphlpapi = LoadLibrary("iphlpapi.dll"); if (!hnd_iphlpapi) return ARES_ELOADIPHLPAPI; @@ -73,7 +78,7 @@ static int ares_win32_init(void) */ hnd_advapi32 = 0; - hnd_advapi32 = LoadLibraryW(L"advapi32.dll"); + hnd_advapi32 = LoadLibrary("advapi32.dll"); if (hnd_advapi32) { ares_fpSystemFunction036 = (fpSystemFunction036_t) @@ -111,7 +116,7 @@ int ares_library_init(int flags) { res = ares_win32_init(); if (res != ARES_SUCCESS) - return res; + return res; /* LCOV_EXCL_LINE: can't test Win32 init failure */ } ares_init_flags = flags; @@ -119,6 +124,20 @@ int ares_library_init(int flags) return ARES_SUCCESS; } +int ares_library_init_mem(int flags, + void *(*amalloc)(size_t size), + void (*afree)(void *ptr), + void *(*arealloc)(void *ptr, size_t size)) +{ + if (amalloc) + ares_malloc = amalloc; + if (arealloc) + ares_realloc = arealloc; + if (afree) + ares_free = afree; + return ares_library_init(flags); +} + void ares_library_cleanup(void) { @@ -132,6 +151,8 @@ void ares_library_cleanup(void) ares_win32_cleanup(); ares_init_flags = ARES_LIB_INIT_NONE; + ares_malloc = malloc; + ares_free = free; } -- cgit v1.2.3