5 if [ "X$1" = "X--check" ] ; then
18 rm -f leaks-log
> /dev
/null
20 if [ "$(uname -s)" = "Darwin" ]; then
21 echo "leaks check on $name ($pid)"
22 leaks
-exclude __CFInitialize
$pid > leaks-log
2>&1 || \
23 { echo "leaks failed: $?"; cat leaks-log
; exit 1; }
25 perl
-e 'my $excluded = 0; my $num = -1; while (<>) {
26 if (/Process \d+: (\d+) leaks? for \d+ total leaked bytes?/) { $num = $1;}
27 if (/Process \d+: (\d+) leaks? malloced for \d+ total leaked byte?/) { $num = $1;}
28 if (/(\d+) leaks? excluded/) { $excluded = $1;}
30 exit 1 if ($num != 0 && $num != $excluded);
31 exit 0;' leaks-log || \
32 { echo "Memory leak in $name" ; echo ""; cat leaks-log
; ec
=1; }
34 if grep -e '1 leak for' leaks-log
> /dev
/null
&& grep -e "Leak.*environ.*__CF_USER_TEXT_ENCODING" leaks-log
> /dev
/null
; then
35 echo "just running into rdar://problem/8764394"
39 [ "$ec" != "0" ] && { echo ""; cat leaks-log
; }
41 #[ "$ec" != "0" ] && { malloc_history $pid -all_by_size > l; }
42 #[ "$ec" != "0" ] && { env PS1=": leaks-debugger !!!! ; " bash ; }
44 [ "$ec" = "0" ] && rm leaks-log
48 if [ "$checkonly" = no
] ; then
51 kill -9 $pid 2> /dev
/null