[svn:parrot] r48702 - trunk/src

chromatic at svn.parrot.org chromatic at svn.parrot.org
Sat Aug 28 02:14:46 UTC 2010


Author: chromatic
Date: Sat Aug 28 02:14:46 2010
New Revision: 48702
URL: https://trac.parrot.org/parrot/changeset/48702

Log:
[PBC] Plugged Annotations memory leak.

Modified:
   trunk/src/packfile.c

Modified: trunk/src/packfile.c
==============================================================================
--- trunk/src/packfile.c	Sat Aug 28 02:14:42 2010	(r48701)
+++ trunk/src/packfile.c	Sat Aug 28 02:14:46 2010	(r48702)
@@ -2644,12 +2644,16 @@
         mem_gc_free(interp, byte_code->op_mapping.libs);
     }
 
-    byte_code->fixups          = NULL;
+    if (byte_code->annotations)
+        PackFile_Annotations_destroy(interp, byte_code->annotations);
+
+    byte_code->annotations     = NULL;
     byte_code->const_table     = NULL;
     byte_code->debugs          = NULL;
-    byte_code->op_mapping.libs = NULL;
+    byte_code->fixups          = NULL;
     byte_code->op_func_table   = NULL;
     byte_code->op_info_table   = NULL;
+    byte_code->op_mapping.libs = NULL;
 }
 
 
@@ -4308,6 +4312,10 @@
     /* Free any entries. */
     if (self->entries)
         mem_gc_free(interp, self->entries);
+
+    self->keys    = NULL;
+    self->groups  = NULL;
+    self->entries = NULL;
 }
 
 
@@ -4450,6 +4458,7 @@
     self->num_entries = PF_fetch_opcode(seg->pf, &cursor);
     self->entries     = mem_gc_allocate_n_zeroed_typed(interp,
             self->num_entries, PackFile_Annotations_Entry);
+
     for (i = 0; i < self->num_entries; ++i) {
         PackFile_Annotations_Entry * const entry = self->entries + i;
         entry->bytecode_offset = PF_fetch_opcode(seg->pf, &cursor);
@@ -4646,11 +4655,11 @@
 
     /* Add annotations entry. */
     if (self->entries)
-            self->entries = mem_gc_realloc_n_typed(interp, self->entries,
-                    1 + self->num_entries, PackFile_Annotations_Entry);
-        else
-            self->entries = mem_gc_allocate_n_typed(interp,
-                    1 + self->num_entries, PackFile_Annotations_Entry);
+        self->entries = mem_gc_realloc_n_typed(interp, self->entries,
+                1 + self->num_entries, PackFile_Annotations_Entry);
+    else
+        self->entries = mem_gc_allocate_n_typed(interp,
+                1 + self->num_entries, PackFile_Annotations_Entry);
 
     self->entries[self->num_entries].bytecode_offset = offset;
     self->entries[self->num_entries].key             = key_id;


More information about the parrot-commits mailing list