From b1c4b7249a33098ca7f2e8f2b786e969493dddcf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20Andr=C3=A9=20Tanner?= Date: Sun, 10 Jan 2016 12:32:04 +0100 Subject: Simplify code by using text_bytes_alloc0 --- vis-motions.c | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) (limited to 'vis-motions.c') diff --git a/vis-motions.c b/vis-motions.c index 754b132..8c2146f 100644 --- a/vis-motions.c +++ b/vis-motions.c @@ -10,13 +10,7 @@ static char *get_word_at(Text *txt, size_t pos) { Filerange word = text_object_word(txt, pos); if (!text_range_valid(&word)) return NULL; - size_t len = word.end - word.start; - char *buf = malloc(len+1); - if (!buf) - return NULL; - len = text_bytes_get(txt, word.start, len, buf); - buf[len] = '\0'; - return buf; + return text_bytes_alloc0(txt, word.start, word.end - word.start); } /** motion implementations */ -- cgit v1.2.3