summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Stenberg <daniel@haxx.se>2000-12-19 13:32:30 +0000
committerDaniel Stenberg <daniel@haxx.se>2000-12-19 13:32:30 +0000
commit0db48a810959c826c5c7cba1f721e2c76ebc953c (patch)
tree5c9b66dc2d13dd93b7af3222446cb5a7920c4b24
parent5594741acbb6fb88ad840c6fa7ca328ff032497c (diff)
downloadgnurl-0db48a810959c826c5c7cba1f721e2c76ebc953c.tar.gz
gnurl-0db48a810959c826c5c7cba1f721e2c76ebc953c.tar.bz2
gnurl-0db48a810959c826c5c7cba1f721e2c76ebc953c.zip
analyzes fopen() leaks as well
-rwxr-xr-xmemanalyze.pl38
1 files changed, 38 insertions, 0 deletions
diff --git a/memanalyze.pl b/memanalyze.pl
index aa8dddb13..c2ac11e7b 100755
--- a/memanalyze.pl
+++ b/memanalyze.pl
@@ -99,6 +99,35 @@ while(<STDIN>) {
}
}
}
+ # FILE url.c:1282 fopen("blabla") = 0x5ddd
+ elsif($_ =~ /^FILE ([^:]*):(\d*) (.*)/) {
+ # generic match for the filename+linenumber
+ $source = $1;
+ $linenum = $2;
+ $function = $3;
+
+ if($function =~ /fopen\(\"([^\"]*)\"\) = (\(nil\)|0x([0-9a-f]*))/) {
+ if($2 eq "(nil)") {
+ ;
+ }
+ else {
+ $fopen{$3}=1;
+ $fopenfile{$3}="$source:$linenum";
+ $fopens++;
+ }
+ }
+ # fclose(0x1026c8)
+ elsif($function =~ /fclose\(0x([0-9a-f]*)\)/) {
+ print "CLOSE $1\n";
+ if(!$fopen{$1}) {
+ print "fclose() without fopen(): $line\n";
+ }
+ else {
+ $fopen{$1}=0;
+ $fopens--;
+ }
+ }
+ }
else {
print "Not recognized prefix line: $line\n";
}
@@ -127,3 +156,12 @@ if($openfile) {
}
}
}
+
+if($fopens) {
+ print "Open FILE handles left at:\n";
+ for(keys %fopen) {
+ if($fopen{$_} == 1) {
+ print "fopen() called at ".$fopenfile{$_}."\n";
+ }
+ }
+}