[svn:parrot] r45003 - branches/pcc_megrecells/src/pmc

bacek at svn.parrot.org bacek at svn.parrot.org
Thu Mar 18 09:49:19 UTC 2010


Author: bacek
Date: Thu Mar 18 09:49:19 2010
New Revision: 45003
URL: https://trac.parrot.org/parrot/changeset/45003

Log:
Fix off-by-one error in CallContext.push_foo

Modified:
   branches/pcc_megrecells/src/pmc/callcontext.pmc

Modified: branches/pcc_megrecells/src/pmc/callcontext.pmc
==============================================================================
--- branches/pcc_megrecells/src/pmc/callcontext.pmc	Thu Mar 18 09:48:54 2010	(r45002)
+++ branches/pcc_megrecells/src/pmc/callcontext.pmc	Thu Mar 18 09:49:19 2010	(r45003)
@@ -66,15 +66,17 @@
     if (size < 8)
         size = 8;
 
-    GETATTR_CallContext_num_positionals(interp, self, num_positionals);
     GETATTR_CallContext_positionals(interp, self, array);
     new_array = (struct Pcc_cell*)Parrot_gc_allocate_fixed_size_storage(interp,
             size * sizeof (Pcc_cell));
-    memcpy(new_array, array, num_positionals * sizeof (Pcc_cell));
 
-    if (array)
+    if (array) {
+        memset(new_array, size * sizeof (Pcc_cell), 0);
+        GETATTR_CallContext_num_positionals(interp, self, num_positionals);
+        memcpy(new_array, array, num_positionals * sizeof (Pcc_cell));
         Parrot_gc_free_fixed_size_storage(interp, allocated_positionals * sizeof (Pcc_cell),
                 array);
+    }
 
     SETATTR_CallContext_allocated_positionals(interp, self, size);
     SETATTR_CallContext_positionals(interp, self, new_array);
@@ -799,7 +801,7 @@
 
     VTABLE void push_integer(INTVAL value) {
         INTVAL    pos  = STATICSELF.elements();
-        Pcc_cell *cell = get_cell_at(INTERP, SELF, pos + 1);
+        Pcc_cell *cell = get_cell_at(INTERP, SELF, pos);
         cell->u.i      = value;
         cell->type     = INTCELL;
         SET_ATTR_num_positionals(INTERP, SELF, pos + 1);
@@ -807,7 +809,7 @@
 
     VTABLE void push_float(FLOATVAL value) {
         INTVAL    pos  = STATICSELF.elements();
-        Pcc_cell *cell = get_cell_at(INTERP, SELF, pos + 1);
+        Pcc_cell *cell = get_cell_at(INTERP, SELF, pos);
         cell->u.n      = value;
         cell->type     = FLOATCELL;
         SET_ATTR_num_positionals(INTERP, SELF, pos + 1);
@@ -815,7 +817,7 @@
 
     VTABLE void push_string(STRING *value) {
         INTVAL    pos  = STATICSELF.elements();
-        Pcc_cell *cell = get_cell_at(INTERP, SELF, pos + 1);
+        Pcc_cell *cell = get_cell_at(INTERP, SELF, pos);
         cell->u.s      = value;
         cell->type     = STRINGCELL;
         SET_ATTR_num_positionals(INTERP, SELF, pos + 1);
@@ -823,7 +825,7 @@
 
     VTABLE void push_pmc(PMC *value) {
         INTVAL    pos  = STATICSELF.elements();
-        Pcc_cell *cell = get_cell_at(INTERP, SELF, pos + 1);
+        Pcc_cell *cell = get_cell_at(INTERP, SELF, pos);
         cell->u.p      = value;
         cell->type     = PMCCELL;
         SET_ATTR_num_positionals(INTERP, SELF, pos + 1);
@@ -890,7 +892,7 @@
     VTABLE void set_pmc_keyed_int(INTVAL key, PMC *value) {
         Pcc_cell *cell = get_cell_at(INTERP, SELF, key);
 
-        cell->u.s   = value;
+        cell->u.p   = value;
         cell->type  = STRINGCELL;
     }
 


More information about the parrot-commits mailing list