#!/bin/bash

if [ $# -eq 0 ]; then
    echo "Usage: memcheck prog [args...]" >&2
    exit 1
fi

opt_gensupp='--gen-suppressions=all'
if which valgrind >/dev/null 2>&1; then
    valgrind --error-exitcode=1 --tool=memcheck --leak-check=yes --quiet \
             --suppressions=./valgrind.supp $*
else
    export MALLOC_CHECK_=3; $*
fi

