Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/common/src/mlib/vec.th
Original file line number Diff line number Diff line change
Expand Up @@ -396,6 +396,8 @@ fn(init_copy(VecName *dst_vec, VecName const *src_vec)) mlib_noexcept
if (!fn(reserve(&tmp, src_vec->size))) {
// We failed to reserve capacity in the new vector
fn(destroy(&tmp));
// Always leave `dst_vec` in an initialized state.
*dst_vec = (VecName){NULL, 0, 0};
return false;
}
// Copy everything into the destination element-by-element
Expand All @@ -412,6 +414,8 @@ fn(init_copy(VecName *dst_vec, VecName const *src_vec)) mlib_noexcept
if (!VecCopyElement((out_iter), (in_iter))) {
// Failed copying here. Undo everything by destroying the temporary
fn(destroy(&tmp));
// Always leave `dst_vec` in an initialized state.
*dst_vec = (VecName){NULL, 0, 0};
return false;
}
// Update the size of the temporary vec to record that it is holding the new
Expand Down