This commit is contained in:
@@ -476,6 +476,15 @@ evstring_push_impl(
|
|||||||
evstr_asserttype(*s);
|
evstr_asserttype(*s);
|
||||||
struct evstr_meta_t *meta = META(*s);
|
struct evstr_meta_t *meta = META(*s);
|
||||||
|
|
||||||
|
// Overlapping ranges, need to copy `data` to keep it alive after growing
|
||||||
|
if(*s < data + sz && data < *s + meta->length)
|
||||||
|
{
|
||||||
|
char *old_data = data;
|
||||||
|
data = ev_str_malloc(sz);
|
||||||
|
if(data == NULL) return EV_STR_ERR_OOM;
|
||||||
|
memcpy(data, old_data, sz);
|
||||||
|
}
|
||||||
|
|
||||||
// TODO Find a more efficient approach?
|
// TODO Find a more efficient approach?
|
||||||
u64 required_capacity = meta->length + sz + 1;
|
u64 required_capacity = meta->length + sz + 1;
|
||||||
while(required_capacity > meta->capacity) { // `<=` because of the null terminator
|
while(required_capacity > meta->capacity) { // `<=` because of the null terminator
|
||||||
|
|||||||
Reference in New Issue
Block a user