Compare commits

...

2 Commits

Author SHA1 Message Date
kayomn 298c7bfe94 Fix runtime error regression in core::copy 2023-02-19 16:32:02 +00:00
kayomn 3a9a6a34bb Fix runtime error regression in core::copy 2023-02-19 16:31:45 +00:00
2 changed files with 3 additions and 4 deletions

View File

@ -480,7 +480,7 @@ export namespace core {
void copy(slice<u8> const & target, slice<u8 const> const & origin) {
if (target.length < origin.length) core::unreachable();
for (usize i = 0; i < target.length; i += 1) target[i] = origin[i];
for (usize i = 0; i < origin.length; i += 1) target[i] = origin[i];
}
/**

View File

@ -70,8 +70,7 @@ export namespace core {
usize const updated_fill = this->filled + source_elements.length;
if (updated_fill >= this->elements.length) {
append_result const result =
this->reserve(max(this->elements.length, updated_fill));
append_result const result = this->reserve(updated_fill);
if (result != append_result::ok) return result;
}
@ -155,7 +154,7 @@ export namespace core {
* `initial_capacity` argument.
*/
append_result reserve(usize capacity) {
usize const requested_capacity = this->elements.length + capacity;
usize const requested_capacity = this->filled + capacity;
if (this->is_dynamic()) {
// Grow dynamic buffer (bailing out if failed).