tree-sitter/script/check-mallocs

21 lines
393 B
Text
Raw Normal View History

2016-01-15 15:08:42 -08:00
#!/usr/bin/env bash
src_dir="lib/src"
2016-01-15 15:08:42 -08:00
allocation_functions=(
malloc
calloc
realloc
free
)
for function in ${allocation_functions[@]}; do
usages=$(grep --line-number -E "\b${function}\(" -r "${src_dir}" --exclude alloc.h )
if [[ ! -z $usages ]]; then
echo "The ${function} function should not be called directly, but is called here:"
echo "$usages"
exit 1
fi
done