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

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


Author: bacek
Date: Mon May 31 23:40:23 2010
New Revision: 47239
URL: https://trac.parrot.org/parrot/changeset/47239

Log:
Add List.is_owned for precise check in GC.is_pmc_ptr

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:09:56 2010	(r47238)
+++ branches/gc_massacre/src/gc/list.c	Mon May 31 23:40:23 2010	(r47239)
@@ -113,6 +113,23 @@
     return 1;
 }
 
+int
+Parrot_gc_list_is_owned(SHIM_INTERP, ARGIN(Linked_List *list), ARGIN(List_Item_Header *item))
+{
+    List_Item_Header *tmp = list->first;
+
+    if (item->owner != list)
+        return 0;
+
+    while (tmp) {
+        if (tmp == item)
+            return 1;
+        tmp = tmp->next;
+    }
+
+    return 0;
+}
+
 /*
 
 =back

Modified: branches/gc_massacre/src/gc/list.h
==============================================================================
--- branches/gc_massacre/src/gc/list.h	Mon May 31 23:09:56 2010	(r47238)
+++ branches/gc_massacre/src/gc/list.h	Mon May 31 23:40:23 2010	(r47239)
@@ -75,6 +75,12 @@
 int Parrot_gc_list_check(SHIM_INTERP, ARGIN(Linked_List *list))
         __attribute__nonnull__(2);
 
+int Parrot_gc_list_is_owned(SHIM_INTERP,
+    ARGIN(Linked_List *list),
+    ARGIN(List_Item_Header *item))
+        __attribute__nonnull__(2)
+        __attribute__nonnull__(3);
+
 #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 = (\
@@ -87,6 +93,9 @@
     , PARROT_ASSERT_ARG(item))
 #define ASSERT_ARGS_Parrot_gc_list_check __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
        PARROT_ASSERT_ARG(list))
+#define ASSERT_ARGS_Parrot_gc_list_is_owned __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
+       PARROT_ASSERT_ARG(list) \
+    , PARROT_ASSERT_ARG(item))
 /* 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