xref: /titanic_41/usr/src/lib/libsqlite/tool/memleak.awk (revision 82629e3015252bf18319ba3815c773df23e21436)
1
2#pragma ident	"%Z%%M%	%I%	%E% SMI"
3
4#
5# This script looks for memory leaks by analyzing the output of "sqlite"
6# when compiled with the MEMORY_DEBUG=2 option.
7#
8/[0-9]+ malloc / {
9  mem[$6] = $0
10}
11/[0-9]+ realloc / {
12  mem[$8] = "";
13  mem[$10] = $0
14}
15/[0-9]+ free / {
16  if (mem[$6]=="") {
17    print "*** free without a malloc at",$6
18  }
19  mem[$6] = "";
20  str[$6] = ""
21}
22/^string at / {
23  addr = $4
24  sub("string at " addr " is ","")
25  str[addr] = $0
26}
27END {
28  for(addr in mem){
29    if( mem[addr]=="" ) continue
30    print mem[addr], str[addr]
31  }
32}
33