Artifact ebd6df1f69c757b3364b5ce3e38fbdee82db499e:
- Executable file
leakcheck/check-malloc-free.sh
— part of check-in
[709b50760d]
at
2010-05-15 00:34:57
on branch trunk
— Added line numbers to debugging output
Added overloaded debugging strdup to check for leaks (user: rkeene, size: 1317) [annotate] [blame] [check-ins using]
- Executable file
leakcheck/leakcheck
— part of check-in
[168d86b82b]
at
2010-05-15 00:48:38
on branch trunk
— Renamed leakcheck tool
Added documentation for leakcheck tool (user: rkeene, size: 1317) [annotate] [blame] [check-ins using]
#! /bin/bash TMPFILE="${TMPDIR:-/tmp}/malloc-free-check-$$${RANDOM}${RANDOM}${RANDOM}.tmp" egrep '(MALLOC|FREE|REALLOC)' "$@" | 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 alloclist="${alloclist} ${addr}" fi ;; free) if ! echo " ${alloclist} " | grep " ${addr} " >/dev/null; then if [ -z "${alloclist}" ]; then alloclist="!${addr}" else alloclist="${alloclist} !${addr}" fi continue fi alloclist="$(echo " ${alloclist} " | sed "s@ ${addr} @ @;s@^ *@@;s@ *\$@@")" ;; realloc) alloclist="$(echo " ${alloclist} " | sed "s@ ${addr} @ ${newaddr} @;s@^ *@@;s@ *\$@@")" ;; esac echo "${alloclist}" done | tail -1 | while read leftovers; do for leftover in ${leftovers}; do case "${leftover}" in !*) leftover="$(echo "${leftover}" | cut -c 2-)" echo "Double freed or never allocated ${leftover}:" grep "${leftover}" "$@" | sed 's@^@ @' echo '' ;; *) echo "Unfreed memory ${leftover}:" grep "${leftover}" "$@" | sed 's@^@ @' echo '' ;; esac done done rm -f "${TMPFILE}"