Author: chromatic
Date: Tue Jun  5 18:47:23 2007
New Revision: 18830

Modified:
   trunk/src/inter_create.c
   trunk/src/packfile.c

Log:
[Packfile] Fix a very small memory leak in each debug segment.

Modified: trunk/src/inter_create.c
==============================================================================
--- trunk/src/inter_create.c    (original)
+++ trunk/src/inter_create.c    Tue Jun  5 18:47:23 2007
@@ -395,19 +395,15 @@
     interp->arena_base = NULL;
     /* cache structure */
     destroy_object_cache(interp);
-    /* packfile */
 
-    if (!Interp_flags_TEST(interp, PARROT_EXTERN_CODE_FLAG))  {
-        PackFile *pf = interp->initial_pf;
-        if (pf)
-            PackFile_destroy(interp, pf);
-    }
+    /* packfile */
+    if (interp->initial_pf)
+        PackFile_destroy(interp, interp->initial_pf);
 
     /* free vtables */
     parrot_free_vtables(interp);
     mmd_destroy(interp);
 
-
     if (interp->profile) {
         mem_sys_free(interp->profile->data);
         interp->profile->data = NULL;

Modified: trunk/src/packfile.c
==============================================================================
--- trunk/src/packfile.c        (original)
+++ trunk/src/packfile.c        Tue Jun  5 18:47:23 2007
@@ -1517,9 +1517,9 @@
     PackFile_Directory *dir = (PackFile_Directory *)self;
     size_t i;
 
-    for (i = 0; i < dir->num_segments; i++) {
+    for (i = 0; i < dir->num_segments; i++)
         PackFile_Segment_destroy(interp, dir->segments[i]);
-    }
+
     if (dir->segments) {
         mem_sys_free(dir->segments);
         dir->segments = NULL;
@@ -1831,10 +1831,10 @@
             byte_code->prederef.branches = NULL;
         }
     }
-    byte_code->fixups = NULL;
-    byte_code->debugs = NULL;
+    byte_code->fixups      = NULL;
     byte_code->const_table = NULL;
-    byte_code->pic_index = NULL;
+    byte_code->pic_index   = NULL;
+    byte_code->debugs      = NULL;
 }
 
 /*
@@ -1898,7 +1898,7 @@
 
     /* Free mappings pointer array. */
     mem_sys_free(debug->mappings);
-    debug->mappings = NULL;
+    debug->mappings     = NULL;
     debug->num_mappings = 0;
 }
 
@@ -2189,9 +2189,6 @@
 
         debug->base.data    = (opcode_t *)mem_sys_allocate(size *
             sizeof (opcode_t));
-        debug->num_mappings = 0;
-        debug->mappings     = mem_allocate_typed(PackFile_DebugMapping *);
-
         debug->code = cs;
         cs->debugs = debug;
     }

Reply via email to