Ticket #1089: ria.patch
File ria.patch, 2.6 KB (added by dukeleto, 11 years ago) |
---|
-
src/pmc/resizableintegerarray.pmc
90 90 91 91 VTABLE void set_integer_native(INTVAL size) { 92 92 INTVAL *int_array; 93 INTVAL cur_size; 93 94 INTVAL resize_threshold; 94 95 95 96 if (size < 0) 96 97 Parrot_ex_throw_from_c_args(INTERP, NULL, EXCEPTION_OUT_OF_BOUNDS, 97 98 "ResizableIntegerArray: Can't resize!"); 98 99 100 GET_ATTR_size(INTERP, SELF, cur_size); 99 101 GET_ATTR_int_array(INTERP, SELF, int_array); 100 102 GET_ATTR_resize_threshold(INTERP, SELF, resize_threshold); 101 103 if (!int_array) { … … 109 111 SUPER(size); 110 112 SET_ATTR_resize_threshold(INTERP, SELF, size); 111 113 } 114 GET_ATTR_int_array(INTERP, SELF, int_array); 112 115 } 113 116 else if (size <= resize_threshold) { 114 117 /* we could shrink here if necessary */ 115 118 SET_ATTR_size(INTERP, SELF, size); 116 return;117 119 } 118 120 else { 119 121 INTVAL cur = resize_threshold; 120 INTVAL *int_array;121 122 122 123 if (cur < 8192) 123 124 cur = size < 2 * cur ? 2 * cur : size; -
include/parrot/memory.h
47 47 48 48 #define mem_sys_memcopy memcpy 49 49 #define mem_sys_memmove memmove 50 #define mem_sys_memset memset 50 51 51 52 #define mem_allocate_typed(type) (type *)mem_sys_allocate(sizeof (type)) 52 53 #define mem_allocate_n_typed(n, type) (type *)mem_sys_allocate((n) * sizeof (type)) -
t/pmc/resizableintegerarray.t
43 43 44 44 .sub main :main 45 45 .include 'test_more.pir' 46 plan(4 7)46 plan(48) 47 47 48 48 test_does_interfaces() 49 49 … … 59 59 60 60 test_conversion() 61 61 test_conversion_overflow() 62 test_zero_after_resize() 62 63 64 63 65 test_set_pmc_index() 64 66 test_get_pmc_index() 65 67 … … 255 257 end: 256 258 .end 257 259 260 .sub test_zero_after_resize 261 $P0 = new ['ResizableIntegerArray'] 262 $P0 = 10 263 $P0[7] = 23 264 $P0 = 5 265 $P0[9] = 0 266 $I0 = $P0[7] 267 is( $I0, 0, 'Latent elements are zeroed when array is shrunk and re-stretched' ) 268 .end 269 258 270 .sub test_conversion 259 271 $P0 = new ['ResizableIntegerArray'] 260 272 $P0 = 6