mirror of
https://codeberg.org/ziglang/zig
synced 2026-11-18 07:05:05 +00:00
#13666 introduced a footgun when using `toOwnedSlice` with `errdefer array_list.deinit()`, since `toOwnedSlice` could retain capacity if `resize` failed, meaning it would leak without `deinit` being called. This meant that the only correct way to use `toOwnedSlice` was with `defer` instead of `errdefer` to ensure that the ArrayList would get cleaned up.
Now, toOwnedSlice will now behave similarly to how it did before #13666, in that it will always clear the ArrayList's capacity if the resize/realloc succeeds.
This also reverts commit 05890a12f5, which was contingent on the modified toOwnedSlice behavior.
Closes #13946
1606 lines
61 KiB
1606 lines
61 KiB