[svn:parrot] r47671 - branches/gsoc_instrument/src/dynpmc

khairul at svn.parrot.org khairul at svn.parrot.org
Thu Jun 17 13:59:40 UTC 2010


Author: khairul
Date: Thu Jun 17 13:59:39 2010
New Revision: 47671
URL: https://trac.parrot.org/parrot/changeset/47671

Log:
Cleanup hook list on destroy.

Modified:
   branches/gsoc_instrument/src/dynpmc/instrument.pmc

Modified: branches/gsoc_instrument/src/dynpmc/instrument.pmc
==============================================================================
--- branches/gsoc_instrument/src/dynpmc/instrument.pmc	Thu Jun 17 06:38:23 2010	(r47670)
+++ branches/gsoc_instrument/src/dynpmc/instrument.pmc	Thu Jun 17 13:59:39 2010	(r47671)
@@ -77,6 +77,7 @@
 /* Linked List operations */
 static probe_list_t *probe_list_create_list(PARROT_INTERP);
 static probe_node_t *probe_list_create_node(PARROT_INTERP);
+static void          probe_list_delete_list(PARROT_INTERP, probe_list_t *list);
 static void          probe_list_delete_node(PARROT_INTERP, probe_node_t *node);
 static void          probe_list_push(PARROT_INTERP, probe_list_t *list, PMC *item);
 static PMC          *probe_list_pop(PARROT_INTERP, probe_list_t *list);
@@ -144,8 +145,22 @@
 
     VTABLE void destroy() {
         Parrot_Instrument_attributes * const attr = PARROT_INSTRUMENT(SELF);
+        Instrument_runcore_t *core = (Instrument_runcore_t *) attr->supervised->run_core;
+        UINTVAL i;
+
+        /* Delete the linked list entries. */
+        if (core->op_catchall != NULL) {
+            probe_list_delete_list(INTERP, core->op_catchall);
+        }
+        if (core->op_hooks != NULL) {
+            for (i = 0; i < attr->supervised->op_count; i++) {
+                if (core->op_hooks[i] != NULL) {
+                    probe_list_delete_list(INTERP, core->op_hooks[i]);
+                }
+            }
 
-        /* TODO: Delete the linked list entries. */
+            mem_gc_free(INTERP, core->op_hooks);
+        }
 
         /* Delete the supervised interpreter */
         Parrot_destroy(attr->supervised);
@@ -619,9 +634,9 @@
     detect_loadlib(interp);
 
     /* Setup an exception handler to handle exits and unhandled exceptions. */
-    if(setjmp(exc_handler.resume)) {
+    if (setjmp(exc_handler.resume)) {
         /* Check for exit or unhandled exception. */
-        if(*pc == enum_ops_exit_i || *pc == enum_ops_exit_ic) {
+        if (*pc == enum_ops_exit_i || *pc == enum_ops_exit_ic) {
             /* Exit called. Do nothing but return so we
                can go on to finalize the instruments. */
         }
@@ -633,7 +648,7 @@
                             VTABLE_get_integer_keyed_str(interp, exc_handler.exception,
                                                          CONST_STRING(interp, "type")));
         }
-        
+
         return pc;
     }
 
@@ -951,6 +966,22 @@
 }
 
 /*
+ * Deletes the list.
+ */
+static void probe_list_delete_list(PARROT_INTERP, probe_list_t *list) {
+    probe_node_t *node, *next;
+
+    node = list->head;
+    while (node != NULL) {
+        next = node->next;
+        probe_list_delete_node(interp, node);
+        node = next;
+    }
+
+    mem_gc_free(interp, list);
+}
+
+/*
  * Deletes the node.
  */
 static void probe_list_delete_node(PARROT_INTERP, probe_node_t *node) {


More information about the parrot-commits mailing list