summaryrefslogtreecommitdiff
path: root/lib/memdebug.h
diff options
context:
space:
mode:
authorYang Tse <yangsita@gmail.com>2013-03-25 03:15:52 +0100
committerYang Tse <yangsita@gmail.com>2013-03-25 03:32:47 +0100
commit8ec2cb5544b86306b702484ea785b6b9596562ab (patch)
tree55952aea963b504165c3246768c93b21d6375958 /lib/memdebug.h
parentc5eabd48e8dbc8393723bb79f0040475d850f389 (diff)
downloadcurl-8ec2cb5544b86306b702484ea785b6b9596562ab.tar.gz
WIN32 MemoryTracking: track wcsdup() _wcsdup() and _tcsdup() usage
As of 25-mar-2013 wcsdup() _wcsdup() and _tcsdup() are only used in WIN32 specific code, so tracking of these has not been extended for other build targets. Without this fix, memory tracking system on WIN32 builds, when using these functions, would provide misleading results. In order to properly extend this support for all targets curl.h would have to define curl_wcsdup_callback prototype and consequently wchar_t should be visible before that in curl.h. IOW curl_wchar_t defined in curlbuild.h and this pulling whatever system header is required to get wchar_t definition. Additionally a new curl_global_init_mem() function that also receives user defined wcsdup() callback would be required.
Diffstat (limited to 'lib/memdebug.h')
-rw-r--r--lib/memdebug.h20
1 files changed, 19 insertions, 1 deletions
diff --git a/lib/memdebug.h b/lib/memdebug.h
index fbeb61de5..955e8b72b 100644
--- a/lib/memdebug.h
+++ b/lib/memdebug.h
@@ -8,7 +8,7 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2012, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2013, Daniel Stenberg, <daniel@haxx.se>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
@@ -46,6 +46,11 @@ CURL_EXTERN void *curl_dorealloc(void *ptr, size_t size, int line,
const char *source);
CURL_EXTERN void curl_dofree(void *ptr, int line, const char *source);
CURL_EXTERN char *curl_dostrdup(const char *str, int line, const char *source);
+#ifdef WIN32
+CURL_EXTERN wchar_t *curl_dowcsdup(const wchar_t *str, int line,
+ const char *source);
+#endif
+
CURL_EXTERN void curl_memdebug(const char *logname);
CURL_EXTERN void curl_memlimit(long limit);
CURL_EXTERN void curl_memlog(const char *format, ...);
@@ -84,6 +89,19 @@ CURL_EXTERN int curl_fclose(FILE *file, int line, const char *source);
#define realloc(ptr,size) curl_dorealloc(ptr, size, __LINE__, __FILE__)
#define free(ptr) curl_dofree(ptr, __LINE__, __FILE__)
+#ifdef WIN32
+# undef wcsdup
+# define wcsdup(ptr) curl_dowcsdup(ptr, __LINE__, __FILE__)
+# undef _wcsdup
+# define _wcsdup(ptr) curl_dowcsdup(ptr, __LINE__, __FILE__)
+# undef _tcsdup
+# ifdef UNICODE
+# define _tcsdup(ptr) curl_dowcsdup(ptr, __LINE__, __FILE__)
+# else
+# define _tcsdup(ptr) curl_dostrdup(ptr, __LINE__, __FILE__)
+# endif
+#endif
+
#define socket(domain,type,protocol)\
curl_socket(domain,type,protocol,__LINE__,__FILE__)
#undef accept /* for those with accept as a macro */