File: memleak.awk

package info (click to toggle)
sqlite 2.4.7-1
  • links: PTS
  • area: main
  • in suites: woody
  • size: 3,080 kB
  • ctags: 1,881
  • sloc: ansic: 21,330; tcl: 7,046; sh: 6,830; yacc: 474; makefile: 464; awk: 73
file content (26 lines) | stat: -rw-r--r-- 425 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#
# This script looks for memory leaks by analyzing the output of "sqlite" 
# when compiled with the MEMORY_DEBUG=2 option.
#
/^malloc / {
  mem[$5] = $0
}
/^realloc / {
  mem[$7] = "";
  mem[$9] = $0
}
/^free / {
  mem[$5] = "";
  str[$5] = ""
}
/^string at / {
  addr = $3
  sub("string at " addr " is ","")
  str[addr] = $0
}
END {
  for(addr in mem){
    if( mem[addr]=="" ) continue
    print mem[addr], str[addr]
  }
}