Commits

marcus  committed 5f4a3d7

Added valgrind script for memory leak checking.

  • Participants
  • Parent commits b7d11eb
  • Branches pgreloaded

Comments (0)

Files changed (3)

File src/base/streamwrapper.c

     interp = thread->interp;
     wrapper->thread = PyThreadState_New (interp);
 #endif
-    
+
     if (PyObject_HasAttrString (obj, "read"))
     {
         wrapper->read = PyObject_GetAttrString (obj, "read");

File src/sdl/rwopsmod.c

     SDL_RWops *ops;
     PyInterpreterState* interp;
     PyThreadState* thread;
-    
+
     if (!obj || !canautoclose)
     {
         PyErr_SetString (PyExc_TypeError, "argument is NULL");
     SDL_RWops *ops;
     PyInterpreterState* interp;
     PyThreadState* thread;
-    
+
     if (!obj || !canautoclose)
     {
         PyErr_SetString (PyExc_TypeError, "argument is NULL");

File util/valgrind.sh

+#!/bin/sh
+
+# Path to the debug version of python
+: ${PYDEBUG:="/opt/python-debug/bin/python"}
+# Valgrind checker application and the default arguments to use.
+: ${VALGRIND:="valgrind"}
+: ${VALGRINDARGS:="--tool=memcheck --leak-check=summary"}
+
+usage()
+{
+    echo "usage: `basename $0` [-f|-r|-s] file ..."
+}
+
+while getopts frs arg; do
+    case $arg in
+        f)
+            DEFARGS="--tool=memcheck --leak-check=full"
+            ;;
+        r)
+            DEFARGS="--tool=memcheck --leak-check=full --show-reachable=yes"
+            ;;
+        s)
+            DEFARGS="--tool=memcheck --leak-check=summary"
+            ;;
+        \? | h)
+            usage
+            exit 2
+    esac
+done
+
+shift $(expr $OPTIND - 1)
+if [ $# -eq 0 ]; then
+    usage
+    exit 1
+fi
+
+for f in $@; do
+    $VALGRIND $DEFARGS $PYDEBUG -E $f
+done