Index: trunk/psLib/src/sys/psMemory.c
===================================================================
--- trunk/psLib/src/sys/psMemory.c	(revision 12886)
+++ 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;
 }
 
