[svn:parrot] r47237 - branches/gc_massacre/src/gc

bacek at svn.parrot.org bacek at svn.parrot.org
Mon May 31 23:09:15 UTC 2010


Author: bacek
Date: Mon May 31 23:09:15 2010
New Revision: 47237
URL: https://trac.parrot.org/parrot/changeset/47237

Log:
Add List.check for validating list

Modified:
   branches/gc_massacre/src/gc/list.c
   branches/gc_massacre/src/gc/list.h

Modified: branches/gc_massacre/src/gc/list.c
==============================================================================
--- branches/gc_massacre/src/gc/list.c	Mon May 31 23:08:29 2010	(r47236)
+++ branches/gc_massacre/src/gc/list.c	Mon May 31 23:09:15 2010	(r47237)
@@ -96,6 +96,22 @@
     list->count--;
 }
 
+int
+Parrot_gc_list_check(SHIM_INTERP, ARGIN(Linked_List *list))
+{
+    List_Item_Header *tmp = list->first;
+    size_t counter = 0;
+
+    while (tmp) {
+        List_Item_Header *next = tmp->next;
+        PARROT_ASSERT(tmp->owner == list);
+        tmp = next;
+        ++counter;
+        PARROT_ASSERT(counter <= list->count);
+    }
+
+    return 1;
+}
 
 /*
 

Modified: branches/gc_massacre/src/gc/list.h
==============================================================================
--- branches/gc_massacre/src/gc/list.h	Mon May 31 23:08:29 2010	(r47236)
+++ branches/gc_massacre/src/gc/list.h	Mon May 31 23:09:15 2010	(r47237)
@@ -72,6 +72,9 @@
         FUNC_MODIFIES(*list)
         FUNC_MODIFIES(*item);
 
+int Parrot_gc_list_check(SHIM_INTERP, ARGIN(Linked_List *list))
+        __attribute__nonnull__(2);
+
 #define ASSERT_ARGS_Parrot_gc_allocate_linked_list \
      __attribute__unused__ int _ASSERT_ARGS_CHECK = (0)
 #define ASSERT_ARGS_Parrot_gc_destroy_linked_list __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
@@ -82,6 +85,8 @@
 #define ASSERT_ARGS_Parrot_gc_list_remove __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
        PARROT_ASSERT_ARG(list) \
     , PARROT_ASSERT_ARG(item))
+#define ASSERT_ARGS_Parrot_gc_list_check __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
+       PARROT_ASSERT_ARG(list))
 /* Don't modify between HEADERIZER BEGIN / HEADERIZER END.  Your changes will be lost. */
 /* HEADERIZER END: src/gc/list.c */
 


More information about the parrot-commits mailing list