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