Index: /trunk/psLib/src/sys/psMemory.c
===================================================================
--- /trunk/psLib/src/sys/psMemory.c	(revision 11415)
+++ /trunk/psLib/src/sys/psMemory.c	(revision 11416)
@@ -10,6 +10,6 @@
 *  @author Joshua Hoblitt, University of Hawaii
 *
-*  @version $Revision: 1.89 $ $Name: not supported by cvs2svn $
-*  @date $Date: 2007-01-24 22:14:48 $
+*  @version $Revision: 1.90 $ $Name: not supported by cvs2svn $
+*  @date $Date: 2007-01-30 03:00:50 $
 *
 *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
@@ -355,5 +355,9 @@
 }
 
-int psMemCheckCorruption(FILE *output, bool abort_on_error)
+int p_psMemCheckCorruption(FILE *output,
+                           bool abort_on_error,
+                           const char *file,
+                           unsigned int lineno,
+                           const char *func)
 {
     // get exclusive access to the memBlock list to avoid it changing on us
@@ -561,12 +565,19 @@
  * Check for memory leaks.
  */
-int psMemCheckLeaks(psMemId id0,
-                    psMemBlock ***array,
-                    FILE * fd,
-                    bool persistence)
+int p_psMemCheckLeaks(psMemId id0,
+                      psMemBlock ***array,
+                      FILE * fd,
+                      bool persistence,
+                      const char *file,
+                      unsigned int lineno,
+                      const char *func)
 {
     psS32 nleak = 0;
     psS32 j = 0;
     psMemBlock *topBlock = lastMemBlockAllocated;
+
+    // make sure that the memblock list is free of corruption before we crawl
+    // the list
+    p_psMemCheckCorruption(fd, true, file, lineno, func);
 
     MUTEX_LOCK(&memBlockListMutex);
Index: /trunk/psLib/src/sys/psMemory.h
===================================================================
--- /trunk/psLib/src/sys/psMemory.h	(revision 11415)
+++ /trunk/psLib/src/sys/psMemory.h	(revision 11416)
@@ -15,6 +15,6 @@
  *  @ingroup MemoryManagement
  *
- *  @version $Revision: 1.64 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2007-01-24 22:14:48 $
+ *  @version $Revision: 1.65 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2007-01-30 03:00:50 $
  *
  *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
@@ -391,4 +391,5 @@
  *  @see psAlloc, psFree, psgetMemId, psMemProblemCallbackSet
  */
+#ifdef DOXYGEN
 int psMemCheckLeaks(
     psMemId id0,                       ///< don't list blocks with id < id0
@@ -397,4 +398,20 @@
     bool persistence                   ///< make check across all object even persistent ones
 );
+#else // ifdef DOXYGEN
+int p_psMemCheckLeaks(
+    psMemId id0,                       ///< don't list blocks with id < id0
+    psMemBlock ***array,               ///< pointer to array of pointers to leaked blocks, or NULL
+    FILE * fd,                         ///< print list of leaks to fd (or NULL)
+    bool persistence,                  ///< make check across all object even persistent ones
+    const char *file,                   ///< File of caller
+    unsigned int lineno,                ///< Line number of caller
+    const char *func                    ///< Function name of caller
+);
+#ifndef SWIG
+#define psMemCheckLeaks(id0, array, fd, persistence) \
+p_psMemCheckLeaks(id0, array, fd, persistence, __FILE__, __LINE__, __func__)
+#endif // ifndef SWIG
+#endif // ifdef DOXYGEN
+
 
 /** Check for memory corruption.  Scans all currently allocated memory buffers and checks for corruptions,
@@ -404,8 +421,23 @@
  *
  */
+#ifdef DOXYGEN
 int psMemCheckCorruption(
     FILE *output,                       ///< FILE to write corrupted blocks too
     bool abort_on_error                 ///< Abort on detecting corruption?
 );
+#else // ifdef DOXYGEN
+int p_psMemCheckCorruption(
+    FILE *output,                       ///< FILE to write corrupted blocks too
+    bool abort_on_error,                ///< Abort on detecting corruption?
+    const char *file,                   ///< File of caller
+    unsigned int lineno,                ///< Line number of caller
+    const char *func                    ///< Function name of caller
+);
+#ifndef SWIG
+#define psMemCheckCorruption(output, abort_on_error) \
+p_psMemCheckCorruption(output, abort_on_error, __FILE__, __LINE__, __func__)
+#endif // ifndef SWIG
+#endif // ifdef DOXYGEN
+
 
 /** Return reference counter
