aboutsummaryrefslogtreecommitdiff
path: root/tests/memanalyze.pl
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 /tests/memanalyze.pl
parentc5eabd48e8dbc8393723bb79f0040475d850f389 (diff)
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 'tests/memanalyze.pl')
-rwxr-xr-xtests/memanalyze.pl23
1 files changed, 22 insertions, 1 deletions
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(<FILE>) {
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";
}