Wrap all calls to malloc and friends

This commit is contained in:
Max Brunsfeld 2016-01-15 15:08:42 -08:00
parent 19b776e74d
commit 87316f22f3
9 changed files with 79 additions and 22 deletions

20
script/check-mallocs Executable file
View file

@ -0,0 +1,20 @@
#!/usr/bin/env bash
src_dir="src/runtime"
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