Skip to content

Commit 24eebf7

Browse files
authored
[cpp] Overhaul resource ownership and record passing (bytecodealliance#1327)
* Use value types for asymmetric API * Correct test arguments * Update docs * Format * Review feedback * Implement different ownership rules * Fix rebase errors * Remove old file * Revert wit::string changes * format * Fix borrowed handles in lists * Formatting
1 parent eb2da2f commit 24eebf7

File tree

14 files changed

+517
-257
lines changed

14 files changed

+517
-257
lines changed

crates/cpp/helper-types/wit.h

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,18 @@ class string {
9595
memcpy(addr, v.data(), v.size());
9696
return string(addr, v.size());
9797
}
98+
char* begin() {
99+
return (char*)data_;
100+
}
101+
char* end() {
102+
return (char*)data_ + length;
103+
}
104+
char const* begin() const {
105+
return (char const*)data_;
106+
}
107+
char const* end() const {
108+
return (char const*)data_ + length;
109+
}
98110
};
99111

100112
/// A vector in linear memory, freed unconditionally using free
@@ -113,7 +125,7 @@ template <class T> class vector {
113125
vector &operator=(vector const &) = delete;
114126
vector &operator=(vector &&b) {
115127
if (data_ && length>0) {
116-
free(const_cast<uint8_t *>(data_));
128+
free(data_);
117129
}
118130
data_ = b.data_;
119131
length = b.length;

0 commit comments

Comments
 (0)