diff options
Diffstat (limited to 'libraries/sqlite/unix/sqlite-3.5.1/tool/memleak.awk')
-rw-r--r-- | libraries/sqlite/unix/sqlite-3.5.1/tool/memleak.awk | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/libraries/sqlite/unix/sqlite-3.5.1/tool/memleak.awk b/libraries/sqlite/unix/sqlite-3.5.1/tool/memleak.awk new file mode 100644 index 0000000..928d3b6 --- /dev/null +++ b/libraries/sqlite/unix/sqlite-3.5.1/tool/memleak.awk | |||
@@ -0,0 +1,29 @@ | |||
1 | # | ||
2 | # This script looks for memory leaks by analyzing the output of "sqlite" | ||
3 | # when compiled with the SQLITE_DEBUG=2 option. | ||
4 | # | ||
5 | /[0-9]+ malloc / { | ||
6 | mem[$6] = $0 | ||
7 | } | ||
8 | /[0-9]+ realloc / { | ||
9 | mem[$8] = ""; | ||
10 | mem[$10] = $0 | ||
11 | } | ||
12 | /[0-9]+ free / { | ||
13 | if (mem[$6]=="") { | ||
14 | print "*** free without a malloc at",$6 | ||
15 | } | ||
16 | mem[$6] = ""; | ||
17 | str[$6] = "" | ||
18 | } | ||
19 | /^string at / { | ||
20 | addr = $4 | ||
21 | sub("string at " addr " is ","") | ||
22 | str[addr] = $0 | ||
23 | } | ||
24 | END { | ||
25 | for(addr in mem){ | ||
26 | if( mem[addr]=="" ) continue | ||
27 | print mem[addr], str[addr] | ||
28 | } | ||
29 | } | ||