From 90695fb2c508803a09581b0ca8f55eaa36749a69 Mon Sep 17 00:00:00 2001 From: Yang Tse Date: Thu, 18 Jul 2013 20:04:02 +0200 Subject: 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. --- tests/memanalyze.pl | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) (limited to 'tests/memanalyze.pl') diff --git a/tests/memanalyze.pl b/tests/memanalyze.pl index 524634969..54117f8ea 100755 --- a/tests/memanalyze.pl +++ b/tests/memanalyze.pl @@ -31,6 +31,7 @@ my $mallocs=0; my $callocs=0; my $reallocs=0; my $strdups=0; +my $wcsdups=0; my $showlimit; while(1) { @@ -220,6 +221,25 @@ while() { newtotal($totalmem); $strdups++; } + elsif($function =~ /wcsdup\(0x([0-9a-f]*)\) \((\d*)\) = 0x([0-9a-f]*)/) { + # wcsdup(a5b50) (8) = df7c0 + + $dup = $1; + $size = $2; + $addr = $3; + $getmem{$addr}="$source:$linenum"; + $sizeataddr{$addr}=$size; + + $totalmem += $size; + + if($trace) { + printf("WCSDUP: $size bytes at %s, makes totally: %d bytes\n", + $getmem{$addr}, $totalmem); + } + + newtotal($totalmem); + $wcsdups++; + } else { print "Not recognized input line: $function\n"; } @@ -378,8 +398,9 @@ if($verbose) { "Reallocs: $reallocs\n", "Callocs: $callocs\n", "Strdups: $strdups\n", + "Wcsdups: $wcsdups\n", "Frees: $frees\n", - "Allocations: ".($mallocs + $callocs + $reallocs + $strdups)."\n"; + "Allocations: ".($mallocs + $callocs + $reallocs + $strdups + $wcsdups)."\n"; print "Maximum allocated: $maxmem\n"; } -- cgit v1.2.3