diff --git a/.gitignore b/.gitignore index 8247f0c..5896d1b 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,5 @@ bin/* !bin/.gitkeep + +valgrind.log diff --git a/scripts/.gitkeep b/scripts/.gitkeep deleted file mode 100644 index e69de29..0000000 diff --git a/scripts/valgrind_check.sh b/scripts/valgrind_check.sh new file mode 100755 index 0000000..5bd66c1 --- /dev/null +++ b/scripts/valgrind_check.sh @@ -0,0 +1,22 @@ +#! /usr/bin/env sh +# valgrind_check.sh +# Run the program with Valgrind to detect memory issues. + +main() { + local program="./bin/program" + local valgrind_log="./valgrind.log" + + local valgrind_flags="--leak-check=full --show-leak-kinds=all --track-origins=yes --verbose" + + if [[ ! -f "$program" ]]; then + echo "Error: Program '$program' not found. Build it first." + exit 1 + fi + + echo "Running Valgrind on $program..." + valgrind $valgrind_flags --log-file="$valgrind_log" "$program" + + echo "Valgrind run complete. Output saved in $valgrind_log" +} + +main $@ \ No newline at end of file