Retoor software development Projects Research SearchXNG
Register Sign In

12 lines
211 B
Plaintext
Raw Normal View History

fix: assign reallocation result to list->elements in shrink path When shrinking a list's capacity, wrenReallocate may return a different memory address. The previous code ignored the return value, leaving list->elements pointing to freed memory. This fix assigns the result back to list->elements and adds a regression test for grow/shrink behavior.
2014-02-10 16:55:14 +01:00
// This mostly tests that lists handle growing and shrinking their memory.
var list = []
for (i in 0..200) {
list.add(i)
}
for (i in 0..195) {
list.removeAt(-1)
}
IO.print(list) // expect: [0, 1, 2, 3, 4]
Reference in New Issue Copy Permalink
f2edb03389
wren/test/list/grow_shrink.wren
Response time: 32ms
Mail Licenses API