Export GC_print_free_list()
authorIvan Maidanski <ivmai@mail.ru>
Mon, 31 Oct 2016 07:09:10 +0000 (10:09 +0300)
committerIvan Maidanski <ivmai@mail.ru>
Mon, 31 Oct 2016 07:09:10 +0000 (10:09 +0300)
Note: this function is not used by GC itself.

* include/gc_inline.h (GC_print_free_list): New public API prototype.
* reclaim.c [!NO_DEBUGGING]: Include gc_inline.h (to check that
GC_print_free_list prototype matches the definition).
* reclaim.c [!NO_DEBUGGING] (GC_print_free_list): Define as public
(GC_API+GC_CALL); remove "ok" local variable; add assertions about kind
and sz_in_granules maximum values.

include/gc_inline.h
reclaim.c

index f4d3b8d..a4fb4e3 100644 (file)
@@ -168,4 +168,7 @@ GC_API GC_ATTR_MALLOC GC_ATTR_ALLOC_SIZE(1) void * GC_CALL
       ((void **)(result))[1] = (void *)(second); \
     } while (0)
 
+GC_API void GC_CALL GC_print_free_list(int /* kind */,
+                                       size_t /* sz_in_granules */);
+
 #endif /* !GC_INLINE_H */
index cee985d..8be53a0 100644 (file)
--- a/reclaim.c
+++ b/reclaim.c
@@ -565,13 +565,17 @@ void GC_print_block_list(void)
               (unsigned long)pstats.total_bytes);
 }
 
+#include "gc_inline.h" /* for GC_print_free_list prototype */
+
 /* Currently for debugger use only: */
-void GC_print_free_list(int kind, size_t sz_in_granules)
+GC_API void GC_CALL GC_print_free_list(int kind, size_t sz_in_granules)
 {
-    struct obj_kind * ok = &GC_obj_kinds[kind];
-    ptr_t flh = ok -> ok_freelist[sz_in_granules];
+    ptr_t flh;
     int n;
 
+    GC_ASSERT(kind < MAXOBJKINDS);
+    GC_ASSERT(sz_in_granules <= MAXOBJGRANULES);
+    flh = GC_obj_kinds[kind].ok_freelist[sz_in_granules];
     for (n = 0; flh; n++) {
         struct hblk *block = HBLKPTR(flh);
         GC_printf("Free object in heap block %p [%d]: %p\n",