Skip to content

Commit

Permalink
Set the rhs vec to invalid_size after a move (#109)
Browse files Browse the repository at this point in the history
* Set the rhs vec to invalid_size after a move

* Fixed a couple more invalid_size resets
  • Loading branch information
billti authored and rossberg committed Oct 2, 2019
1 parent 6db391e commit acd4a52
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion include/wasm.hh
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,9 @@ class vec {
public:
using elem_type = T;

vec(vec<T>&& that) : vec(that.size_, that.data_.release()) {}
vec(vec<T>&& that) : vec(that.size_, that.data_.release()) {
that.size_ = invalid_size;
}

~vec() {
free_data();
Expand All @@ -80,6 +82,7 @@ public:
}

auto release() -> T* {
size_ = invalid_size;
return data_.release();
}

Expand All @@ -93,6 +96,7 @@ public:
free_data();
size_ = that.size_;
data_.reset(that.data_.release());
that.size_ = invalid_size;
}

auto operator=(vec&& that) -> vec& {
Expand Down

0 comments on commit acd4a52

Please sign in to comment.