mirror of
https://github.com/curl/curl.git
synced 2026-04-15 01:11:40 +03:00
memanalyze: fix warnings
Also fix possibly missing reallocated memory from 'Total allocated': ``` Use of uninitialized value $size in addition (+) at tests/memanalyze.pl line 240, <$fileh> line 4. ``` Ref: https://github.com/curl/curl/actions/runs/16565283280/job/46843800711?pr=18049#step:39:3834 Ref: https://github.com/curl/curl/actions/runs/16556860012/job/46819517495?pr=17927#step:39:156 Follow-up tofc98a630cf#18048 Follow-up to2ec54556d4#17877 Closes #18049
This commit is contained in:
parent
a28f5f68b9
commit
9a68a86ea3
1 changed files with 18 additions and 10 deletions
|
|
@ -29,6 +29,9 @@
|
|||
# MEM mprintf.c:1103 realloc(e5718, 64) = e6118
|
||||
# MEM sendf.c:232 free(f6520)
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
my $mallocs=0;
|
||||
my $callocs=0;
|
||||
my $reallocs=0;
|
||||
|
|
@ -60,15 +63,15 @@ while(@ARGV) {
|
|||
}
|
||||
}
|
||||
|
||||
my $memsum; # the total number of memory allocated over the lifetime
|
||||
my $maxmem; # the high water mark
|
||||
my $memsum = 0; # the total number of memory allocated over the lifetime
|
||||
my $maxmem = 0; # the high water mark
|
||||
|
||||
sub newtotal {
|
||||
my ($newtot)=@_;
|
||||
# count a max here
|
||||
|
||||
if($newtot > $maxmem) {
|
||||
$maxmem= $newtot;
|
||||
$maxmem = $newtot;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -199,7 +202,7 @@ while(<$fileh>) {
|
|||
my $arg1 = $1;
|
||||
my $arg2 = $2;
|
||||
|
||||
if($sizeataddr{$addr}>0) {
|
||||
if($sizeataddr{$addr} && $sizeataddr{$addr}>0) {
|
||||
# this means weeeeeirdo
|
||||
print "Mixed debug compile, rebuild curl now\n";
|
||||
}
|
||||
|
|
@ -221,14 +224,20 @@ while(<$fileh>) {
|
|||
elsif($function =~ /realloc\((\(nil\)|0x([0-9a-f]*)), (\d*)\) = 0x([0-9a-f]*)/) {
|
||||
my ($oldaddr, $newsize, $newaddr) = ($2, $3, $4);
|
||||
|
||||
$totalmem -= $sizeataddr{$oldaddr};
|
||||
if($trace) {
|
||||
printf("REALLOC: %d less bytes and ", $sizeataddr{$oldaddr});
|
||||
if($oldaddr) {
|
||||
my $oldsize = $sizeataddr{$oldaddr} ? $sizeataddr{$oldaddr} : 0;
|
||||
|
||||
$totalmem -= $oldsize;
|
||||
if($trace) {
|
||||
printf("REALLOC: %d less bytes and ", $oldsize);
|
||||
}
|
||||
$sizeataddr{$oldaddr}=0;
|
||||
|
||||
$getmem{$oldaddr}="";
|
||||
}
|
||||
$sizeataddr{$oldaddr}=0;
|
||||
|
||||
$totalmem += $newsize;
|
||||
$memsum += $size;
|
||||
$memsum += $newsize;
|
||||
$sizeataddr{$newaddr}=$newsize;
|
||||
|
||||
if($trace) {
|
||||
|
|
@ -238,7 +247,6 @@ while(<$fileh>) {
|
|||
newtotal($totalmem);
|
||||
$reallocs++;
|
||||
|
||||
$getmem{$oldaddr}="";
|
||||
$getmem{$newaddr}="$source:$linenum";
|
||||
}
|
||||
elsif($function =~ /strdup\(0x([0-9a-f]*)\) \((\d*)\) = 0x([0-9a-f]*)/) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue