Index: trunk/psLib/src/sys/psMemory.c
===================================================================
--- trunk/psLib/src/sys/psMemory.c	(revision 1360)
+++ trunk/psLib/src/sys/psMemory.c	(revision 1385)
@@ -8,6 +8,6 @@
 *  @author Robert Lupton, Princeton University
 *
-*  @version $Revision: 1.30 $ $Name: not supported by cvs2svn $
-*  @date $Date: 2004-07-31 02:28:10 $
+*  @version $Revision: 1.31 $ $Name: not supported by cvs2svn $
+*  @date $Date: 2004-08-04 23:37:39 $
 *
 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
@@ -47,5 +47,5 @@
         NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL
     };
-    
+
 #ifdef PS_MEM_DEBUG
 static psMemBlock* deadBlockList;    // a place to put dead memBlocks in debug mode.
@@ -62,18 +62,18 @@
 {
     void * ptr = NULL;
-    
+
     pthread_mutex_lock( &recycleMemBlockListMutex );
     int level = recycleBins - 1;
     while ( level >= 0 && ptr == NULL ) {
-            while ( recycleMemBlockList[ level ] != NULL && ptr == NULL ) {
-                    psMemBlock * old = recycleMemBlockList[ level ];
-                    recycleMemBlockList[ level ] = recycleMemBlockList[ level ] ->nextBlock;
-                    free( old );
-                    ptr = malloc( size );
-                }
-            level--;
-        }
+        while ( recycleMemBlockList[ level ] != NULL && ptr == NULL ) {
+            psMemBlock * old = recycleMemBlockList[ level ];
+            recycleMemBlockList[ level ] = recycleMemBlockList[ level ] ->nextBlock;
+            free( old );
+            ptr = malloc( size );
+        }
+        level--;
+    }
     pthread_mutex_unlock( &recycleMemBlockListMutex );
-    
+
     return ptr;
 }
@@ -84,11 +84,11 @@
 {
     psMemExhaustedCallback old = memExhaustedCallback;
-    
+
     if ( func != NULL ) {
-            memExhaustedCallback = func;
-        } else {
-            memExhaustedCallback = memExhaustedCallbackDefault;
-        }
-        
+        memExhaustedCallback = func;
+    } else {
+        memExhaustedCallback = memExhaustedCallbackDefault;
+    }
+
     return old;
 }
@@ -98,12 +98,12 @@
 {
     if ( ptr->refCounter < 1 ) {
-            psError( __func__,
-                     "Block %ld allocated at %s:%d freed more than once at %s:%d\n",
-                     ptr->id, ptr->file, ptr->lineno, file, lineno );
-        }
-        
+        psError( __func__,
+                 "Block %ld allocated at %s:%d freed more than once at %s:%d\n",
+                 ptr->id, ptr->file, ptr->lineno, file, lineno );
+    }
+
     if ( lineno > 0 ) {
-            psAbort( __func__, "Detected a problem in the memory system at %s:%d", file, lineno );
-        }
+        psAbort( __func__, "Detected a problem in the memory system at %s:%d", file, lineno );
+    }
 }
 static psMemProblemCallback memProblemCallback = memProblemCallbackDefault;
@@ -112,11 +112,11 @@
 {
     psMemProblemCallback old = memProblemCallback;
-    
+
     if ( func != NULL ) {
-            memProblemCallback = func;
-        } else {
-            memProblemCallback = memProblemCallbackDefault;
-        }
-        
+        memProblemCallback = func;
+    } else {
+        memProblemCallback = memProblemCallbackDefault;
+    }
+
     return old;
 }
@@ -133,5 +133,5 @@
     psMemoryId old = p_psMemAllocateID;
     p_psMemAllocateID = id;
-    
+
     return old;
 }
@@ -141,5 +141,5 @@
     psMemoryId old = p_psMemFreeID;
     p_psMemFreeID = id;
-    
+
     return old;
 }
@@ -154,5 +154,5 @@
 {
     static psMemoryId incr = 0;  // "p_psMemAllocateID += incr"
-    
+
     return incr;
 }
@@ -161,5 +161,5 @@
 {
     static psMemoryId incr = 0;  // "p_psMemFreeID += incr"
-    
+
     return incr;
 }
@@ -174,11 +174,11 @@
 {
     psMemFreeCallback old = memAllocateCallback;
-    
+
     if ( func != NULL ) {
-            memAllocateCallback = func;
-        } else {
-            memAllocateCallback = memAllocateCallbackDefault;
-        }
-        
+        memAllocateCallback = func;
+    } else {
+        memAllocateCallback = memAllocateCallbackDefault;
+    }
+
     return old;
 }
@@ -187,11 +187,11 @@
 {
     psMemFreeCallback old = memFreeCallback;
-    
+
     if ( func != NULL ) {
-            memFreeCallback = func;
-        } else {
-            memFreeCallback = memFreeCallbackDefault;
-        }
-        
+        memFreeCallback = func;
+    } else {
+        memFreeCallback = memFreeCallbackDefault;
+    }
+
     return old;
 }
@@ -206,5 +206,5 @@
     id = memid + 1;
     pthread_mutex_unlock( &memIdMutex );
-    
+
     return id;
 }
@@ -220,28 +220,28 @@
     // n.b. since this is called by psMemCheckCorruption while the memblock list is mutex locked,
     // we shouldn't call such things as p_psAlloc/p_psFree here.
-    
+
     if ( m == NULL ) {
-            psError( funcName, "Memory Corruption: NULL memory block found." );
-            return 1;
-        }
-        
+        psError( funcName, "Memory Corruption: NULL memory block found." );
+        return 1;
+    }
+
     if ( m->refCounter == 0 ) {
-            // using an unreferenced block of memory, are you?
-            psError( __func__, "Memory Corruption: memory block %ld was freed but still used.",
-                     m->id );
-            return 1;
-        }
-        
+        // using an unreferenced block of memory, are you?
+        psError( __func__, "Memory Corruption: memory block %ld was freed but still used.",
+                 m->id );
+        return 1;
+    }
+
     if ( m->startblock != P_PS_MEMMAGIC || m->endblock != P_PS_MEMMAGIC ) {
-            psError( funcName, "Memory Corruption: memory block %ld is corrupted (buffer underflow)",
-                     m->id );
-            return 1;
-        }
+        psError( funcName, "Memory Corruption: memory block %ld is corrupted (buffer underflow)",
+                 m->id );
+        return 1;
+    }
     if ( *( void** ) ( ( int8_t* ) ( m + 1 ) + m->userMemorySize ) != P_PS_MEMMAGIC ) {
-            psError( funcName, "Memory Corruption: memory block %ld is corrupted (buffer overflow)",
-                     m->id );
-            return 1;
-        }
-        
+        psError( funcName, "Memory Corruption: memory block %ld is corrupted (buffer overflow)",
+                 m->id );
+        return 1;
+    }
+
     return 0;
 }
@@ -250,23 +250,23 @@
 {
     int nbad = 0;                       // number of bad blocks
-    
+
     // get exclusive access to the memBlock list to avoid it changing on us while we use it.
     pthread_mutex_lock( &memBlockListMutex );
-    
+
     for ( psMemBlock * iter = lastMemBlockAllocated; iter != NULL; iter = iter->nextBlock ) {
-            if ( checkMemBlock( iter, __func__ ) ) {
-                    nbad++;
-                    
-                    memProblemCallback( iter, __func__, __LINE__ );
-                    
-                    if ( abort_on_error ) {
-                            // release the lock on the memblock list
-                            pthread_mutex_unlock( &memBlockListMutex );
-                            psAbort( __func__, "Detected memory corruption" );
-                            return nbad;
-                        }
-                }
-        }
-        
+        if ( checkMemBlock( iter, __func__ ) ) {
+            nbad++;
+
+            memProblemCallback( iter, __func__, __LINE__ );
+
+            if ( abort_on_error ) {
+                // release the lock on the memblock list
+                pthread_mutex_unlock( &memBlockListMutex );
+                psAbort( __func__, "Detected memory corruption" );
+                return nbad;
+            }
+        }
+    }
+
     // release the lock on the memblock list
     pthread_mutex_unlock( &memBlockListMutex );
@@ -278,54 +278,54 @@
 
     psMemBlock * ptr = NULL;
-    
+
     // memory is of the size I want to bother recycling?
     if ( size < P_PS_LARGE_BLOCK_SIZE ) {
-            // find the bin we need.
-            int level = 0;
-            while ( size > recycleBinSize[ level ] ) {
-                    level++;
+        // find the bin we need.
+        int level = 0;
+        while ( size > recycleBinSize[ level ] ) {
+            level++;
+        }
+        // Are we in one of the bins
+        if ( level < recycleBins ) {
+
+            size = recycleBinSize[ level ];  // round-up size to next sized bin.
+
+            pthread_mutex_lock( &recycleMemBlockListMutex );
+
+            if ( recycleMemBlockList[ level ] != NULL ) {
+                ptr = recycleMemBlockList[ level ];
+                recycleMemBlockList[ level ] = ptr->nextBlock;
+                if ( recycleMemBlockList[ level ] != NULL ) {
+                    recycleMemBlockList[ level ] ->previousBlock = NULL;
                 }
-            // Are we in one of the bins
-            if ( level < recycleBins ) {
-            
-                    size = recycleBinSize[ level ];  // round-up size to next sized bin.
-                    
-                    pthread_mutex_lock( &recycleMemBlockListMutex );
-                    
-                    if ( recycleMemBlockList[ level ] != NULL ) {
-                            ptr = recycleMemBlockList[ level ];
-                            recycleMemBlockList[ level ] = ptr->nextBlock;
-                            if ( recycleMemBlockList[ level ] != NULL ) {
-                                    recycleMemBlockList[ level ] ->previousBlock = NULL;
-                                }
-                            size = ptr->userMemorySize;
-                        }
-                        
-                    pthread_mutex_unlock( &recycleMemBlockListMutex );
-                }
-        }
-        
+                size = ptr->userMemorySize;
+            }
+
+            pthread_mutex_unlock( &recycleMemBlockListMutex );
+        }
+    }
+
     if ( ptr == NULL ) {
-            ptr = malloc( sizeof( psMemBlock ) + size + sizeof( void* ) );
-            
+        ptr = malloc( sizeof( psMemBlock ) + size + sizeof( void* ) );
+
+        if ( ptr == NULL ) {
+            ptr = memExhaustedCallback( size );
             if ( ptr == NULL ) {
-                    ptr = memExhaustedCallback( size );
-                    if ( ptr == NULL ) {
-                            psAbort( __func__, "Failed to allocate %u bytes at %s:%d",
-                                     size, file, lineno );
-                        }
-                }
-                
-            ptr->startblock = P_PS_MEMMAGIC;
-            ptr->endblock = P_PS_MEMMAGIC;
-            ptr->userMemorySize = size;
-            pthread_mutex_init( &ptr->refCounterMutex, NULL );
-        }
-        
+                psAbort( __func__, "Failed to allocate %u bytes at %s:%d",
+                         size, file, lineno );
+            }
+        }
+
+        ptr->startblock = P_PS_MEMMAGIC;
+        ptr->endblock = P_PS_MEMMAGIC;
+        ptr->userMemorySize = size;
+        pthread_mutex_init( &ptr->refCounterMutex, NULL );
+    }
+
     // increment the memory id safely.
     pthread_mutex_lock( &memBlockListMutex );
     *( psMemoryId* ) & ptr->id = ++memid;
     pthread_mutex_unlock( &memBlockListMutex );
-    
+
     ptr->file = file;
     ptr->freeFcn = NULL;
@@ -333,24 +333,24 @@
     *( void** ) ( ( int8_t* ) ( ptr + 1 ) + size ) = P_PS_MEMMAGIC;
     ptr->previousBlock = NULL;
-    
+
     ptr->refCounter = 1;                // one user so far
-    
+
     // need exclusive access of the memory block list now...
     pthread_mutex_lock( &memBlockListMutex );
-    
+
     // insert the new block to the front of the memBlock linked-list
     ptr->nextBlock = lastMemBlockAllocated;
     if ( ptr->nextBlock != NULL ) {
-            ptr->nextBlock->previousBlock = ptr;
-        }
+        ptr->nextBlock->previousBlock = ptr;
+    }
     lastMemBlockAllocated = ptr;
-    
+
     pthread_mutex_unlock( &memBlockListMutex );
-    
+
     //  Did the user ask to be informed about this allocation?
     if ( ptr->id == p_psMemAllocateID ) {
-            p_psMemAllocateID += memAllocateCallback( ptr );
-        }
-        
+        p_psMemAllocateID += memAllocateCallback( ptr );
+    }
+
     // And return the user the memory that they allocated
     return ptr + 1;   // user memory
@@ -360,50 +360,50 @@
 {
     if ( vptr == NULL ) {
-            return p_psAlloc( size, file, lineno );
-        } else {
-            psMemBlock *ptr = ( ( psMemBlock * ) vptr ) - 1;
-            bool isBlockLast = false;
-            
-            if ( checkMemBlock( ptr, __func__ ) != 0 ) {
-                    memProblemCallback( ptr, file, lineno );
-                    psAbort( file, "Realloc detected a memory corruption (id %ld @ %s:%d).",
-                             ptr->id, ptr->file, ptr->lineno );
-                }
-                
-            pthread_mutex_lock( &memBlockListMutex );
-            
-            isBlockLast = ( ptr == lastMemBlockAllocated );
-            
-            ptr = ( psMemBlock* ) realloc( ptr, sizeof( psMemBlock ) + size + sizeof( void* ) );
-            
-            if ( ptr == NULL ) {
-                    psAbort( __func__, "Failed to reallocate %ld bytes at %s:%d",
-                             size, file, lineno );
-                }
-                
-            ptr->userMemorySize = size;
-            *( void** ) ( ( int8_t* ) ( ptr + 1 ) + size ) = P_PS_MEMMAGIC;
-            
-            if ( isBlockLast ) {
-                    lastMemBlockAllocated = ptr;
-                }
-                
-            // the block location may have changed, so fix the linked list addresses.
-            if ( ptr->nextBlock != NULL ) {
-                    ptr->nextBlock->previousBlock = ptr;
-                }
-            if ( ptr->previousBlock != NULL ) {
-                    ptr->previousBlock->nextBlock = ptr;
-                }
-                
-            pthread_mutex_unlock( &memBlockListMutex );
-            
-            //  Did the user ask to be informed about this allocation?
-            if ( ptr->id == p_psMemAllocateID ) {
-                    p_psMemAllocateID += memAllocateCallback( ptr );
-                }
-                
-            return ptr + 1;   // usr memory
-        }
+        return p_psAlloc( size, file, lineno );
+    } else {
+        psMemBlock *ptr = ( ( psMemBlock * ) vptr ) - 1;
+        bool isBlockLast = false;
+
+        if ( checkMemBlock( ptr, __func__ ) != 0 ) {
+            memProblemCallback( ptr, file, lineno );
+            psAbort( file, "Realloc detected a memory corruption (id %ld @ %s:%d).",
+                     ptr->id, ptr->file, ptr->lineno );
+        }
+
+        pthread_mutex_lock( &memBlockListMutex );
+
+        isBlockLast = ( ptr == lastMemBlockAllocated );
+
+        ptr = ( psMemBlock* ) realloc( ptr, sizeof( psMemBlock ) + size + sizeof( void* ) );
+
+        if ( ptr == NULL ) {
+            psAbort( __func__, "Failed to reallocate %ld bytes at %s:%d",
+                     size, file, lineno );
+        }
+
+        ptr->userMemorySize = size;
+        *( void** ) ( ( int8_t* ) ( ptr + 1 ) + size ) = P_PS_MEMMAGIC;
+
+        if ( isBlockLast ) {
+            lastMemBlockAllocated = ptr;
+        }
+
+        // the block location may have changed, so fix the linked list addresses.
+        if ( ptr->nextBlock != NULL ) {
+            ptr->nextBlock->previousBlock = ptr;
+        }
+        if ( ptr->previousBlock != NULL ) {
+            ptr->previousBlock->nextBlock = ptr;
+        }
+
+        pthread_mutex_unlock( &memBlockListMutex );
+
+        //  Did the user ask to be informed about this allocation?
+        if ( ptr->id == p_psMemAllocateID ) {
+            p_psMemAllocateID += memAllocateCallback( ptr );
+        }
+
+        return ptr + 1;   // usr memory
+    }
 }
 
@@ -421,41 +421,41 @@
     int j = 0;
     psMemBlock* topBlock = lastMemBlockAllocated;
-    
+
     pthread_mutex_lock( &memBlockListMutex );
-    
+
     for ( psMemBlock * iter = topBlock; iter != NULL; iter = iter->nextBlock ) {
-            if ( ( psMemGetRefCounter( iter + 1 ) > 0 ) && ( iter->id >= id0 ) ) {
-                    nleak++;
-                    
-                    if ( fd != NULL ) {
-                            if ( nleak == 1 ) {
-                                    fprintf( fd, "   %20s:line ID\n", "file" );
-                                }
-                                
-                            fprintf( fd, "   %20s:%-4d %ld\n", iter->file, iter->lineno, iter->id );
-                        }
+        if ( ( psMemGetRefCounter( iter + 1 ) > 0 ) && ( iter->id >= id0 ) ) {
+            nleak++;
+
+            if ( fd != NULL ) {
+                if ( nleak == 1 ) {
+                    fprintf( fd, "   %20s:line ID\n", "file" );
                 }
-        }
-        
+
+                fprintf( fd, "   %20s:%-4d %ld\n", iter->file, iter->lineno, iter->id );
+            }
+        }
+    }
+
     pthread_mutex_unlock( &memBlockListMutex );
-    
+
     if ( nleak == 0 || arr == NULL ) {
-            return nleak;
-        }
-        
+        return nleak;
+    }
+
     *arr = p_psAlloc( nleak * sizeof( psMemBlock ), __FILE__, __LINE__ );
     pthread_mutex_lock( &memBlockListMutex );
-    
+
     for ( psMemBlock * iter = topBlock; iter != NULL; iter = iter->nextBlock ) {
-            if ( ( psMemGetRefCounter( iter + 1 ) > 0 ) && ( iter->id >= id0 ) ) {
-                    ( *arr ) [ j++ ] = iter;
-                    if ( j == nleak ) { // found them all
-                            break;
-                        }
-                }
-        }
-        
+        if ( ( psMemGetRefCounter( iter + 1 ) > 0 ) && ( iter->id >= id0 ) ) {
+            ( *arr ) [ j++ ] = iter;
+            if ( j == nleak ) { // found them all
+                break;
+            }
+        }
+    }
+
     pthread_mutex_unlock( &memBlockListMutex );
-    
+
     return nleak;
 }
@@ -463,5 +463,5 @@
 /*
  * Reference counting APIs
- */ 
+ */
 // return refCounter
 psReferenceCount psMemGetRefCounter( void *vptr )
@@ -469,19 +469,19 @@
     psMemBlock * ptr;
     unsigned int refCount;
-    
+
     if ( vptr == NULL ) {
-            return 0;
-        }
-        
+        return 0;
+    }
+
     ptr = ( ( psMemBlock * ) vptr ) - 1;
-    
+
     if ( checkMemBlock( ptr, __func__ ) != 0 ) {
-            memProblemCallback( ptr, __func__, __LINE__ );
-        }
-        
+        memProblemCallback( ptr, __func__, __LINE__ );
+    }
+
     pthread_mutex_lock( &ptr->refCounterMutex );
     refCount = ptr->refCounter;
     pthread_mutex_unlock( &ptr->refCounterMutex );
-    
+
     return refCount;
 }
@@ -490,19 +490,19 @@
 {
     psMemBlock * ptr;
-    
+
     if ( vptr == NULL ) {
-            return vptr;
-        }
-        
+        return vptr;
+    }
+
     ptr = ( ( psMemBlock * ) vptr ) - 1;
-    
+
     if ( checkMemBlock( ptr, __func__ ) ) {
-            memProblemCallback( ptr, file, lineno );
-        }
-        
+        memProblemCallback( ptr, file, lineno );
+    }
+
     pthread_mutex_lock( &ptr->refCounterMutex );
     ptr->refCounter++;
     pthread_mutex_unlock( &ptr->refCounterMutex );
-    
+
     return vptr;
 }
@@ -512,90 +512,90 @@
 {
     if ( vptr == NULL ) {
-            return NULL;
-        }
-        
+        return NULL;
+    }
+
     psMemBlock *ptr = ( ( psMemBlock * ) vptr ) - 1;
-    
+
     if ( checkMemBlock( ptr, __func__ ) != 0 ) {
-            memProblemCallback( ptr, file, lineno );
-            return NULL;
-        }
-        
+        memProblemCallback( ptr, file, lineno );
+        return NULL;
+    }
+
     pthread_mutex_lock( &ptr->refCounterMutex );
-    
+
     if ( ptr->refCounter > 1 ) {
-            /// XXX - Probably should have another mutex here.
-            ptr->refCounter--;          // multiple references, just decrement the count.
-            pthread_mutex_unlock( &ptr->refCounterMutex );
-            
+        /// XXX - Probably should have another mutex here.
+        ptr->refCounter--;          // multiple references, just decrement the count.
+        pthread_mutex_unlock( &ptr->refCounterMutex );
+
+    } else {
+        pthread_mutex_unlock( &ptr->refCounterMutex );
+
+        // Did the user ask to be informed about this deallocation?
+        if ( ptr->id == p_psMemFreeID ) {
+            p_psMemFreeID += memFreeCallback( ptr );
+        }
+
+        if ( ptr->freeFcn != NULL ) {
+            ptr->freeFcn( vptr );
+        }
+
+        pthread_mutex_lock( &memBlockListMutex );
+
+        // cut the memBlock out of the memBlock list
+        if ( ptr->nextBlock != NULL ) {
+            ptr->nextBlock->previousBlock = ptr->previousBlock;
+        }
+        if ( ptr->previousBlock != NULL ) {
+            ptr->previousBlock->nextBlock = ptr->nextBlock;
+        }
+        if ( lastMemBlockAllocated == ptr ) {
+            lastMemBlockAllocated = ptr->nextBlock;
+        }
+
+        pthread_mutex_unlock( &memBlockListMutex );
+
+
+        // do we need to recycle?
+        if ( ptr->userMemorySize < P_PS_LARGE_BLOCK_SIZE ) {
+
+            int level = 1;
+            while ( ptr->userMemorySize >= recycleBinSize[ level ] ) {
+                level++;
+            }
+            level--;
+
+            ptr->refCounter = 0;
+            ptr->previousBlock = NULL;
+
+            pthread_mutex_lock( &recycleMemBlockListMutex );
+            ptr->nextBlock = recycleMemBlockList[ level ];
+            if ( recycleMemBlockList[ level ] != NULL ) {
+                recycleMemBlockList[ level ] ->previousBlock = ptr;
+            }
+            recycleMemBlockList[ level ] = ptr;
+            pthread_mutex_unlock( &recycleMemBlockListMutex );
+
         } else {
-            pthread_mutex_unlock( &ptr->refCounterMutex );
-            
-            // Did the user ask to be informed about this deallocation?
-            if ( ptr->id == p_psMemFreeID ) {
-                    p_psMemFreeID += memFreeCallback( ptr );
-                }
-                
-            if ( ptr->freeFcn != NULL ) {
-                    ptr->freeFcn( vptr );
-                }
-                
-            pthread_mutex_lock( &memBlockListMutex );
-            
-            // cut the memBlock out of the memBlock list
-            if ( ptr->nextBlock != NULL ) {
-                    ptr->nextBlock->previousBlock = ptr->previousBlock;
-                }
-            if ( ptr->previousBlock != NULL ) {
-                    ptr->previousBlock->nextBlock = ptr->nextBlock;
-                }
-            if ( lastMemBlockAllocated == ptr ) {
-                    lastMemBlockAllocated = ptr->nextBlock;
-                }
-                
-            pthread_mutex_unlock( &memBlockListMutex );
-            
-            
-            // do we need to recycle?
-            if ( ptr->userMemorySize < P_PS_LARGE_BLOCK_SIZE ) {
-            
-                    int level = 1;
-                    while ( ptr->userMemorySize >= recycleBinSize[ level ] ) {
-                            level++;
-                        }
-                    level--;
-                    
-                    ptr->refCounter = 0;
-                    ptr->previousBlock = NULL;
-                    
-                    pthread_mutex_lock( &recycleMemBlockListMutex );
-                    ptr->nextBlock = recycleMemBlockList[ level ];
-                    if ( recycleMemBlockList[ level ] != NULL ) {
-                            recycleMemBlockList[ level ] ->previousBlock = ptr;
-                        }
-                    recycleMemBlockList[ level ] = ptr;
-                    pthread_mutex_unlock( &recycleMemBlockListMutex );
-                    
-                } else {
-                    // memory is larger than I want to recycle.
-                    #ifdef PS_MEM_DEBUG
-                    ( void ) p_psRealloc( vptr, 0, file, lineno );
-                    ptr->previousBlock = NULL;
-                    ptr->nextBlock = deadBlockList;
-                    if ( deadBlockList != NULL ) {
-                            deadBlockList->previous = ptr;
-                        }
-                    deadBlockList = ptr;
-                    #else
-                    
-                    pthread_mutex_destroy( &ptr->refCounterMutex );
-                    free( ptr );
-                    #endif
-                    
-                }
-                
-            vptr = NULL;    // since we freed it, make sure we return NULL.
-        }
-        
+            // memory is larger than I want to recycle.
+            #ifdef PS_MEM_DEBUG
+            ( void ) p_psRealloc( vptr, 0, file, lineno );
+            ptr->previousBlock = NULL;
+            ptr->nextBlock = deadBlockList;
+            if ( deadBlockList != NULL ) {
+                deadBlockList->previous = ptr;
+            }
+            deadBlockList = ptr;
+            #else
+
+            pthread_mutex_destroy( &ptr->refCounterMutex );
+            free( ptr );
+            #endif
+
+        }
+
+        vptr = NULL;    // since we freed it, make sure we return NULL.
+    }
+
     return vptr;
 }
@@ -604,28 +604,28 @@
 {
     if ( vptr == NULL ) {
-            return ;
-        }
-        
+        return ;
+    }
+
     psMemBlock *ptr = ( ( psMemBlock * ) vptr ) - 1;
-    
+
     if ( checkMemBlock( ptr, __func__ ) != 0 ) {
-            memProblemCallback( ptr, __func__, __LINE__ );
-        }
-        
+        memProblemCallback( ptr, __func__, __LINE__ );
+    }
+
     ptr->freeFcn = freeFcn;
-    
+
 }
 psFreeFcn p_psMemGetDeallocator( void* vptr )
 {
     if ( vptr == NULL ) {
-            return NULL;
-        }
-        
+        return NULL;
+    }
+
     psMemBlock *ptr = ( ( psMemBlock * ) vptr ) - 1;
-    
+
     if ( checkMemBlock( ptr, __func__ ) != 0 ) {
-            memProblemCallback( ptr, __func__, __LINE__ );
-        }
-        
+        memProblemCallback( ptr, __func__, __LINE__ );
+    }
+
     return ptr->freeFcn;
 }
