From 9ada9861f63985dd7f9bcfa0a59dc555539243df Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Mon, 13 Sep 2021 11:52:40 -0400 Subject: [PATCH] vere: refactors _term_it_send_csi() --- pkg/urbit/vere/io/term.c | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/pkg/urbit/vere/io/term.c b/pkg/urbit/vere/io/term.c index a15f26454..8a337fe6e 100644 --- a/pkg/urbit/vere/io/term.c +++ b/pkg/urbit/vere/io/term.c @@ -342,25 +342,24 @@ _term_it_send_csi(u3_utty *uty_u, c3_c cmd_c, c3_w num_w, ...) // argument digits (5 per arg) and separators (1 per arg, minus 1). // freed via _term_it_write. // - c3_c* pas_c = malloc( sizeof(*pas_c) * (2 + num_w * 6) ); - c3_c was_c = 0; + c3_c* pas_c = c3_malloc( 2 + num_w * 6 ); + c3_y len_y = 0; - pas_c[was_c++] = '\033'; - pas_c[was_c++] = '['; + pas_c[len_y++] = '\033'; + pas_c[len_y++] = '['; - while ( num_w > 0 ) { + while ( num_w-- ) { c3_w par_w = va_arg(ap, c3_w); - was_c += sprintf(pas_c+was_c, "%d", par_w); + len_y += sprintf(pas_c+len_y, "%d", par_w); - if ( --num_w > 0 ) { - pas_c[was_c++] = ';'; + if ( num_w ) { + pas_c[len_y++] = ';'; } } - pas_c[was_c++] = cmd_c; + pas_c[len_y++] = cmd_c; - uv_buf_t pas_u = uv_buf_init(pas_c, was_c); - _term_it_write(uty_u, &pas_u, pas_c); + _term_it_send(uty_u, len_y, (c3_y*)pas_c); va_end(ap); }