2N/A
2N/A#pragma ident "%Z%%M% %I% %E% SMI"
2N/A
2N/A#
2N/A# This script looks for memory leaks by analyzing the output of "sqlite"
2N/A# when compiled with the MEMORY_DEBUG=2 option.
2N/A#
2N/A/[0-9]+ malloc / {
2N/A mem[$6] = $0
2N/A}
2N/A/[0-9]+ realloc / {
2N/A mem[$8] = "";
2N/A mem[$10] = $0
2N/A}
2N/A/[0-9]+ free / {
2N/A if (mem[$6]=="") {
2N/A print "*** free without a malloc at",$6
2N/A }
2N/A mem[$6] = "";
2N/A str[$6] = ""
2N/A}
2N/A/^string at / {
2N/A addr = $4
2N/A sub("string at " addr " is ","")
2N/A str[addr] = $0
2N/A}
2N/AEND {
2N/A for(addr in mem){
2N/A if( mem[addr]=="" ) continue
2N/A print mem[addr], str[addr]
2N/A }
2N/A}