[svn:parrot] r42431 - trunk/src/call
chromatic at svn.parrot.org
chromatic at svn.parrot.org
Wed Nov 11 23:33:38 UTC 2009
Author: chromatic
Date: Wed Nov 11 23:33:38 2009
New Revision: 42431
URL: https://trac.parrot.org/parrot/changeset/42431
Log:
[PCC] Fixed a memory leak of register storage for Contexts which need no
registers. Previously, we allocated fixed-sized storage for the register set
even if we didn't need it; that allocation always returns at least one
pointer's worth of memory. However, Parrot_pcc_free_registers() skips freeing
the register storage back to a fixed-size pool if the Context has no registers.
Skipping the allocation avoids this problem. This fixes the final part of the
leak reported by Lewis Wall in TT #1264.
Modified:
trunk/src/call/context.c
Modified: trunk/src/call/context.c
==============================================================================
--- trunk/src/call/context.c Wed Nov 11 23:33:34 2009 (r42430)
+++ trunk/src/call/context.c Wed Nov 11 23:33:38 2009 (r42431)
@@ -463,7 +463,10 @@
const size_t all_regs_size = size_n + size_i + size_p + size_s;
const size_t reg_alloc = ROUND_ALLOC_SIZE(all_regs_size);
- ctx->registers = (Parrot_Context *)Parrot_gc_allocate_fixed_size_storage(interp, reg_alloc);
+ /* don't allocate any storage if there are no registers */
+ ctx->registers = reg_alloc
+ ? (Parrot_Context *)Parrot_gc_allocate_fixed_size_storage(interp, reg_alloc)
+ : NULL;
ctx->n_regs_used[REGNO_INT] = number_regs_used[REGNO_INT];
ctx->n_regs_used[REGNO_NUM] = number_regs_used[REGNO_NUM];
@@ -475,9 +478,9 @@
/* ctx.bp_ps points to S0, which has Px on the left */
ctx->bp_ps.regs_s = (STRING **)((char *)ctx->registers + size_nip);
-
}
+
/*
=item C<void Parrot_pcc_allocate_registers(PARROT_INTERP, PMC *pmcctx, const
More information about the parrot-commits
mailing list