Ticket #757: TRAC-757-1.patch

File TRAC-757-1.patch, 1.8 KB (added by cdarroch, 5 years ago)

adjust vtable max and alloced to avoid losing slots?

  • src/pmc.c

    old new  
    675675    const INTVAL type_id = interp->n_vtable_max++; 
    676676 
    677677    /* Have we overflowed the table? */ 
    678     if (type_id >= interp->n_vtable_alloced) 
     678    if (type_id > interp->n_vtable_alloced) 
    679679        parrot_realloc_vtables(interp); 
    680680 
    681681    return type_id; 
  • src/vtables.c

    old new  
    129129parrot_alloc_vtables(PARROT_INTERP) 
    130130{ 
    131131    ASSERT_ARGS(parrot_alloc_vtables) 
     132    PARROT_ASSERT(enum_class_core_max <= PARROT_MAX_CLASSES); 
     133 
    132134    interp->vtables          = mem_allocate_n_zeroed_typed(PARROT_MAX_CLASSES, VTABLE *); 
    133135    interp->n_vtable_max     = enum_class_core_max; 
    134     interp->n_vtable_alloced = PARROT_MAX_CLASSES - 1; 
     136    interp->n_vtable_alloced = PARROT_MAX_CLASSES; 
    135137} 
    136138 
    137139/* 
     
    155157    const INTVAL new_size    = new_max              * sizeof (VTABLE *); 
    156158    const INTVAL old_size    = interp->n_vtable_max * sizeof (VTABLE *); 
    157159 
    158     /* arrays start at zero, but we compare type numbers starting at 1 */ 
    159     interp->n_vtable_alloced = new_max - 1; 
     160    interp->n_vtable_alloced = new_max; 
    160161    interp->vtables          = (VTABLE **)mem_sys_realloc_zeroed( 
    161162        interp->vtables, new_size, old_size); 
    162163} 
  • src/pmc/parrotinterpreter.pmc

    old new  
    8080        d->class_hash   = Parrot_clone(d, s->class_hash); 
    8181        d->n_vtable_max = s->n_vtable_max; 
    8282 
    83         if (d->n_vtable_max > d->n_vtable_alloced) 
     83        while (d->n_vtable_max > d->n_vtable_alloced) 
    8484            parrot_realloc_vtables(d); 
    8585 
    8686        last_remove = s->n_vtable_max;