vis

a vi-like editor based on Plan 9's structural regular expressions

git clone https://9o.is/git/vis.git

commit 209e61c919405114a836861bc83c5b4a1263a268
parent 588bc1238bd28fdd1069f3557feb9a86363dc7df
Author: Marc André Tanner <mat@brain-dump.org>
Date:   Mon, 18 Jan 2016 21:00:28 +0100

vis: simplify code by using text_bytes_alloc0

Diffstat:
Mmain.c | 5+----
1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/main.c b/main.c @@ -1167,12 +1167,9 @@ static const char *cursors_select_next(Vis *vis, const char *keys, const Arg *ar if (!text_range_valid(&sel)) return keys; - size_t len = text_range_size(&sel); - char *buf = malloc(len+1); + char *buf = text_bytes_alloc0(txt, sel.start, text_range_size(&sel)); if (!buf) return keys; - len = text_bytes_get(txt, sel.start, len, buf); - buf[len] = '\0'; Filerange word = text_object_word_find_next(txt, sel.end, buf); free(buf);