Index: /branches/eam_branch_20090203/psLib/src/sys/psMemory.c
===================================================================
--- /branches/eam_branch_20090203/psLib/src/sys/psMemory.c	(revision 21294)
+++ /branches/eam_branch_20090203/psLib/src/sys/psMemory.c	(revision 21295)
@@ -10,6 +10,6 @@
 *  @author Joshua Hoblitt, University of Hawaii
 *
-*  @version $Revision: 1.100 $ $Name: not supported by cvs2svn $
-*  @date $Date: 2008-08-20 02:00:20 $
+*  @version $Revision: 1.100.22.1 $ $Name: not supported by cvs2svn $
+*  @date $Date: 2009-02-04 23:37:10 $
 *
 *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
@@ -736,5 +736,7 @@
     // XXX we probably need a MUTEX_LOCK here: otherwise, two functions can race on recCounter++ and
     // refCounter--;
+    MUTEX_LOCK(&memBlockListMutex);
     memBlock->refCounter++;
+    MUTEX_UNLOCK(&memBlockListMutex);
 
     // Did the user ask to be informed about this allocation?
@@ -802,9 +804,9 @@
     // if we have multiple references, just decrement the count and return.
     // XXX we probably need a MUTEX_LOCK here: otherwise, two functions can race on refCounter--;
+    MUTEX_LOCK(&memBlockListMutex);
     if (memBlock->refCounter > 1) {
         memBlock->refCounter--;
 
         // Did the user ask to be informed about this deallocation?
-        MUTEX_LOCK(&memBlockListMutex);
         if (memBlock->id == p_psMemFreeID) {
             p_psMemFreeID += memFreeCallback(memBlock);
@@ -813,4 +815,5 @@
         return ptr;
     }
+    MUTEX_UNLOCK(&memBlockListMutex);
 
     // we can't invoke freeFunc() while we're holding memBlockListMutex as it
