"Fossies" - the Fresh Open Source Software Archive

Member "mpr-2.8/mprleak" (3 Nov 2002, 769 Bytes) of package /linux/misc/old/mpr-2.8.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) Bash source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file.

    1 #!/bin/sh
    2 
    3 MPRAWK=${MPRAWK-awk}
    4 
    5 case "$#" in
    6 0|1)    ;;
    7 *)  echo "usage: mprleak [log]" >&2
    8     exit 1;;
    9 esac
   10 
   11 MPRFILTER=`mprfilter mprleak "$@"` || exit 1
   12 
   13 trap 'exit 0' 13
   14 
   15 $MPRFILTER |
   16 
   17 $MPRAWK -F: '
   18     /^m/ {
   19         if ($NF)
   20             malloc[$NF]=sprintf("%d:%s", NR, $0)
   21     }
   22     /^f/ {
   23         if ($NF && !malloc[$NF])
   24             printf "mprleak: %s (NR=%d)\n", $0, NR |"cat 1>&2"
   25         delete malloc[$NF]
   26     }
   27     /^r/ {
   28         if ($(NF-1) && !malloc[$(NF-1)]) {
   29             printf "mprleak: %s (NR=%d)\n", $0, NR |"cat 1>&2"
   30             delete malloc[$(NF-1)]
   31         }
   32         if (!$(NF-2) || $NF)
   33             delete malloc[$(NF-1)]
   34         if ($NF)
   35             malloc[$NF]=sprintf("%d:%s", NR, $0)
   36     }
   37     END  {
   38         for (i in malloc)
   39             print malloc[i]
   40     }' |
   41 
   42 sort -n -t: | cut -d: -f2- |
   43 
   44 $MPRAWK -F: '
   45     /^m/ { if ($(NF-1)) print }
   46     /^r/ { if ($(NF-2)) print }'
   47 
   48 exit 0