[opengtl-commits] [645] more debug

[ Thread Index | Date Index | More lists.tuxfamily.org/opengtl-commits Archives ]


Revision: 645
Author:   cyrille
Date:     2009-03-17 15:57:39 +0100 (Tue, 17 Mar 2009)

Log Message:
-----------
more debug

Modified Paths:
--------------
    trunk/OpenGTL/OpenGTL/GTLCore/MemoryManager_p.cpp


Modified: trunk/OpenGTL/OpenGTL/GTLCore/MemoryManager_p.cpp
===================================================================
--- trunk/OpenGTL/OpenGTL/GTLCore/MemoryManager_p.cpp	2009-03-17 14:04:46 UTC (rev 644)
+++ trunk/OpenGTL/OpenGTL/GTLCore/MemoryManager_p.cpp	2009-03-17 14:57:39 UTC (rev 645)
@@ -29,7 +29,7 @@
 
 #define DEFAULT_SEGMENT_SIZE 100000
 
-#define DEBUG_MEMORY_MANAGER
+// #define DEBUG_MEMORY_MANAGER
 
 #ifdef DEBUG_MEMORY_MANAGER
 
@@ -77,6 +77,8 @@
   }
   inline void* allocate(int size)
   {
+    MM_DEBUG( "Begin allocate" );
+    printStatus();
     GTL_ASSERT( canContains(size) );
     int sizeTotal = size + sizeof(Header);
     Header* nextFreeH = reinterpret_cast<Header*>(nextFree);
@@ -92,10 +94,14 @@
     }
     previous = nextFreeH;
     nextFree += sizeTotal;
+    printStatus();
+    MM_DEBUG( "End allocate" );
     return nextFreeH->data;
   }
   inline void desallocate(void* ptr)
   {
+    MM_DEBUG( "Begin desallocate" );
+    printStatus();
     GTL_ASSERT(contains(ptr));
     uint8_t* ptr8 = reinterpret_cast<uint8_t*>(ptr);
     Header* currentHeader = reinterpret_cast<Header*>(ptr8-sizeof(Header));
@@ -110,6 +116,8 @@
           MM_DEBUG("No previous, free = " << uint(end - nextFree) );
           nextFree = reinterpret_cast<uint8_t*>(currentHeader);
           previous = 0;
+	  printStatus();
+	  MM_DEBUG( "End desallocate" );
           return;
         }
         Header* previousCurrentHeader = currentHeader->previous;
@@ -123,11 +131,25 @@
           previous = previousCurrentHeader;
           previous->next = 0;
           nextFree = reinterpret_cast<uint8_t*>(currentHeader);
+	  MM_DEBUG("Now free" << uint(end - nextFree));
+	  printStatus();
+	  MM_DEBUG( "End desallocate" );
           return;
         }
       }
     }
+    printStatus();
   }
+  inline void printStatus()
+  {
+    MM_DEBUG( "### nextFree = " << (void*)nextFree << " previous = " << (void*)previous << " start = " << (void*)start << " end = " << (void*)end << " Free space = " << uint(end - nextFree) );
+    if(previous)
+    {
+      MM_DEBUG( "### previous->status = " << previous->status << " previous->size = " << previous->size
+	     << " previous->previous = " << previous->previous << " previous->next = " << previous->next
+	     << " previous->data = " << (void*)previous->data );
+    }
+  }
   uint8_t* nextFree;
   Header* previous;
   uint8_t* start;


Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/