aboutsummaryrefslogtreecommitdiff
path: root/osc.c
diff options
context:
space:
mode:
authorDaniel Eklöf <daniel@ekloef.se>2019-07-19 06:59:35 +0000
committerDaniel Eklöf <daniel@ekloef.se>2019-07-19 06:59:35 +0000
commit153628a21749f954c4182c72335a9c3524e9a336 (patch)
tree9976a598e0600b9ba74582be2865c97cbffbc235 /osc.c
parentosc: terminate reply with ST rather than BEL (diff)
osc: allocate data buffer dynamically
Diffstat (limited to 'osc.c')
-rw-r--r--osc.c20
1 files changed, 20 insertions, 0 deletions
diff --git a/osc.c b/osc.c
index 5697b230..21ee67c0 100644
--- a/osc.c
+++ b/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;
+}