Index: src/pmc/resizableintegerarray.pmc =================================================================== --- src/pmc/resizableintegerarray.pmc (revision 48587) +++ src/pmc/resizableintegerarray.pmc (working copy) @@ -90,12 +90,14 @@ VTABLE void set_integer_native(INTVAL size) { INTVAL *int_array; + INTVAL cur_size; INTVAL resize_threshold; if (size < 0) Parrot_ex_throw_from_c_args(INTERP, NULL, EXCEPTION_OUT_OF_BOUNDS, "ResizableIntegerArray: Can't resize!"); + GET_ATTR_size(INTERP, SELF, cur_size); GET_ATTR_int_array(INTERP, SELF, int_array); GET_ATTR_resize_threshold(INTERP, SELF, resize_threshold); if (!int_array) { @@ -109,15 +111,14 @@ SUPER(size); SET_ATTR_resize_threshold(INTERP, SELF, size); } + GET_ATTR_int_array(INTERP, SELF, int_array); } else if (size <= resize_threshold) { /* we could shrink here if necessary */ SET_ATTR_size(INTERP, SELF, size); - return; } else { INTVAL cur = resize_threshold; - INTVAL *int_array; if (cur < 8192) cur = size < 2 * cur ? 2 * cur : size; Index: include/parrot/memory.h =================================================================== --- include/parrot/memory.h (revision 48587) +++ include/parrot/memory.h (working copy) @@ -47,6 +47,7 @@ #define mem_sys_memcopy memcpy #define mem_sys_memmove memmove +#define mem_sys_memset memset #define mem_allocate_typed(type) (type *)mem_sys_allocate(sizeof (type)) #define mem_allocate_n_typed(n, type) (type *)mem_sys_allocate((n) * sizeof (type)) Index: t/pmc/resizableintegerarray.t =================================================================== --- t/pmc/resizableintegerarray.t (revision 48587) +++ t/pmc/resizableintegerarray.t (working copy) @@ -43,7 +43,7 @@ .sub main :main .include 'test_more.pir' - plan(47) + plan(48) test_does_interfaces() @@ -59,7 +59,9 @@ test_conversion() test_conversion_overflow() + test_zero_after_resize() + test_set_pmc_index() test_get_pmc_index() @@ -255,6 +257,16 @@ end: .end +.sub test_zero_after_resize + $P0 = new ['ResizableIntegerArray'] + $P0 = 10 + $P0[7] = 23 + $P0 = 5 + $P0[9] = 0 + $I0 = $P0[7] + is( $I0, 0, 'Latent elements are zeroed when array is shrunk and re-stretched' ) +.end + .sub test_conversion $P0 = new ['ResizableIntegerArray'] $P0 = 6