starpu_check_malloc.sh 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. #!/bin/bash
  2. # StarPU --- Runtime system for heterogeneous multicore architectures.
  3. #
  4. # Copyright (C) 2017 CNRS
  5. #
  6. # StarPU is free software; you can redistribute it and/or modify
  7. # it under the terms of the GNU Lesser General Public License as published by
  8. # the Free Software Foundation; either version 2.1 of the License, or (at
  9. # your option) any later version.
  10. #
  11. # StarPU is distributed in the hope that it will be useful, but
  12. # WITHOUT ANY WARRANTY; without even the implied warranty of
  13. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  14. #
  15. # See the GNU Lesser General Public License in COPYING.LGPL for more details.
  16. #
  17. dirname=$(dirname $0)
  18. cd $dirname/../../../
  19. DIRS="src tools mpi/src"
  20. #sc_hypervisor/src"
  21. for d in $DIRS
  22. do
  23. STARPU_C_FILES=$(find $d -name '*.c' | tr '\012' ' ')
  24. #echo "Checking $STARPU_C_FILES"
  25. for e in "\bmalloc(" "\bcalloc(" "\brealloc("
  26. do
  27. #echo $e
  28. grep -n "$e" $STARPU_C_FILES | while read line
  29. do
  30. #echo "----------------------------------------------------------------"
  31. #echo "$line"
  32. file=$(echo $line | awk -F':' '{print $1}')
  33. count=$(echo $line | awk -F':' '{print $2}')
  34. count1=$(( count + 1 ))
  35. line1=$(grep -n "" $file | grep "^$count1:")
  36. # echo "$line1"
  37. c=$(echo "$line1" | grep -c -E "\!|NULL")
  38. # echo $c
  39. if test $c -eq 0
  40. then
  41. echo "$line"
  42. fi
  43. done
  44. done
  45. done