-
Notifications
You must be signed in to change notification settings - Fork 227
[cpp] Overhaul resource ownership and record passing #1327
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
833c84f
9bfd0ee
4d82caf
89878de
b432127
f809b1b
103a132
8077194
e9e8f01
dd39693
8120c93
e31121e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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; | ||
} | ||
}; | ||
|
||
/// A vector in linear memory, freed unconditionally using free | ||
|
@@ -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_); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I agree with the direction of this change I just recall that There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 |
||
} | ||
data_ = b.data_; | ||
length = b.length; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
❤️