tree-sitter/script/check-mallocs

13 lines
388 B
Text
Raw Normal View History

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