Skip to content
Merged
Show file tree
Hide file tree
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
14 changes: 13 additions & 1 deletion crates/cpp/helper-types/wit.h
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,18 @@ class string {
memcpy(addr, v.data(), v.size());
return string(addr, v.size());
}
char* begin() {
return (char*)data_;
}
char* end() {
return (char*)data_ + length;
}
char const* begin() const {
return (char const*)data_;
}
char const* end() const {
return (char const*)data_ + length;
}
Comment on lines +98 to +109
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

❤️

};

/// A vector in linear memory, freed unconditionally using free
Expand All @@ -113,7 +125,7 @@ template <class T> class vector {
vector &operator=(vector const &) = delete;
vector &operator=(vector &&b) {
if (data_ && length>0) {
free(const_cast<uint8_t *>(data_));
free(data_);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree with the direction of this change I just recall that wit::vector<const T> would trigger this, if I recall correctly. Probably the cause is removed by this new ownership design.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, I see where that might be hit. I think it would be better to generate a const wit::vector<T> instead of a wit::vector<const T>

}
data_ = b.data_;
length = b.length;
Expand Down
Loading