1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
|
#! /bin/bash
LEAKCHECKFILE="$1"
TMPFILE="${TMPDIR:-/tmp}/malloc-free-check-$$${RANDOM}${RANDOM}${RANDOM}.tmp"
export LEAKCHECKFILE TMPFILE
if [ -z "${LEAKCHECKFILE}" ]; then
echo "Usage: leakcheck <filename>" >&2
echo " filename Name of file containing debugging output" >&2
exit 1
fi
egrep '(MALLOC|FREE|REALLOC)' "${LEAKCHECKFILE}" | sed 's@^.*FREE(\(0x[0-9a-f]*\)).*$@free \1@;s@^.*MALLOC() = @malloc @;s@^.*REALLOC(\(0x[0-9a-f]*\)) = @realloc \1 @' > "${TMPFILE}"
cat "${TMPFILE}" | while read op addr newaddr; do
case "${op}" in
malloc)
if [ -z "${alloclist}" ]; then
alloclist="${addr}"
else
|
|
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
|
#! /bin/bash
LEAKCHECKFILE="$1"
TMPFILE="${TMPDIR:-/tmp}/malloc-free-check-$$${RANDOM}${RANDOM}${RANDOM}.tmp"
export LEAKCHECKFILE TMPFILE
if [ -z "${LEAKCHECKFILE}" ]; then
echo "Usage: leakcheck <filename>" >&2
echo " filename Name of file containing debugging output" >&2
exit 1
fi
egrep '(MALLOC|FREE|REALLOC)' "${LEAKCHECKFILE}" | sed 's@^.*FREE(\([x0-9a-fA-F]*\)).*$@free \1@;s@^.*MALLOC() = @malloc @;s@^.*REALLOC(\([x0-9a-fA-F]*\)) = @realloc \1 @' > "${TMPFILE}"
cat "${TMPFILE}" | while read op addr newaddr; do
case "${op}" in
malloc)
if [ -z "${alloclist}" ]; then
alloclist="${addr}"
else
|