mirror of
https://codeberg.org/dnkl/foot.git
synced 2026-04-14 08:21:27 -04:00
osc: allocate data buffer dynamically
This commit is contained in:
parent
95ff37afd7
commit
153628a217
5 changed files with 30 additions and 4 deletions
20
osc.c
20
osc.c
|
|
@ -83,3 +83,23 @@ osc_dispatch(struct terminal *term)
|
|||
break;
|
||||
}
|
||||
}
|
||||
|
||||
bool
|
||||
osc_ensure_size(struct terminal *term, size_t required_size)
|
||||
{
|
||||
if (required_size <= term->vt.osc.size)
|
||||
return true;
|
||||
|
||||
size_t new_size = (required_size + 127) / 128 * 128;
|
||||
assert(new_size > 0);
|
||||
|
||||
uint8_t *new_data = realloc(term->vt.osc.data, new_size);
|
||||
if (new_data == NULL) {
|
||||
LOG_ERRNO("failed to increase size of OSC buffer");
|
||||
return false;
|
||||
}
|
||||
|
||||
term->vt.osc.data = new_data;
|
||||
term->vt.osc.size = new_size;
|
||||
return true;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue