Index: trunk/psLib/src/sys/psAssert.h
===================================================================
--- trunk/psLib/src/sys/psAssert.h	(revision 14674)
+++ trunk/psLib/src/sys/psAssert.h	(revision 14676)
@@ -20,15 +20,13 @@
 }
 
-// Ensure this is a psLib pointer, by checking for the memblock bounds.
-#define PS_ASSERT_PTR(NAME, RVAL) \
+// Ensure this is a psLib pointer
+#define PS_ASSERT_PTR(PTR, RVAL) \
 { \
-    if (NAME == NULL) return(RVAL); \
-    psMemBlock *mb = (psMemBlock*)(NAME) - 1; \
-    if (mb->startblock != P_PS_MEMMAGIC || mb->endblock != P_PS_MEMMAGIC || \
-            *(psU32 *)((char *)(mb + 1) + mb->userMemorySize) != P_PS_MEMMAGIC) { \
+    if (PTR == NULL) return RVAL; \
+    if (!psMemIsAlloced(PTR)) { \
         psError(PS_ERR_MEMORY_CORRUPTION, false, \
-                "Error: Pointer %s is corrupted or not on the PS memory system.", \
-                #NAME); \
-        return (RVAL); \
+            "Error: Pointer %p is corrupted or not on the PS memory system.", \
+            PTR); \
+        return RVAL; \
     } \
 }
Index: trunk/psLib/src/sys/psMemory.c
===================================================================
--- trunk/psLib/src/sys/psMemory.c	(revision 14674)
+++ trunk/psLib/src/sys/psMemory.c	(revision 14676)
@@ -10,6 +10,6 @@
 *  @author Joshua Hoblitt, University of Hawaii
 *
-*  @version $Revision: 1.96 $ $Name: not supported by cvs2svn $
-*  @date $Date: 2007-04-18 19:38:10 $
+*  @version $Revision: 1.97 $ $Name: not supported by cvs2svn $
+*  @date $Date: 2007-08-27 23:14:35 $
 *
 *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
@@ -374,5 +374,4 @@
                 MUTEX_UNLOCK(&memBlockListMutex);
                 PS_MEM_ABORT(__func__, "Detected memory corruption");
-                return nbad;
             }
         }
@@ -383,4 +382,33 @@
 
     return nbad;
+}
+
+bool p_psMemIsAlloced(const char *file,
+                      unsigned int lineno,
+                      const char *func,
+                      const void *ptr)
+{
+    // if ptr is a psAlloc()'d memory, find the actual address of the memBlock
+    psMemBlock *addr = ((psMemBlock *)ptr) - 1;
+
+    // get exclusive access to the memBlock list to avoid it changing on us
+    // while we use it.
+    MUTEX_LOCK(&memBlockListMutex);
+
+    // loop through the linked list of memBlocks looking for a matching pointer
+    for (psMemBlock *memBlock = lastMemBlockAllocated; memBlock != NULL; memBlock = memBlock->nextBlock) {
+        if (memBlock == addr) {
+            // we found the memBlock
+            HANDLE_BAD_BLOCK(memBlock, file, lineno, func);
+
+            MUTEX_UNLOCK(&memBlockListMutex);
+            return true;
+        }
+    }
+
+    // release the lock on the memblock list
+    MUTEX_UNLOCK(&memBlockListMutex);
+
+    return false;
 }
 
Index: trunk/psLib/src/sys/psMemory.h
===================================================================
--- trunk/psLib/src/sys/psMemory.h	(revision 14674)
+++ trunk/psLib/src/sys/psMemory.h	(revision 14676)
@@ -15,6 +15,6 @@
  *  @ingroup MemoryManagement
  *
- *  @version $Revision: 1.69 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2007-03-09 20:11:04 $
+ *  @version $Revision: 1.70 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2007-08-27 23:14:35 $
  *
  *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
@@ -407,4 +407,25 @@
 #endif // ifdef DOXYGEN
 
+/** Checks to see if a pointer is to a region of memory that was allocated by psAlloc().
+ *  @return bool
+ *
+ */
+#ifdef DOXYGEN
+bool psMemIsAlloced(
+    const void *ptr                           ///< pointer to memory
+);
+#else // ifdef DOXYGEN
+bool p_psMemIsAlloced(
+    const char *file,
+    unsigned int lineno,
+    const char *func,
+    const void *ptr
+);
+#ifndef SWIG
+#define psMemIsAlloced(ptr) \
+      p_psMemIsAlloced(__FILE__, __LINE__, __func__, ptr)
+#endif // ifndef SWIG
+#endif // ifdef DOXYGEN
+
 
 /** Return reference counter
