This commit is contained in:
Nikita Ivanov 2022-05-26 03:03:55 +05:00
parent 0ab9be934f
commit 04fc61c901
No known key found for this signature in database
GPG Key ID: 6E656AC5B97B5133

View File

@ -113,11 +113,13 @@ void char_v_append(CharVec *v, char c)
if (v->len + 1 >= v->cap) {
v->cap *= 2;
v->buf = realloc(v->buf, v->cap * sizeof(v->buf[0]));
if (!v->buf) {
void *new = realloc(v->buf, v->cap * sizeof(v->buf[0]));
if (!new) {
free(v->buf);
PRINTINTERR(FUNCFAILED("realloc"), ERRNOS);
abort();
}
v->buf = new;
}
v->buf[v->len - 1] = c;