Wrap all calls to malloc and friends
This commit is contained in:
parent
19b776e74d
commit
87316f22f3
9 changed files with 79 additions and 22 deletions
20
script/check-mallocs
Executable file
20
script/check-mallocs
Executable 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
|
||||
Loading…
Add table
Add a link
Reference in a new issue