summaryrefslogtreecommitdiff
path: root/lib/curl_memory.h
diff options
context:
space:
mode:
authorYang Tse <yangsita@gmail.com>2013-07-18 20:04:02 +0200
committerYang Tse <yangsita@gmail.com>2013-07-18 23:37:33 +0200
commit90695fb2c508803a09581b0ca8f55eaa36749a69 (patch)
tree8ba98611465b9639fada7c24aef8e420f46405b2 /lib/curl_memory.h
parentdd17069c9e307ff135f4eb572671bd351f7e6a42 (diff)
downloadcurl-90695fb2c508803a09581b0ca8f55eaa36749a69.tar.gz
Reinstate "WIN32 MemoryTracking: track wcsdup() _wcsdup() and _tcsdup() usage".
This reverts commit 7ed25cc, reinstating commit 8ec2cb5. As of 18-jul-2013 we still do have code in libcurl that makes use of these memory functions. Commit 8ec2cb5 comment still applies and is yet valid. These memory functions are solely used in Windows builds, so all related code is protected with '#ifdef WIN32' preprocessor conditional compilation directives. Specifically, wcsdup() _wcsdup() are used when building a Windows target with UNICODE and USE_WINDOWS_SSPI preprocessor symbols defined. This is the case when building a Windows UNICODE target with Windows native SSL/TLS support enabled. Realizing that wcsdup() _wcsdup() are used is a bit tricky given that usage of these is hidden behind _tcsdup() which is MS way of dealing with code that must tolerate UNICODE and non-UNICODE compilation. Additionally, MS header files and those compatible from other compilers use this preprocessor conditional compilation directive in order to select at compilation time whether 'wide' or 'ansi' MS API functions are used. Without this code, Windows build targets with Windows native SSL/TLS support enabled and MemoryTracking support enabled misbehave in tracking memory usage, regardless of being a UNICODE enabled build or not.
Diffstat (limited to 'lib/curl_memory.h')
-rw-r--r--lib/curl_memory.h16
1 files changed, 16 insertions, 0 deletions
diff --git a/lib/curl_memory.h b/lib/curl_memory.h
index c1e92513f..4bba008c9 100644
--- a/lib/curl_memory.h
+++ b/lib/curl_memory.h
@@ -87,6 +87,9 @@ extern curl_free_callback Curl_cfree;
extern curl_realloc_callback Curl_crealloc;
extern curl_strdup_callback Curl_cstrdup;
extern curl_calloc_callback Curl_ccalloc;
+#ifdef WIN32
+extern curl_wcsdup_callback Curl_cwcsdup;
+#endif
#ifndef CURLDEBUG
@@ -110,6 +113,19 @@ extern curl_calloc_callback Curl_ccalloc;
#undef free
#define free(ptr) Curl_cfree(ptr)
+#ifdef WIN32
+# undef wcsdup
+# define wcsdup(ptr) Curl_cwcsdup(ptr)
+# undef _wcsdup
+# define _wcsdup(ptr) Curl_cwcsdup(ptr)
+# undef _tcsdup
+# ifdef UNICODE
+# define _tcsdup(ptr) Curl_cwcsdup(ptr)
+# else
+# define _tcsdup(ptr) Curl_cstrdup(ptr)
+# endif
+#endif
+
#endif /* CURLDEBUG */
#else /* CURLX_NO_MEMORY_CALLBACKS */