瀏覽代碼

fix the debug support for freelist-organised raw blocks

Ioannis Koutras 12 年之前
父節點
當前提交
3ed8dc4e01
共有 4 個文件被更改,包括 9 次插入5 次删除
  1. 1 1
      private-include/freelist/freelist_debug.h
  2. 1 1
      src/CMakeLists.txt
  3. 4 0
      src/debug.c
  4. 3 3
      src/freelist/freelist_debug.c

+ 1 - 1
private-include/freelist/freelist_debug.h

@@ -16,7 +16,7 @@
  */
 
 /**
- * @file   freelist_debug.h
+ * @file   freelist/debug.h
  * @author Ioannis Koutras (joko@microlab.ntua.gr)
  * @date   September 2012
  * @brief  Debug functions for freelist-organised raw blocks

+ 1 - 1
src/CMakeLists.txt

@@ -115,7 +115,7 @@ if(RAW_BLOCKS_TYPE STREQUAL "freelist")
   if(WITH_DEBUG)
     set(dmmlib_SRCS
       ${dmmlib_SRCS}
-      freelist/freelist_debug.c
+      freelist/debug.c
       )
   endif(WITH_DEBUG)
 

+ 4 - 0
src/debug.c

@@ -29,6 +29,8 @@
 #include "dmmlib/dmmlib.h"
 #include "locks.h"
 
+#include "dmmlib/freelist/freelist_rb.h"
+
 /** Gets the number of raw blocks that are currently managed by an allocator.
  *
  * @param allocator The pointer of the allocator's data structure.
@@ -44,6 +46,8 @@ void get_raw_blocks(allocator_t *allocator) {
         DBG_TRACE("dmmlib - Raw block at %p of size %zu\n",
                 (void *)current_raw_block,
                 current_raw_block->size);
+        get_memory_blocks((freelist_rb_t *)((uintptr_t) current_raw_block +
+                    sizeof(raw_block_header_t)));
     }
 
     DBG_TRACE("dmmlib - there are %d raw blocks\n", counter);

+ 3 - 3
src/freelist/freelist_debug.c

@@ -16,13 +16,13 @@
  */
 
 /**
- * @file   freelist_debug.c
+ * @file   freelist/debug.c
  * @author Ioannis Koutras (joko@microlab.ntua.gr)
  * @date   September 2012
  * @brief  Debug functions implementation for freelist-organised raw blocks
  */
 
-#include "freelist/freelist_debug.h"
+#include "freelist/debug.h"
 
 #include "dmmlib/freelist/block_header.h"
 #include "freelist/block_header_funcs.h"
@@ -37,7 +37,7 @@ void get_memory_blocks(freelist_rb_t *raw_block) {
     block_header_t *memory_block;
     int counter;
 
-    counter = 1;
+    counter = 0;
 
     SLIST_FOREACH(memory_block, &raw_block->fl_head, pointers) {
         counter++;