NASM 0.98.26
[nasm/avx512.git] / misc / findleak.pl
blob727628b44aaf365b7bfe77680b86315c854600f2
1 #!/usr/bin/perl
2 my %mem = {};
3 my %alloc = {};
4 while(<>)
6 if (/realloc\((0x[0-9a-f]+).*\).*returns \((0x[0-9a-f]+)/)
8 $mem{$1}--;
9 if ($mem{$1} != 0) {
10 print "free before alloc! $_";
12 if ($mem{$2} != 0) {
13 print "memory leak! $_";
15 $mem{$2}++;
16 $alloc{$2} = $_;
18 elsif (/free\((0x[0-9a-f]+)/)
20 $mem{$1}--;
21 if ($mem{$1} != 0) {
22 print "free before alloc! $_";
25 elsif (m/returns (0x[0-9a-f]+)/)
27 if ($mem{$1} != 0) {
28 print "memory leak! $_";
30 $mem{$1}++;
31 $alloc{$1} = $_;
34 foreach $goo (sort keys %mem)
36 if ($mem{$goo})
38 print "$mem{$goo} $alloc{$goo}";
41 # From: Ed Beroset <beroset@mindspring.com>