aboutsummaryrefslogtreecommitdiff
path: root/vis-motions.c
diff options
context:
space:
mode:
authorMarc André Tanner <mat@brain-dump.org>2016-01-10 12:32:04 +0100
committerMarc André Tanner <mat@brain-dump.org>2016-01-10 12:45:58 +0100
commitb1c4b7249a33098ca7f2e8f2b786e969493dddcf (patch)
tree1a9db1a93281d5b4a8ccef3a68c9a1fb447cda73 /vis-motions.c
parente6e077c8469f857ac58d804c788e887ce86e2303 (diff)
downloadvis-b1c4b7249a33098ca7f2e8f2b786e969493dddcf.tar.gz
vis-b1c4b7249a33098ca7f2e8f2b786e969493dddcf.tar.xz
Simplify code by using text_bytes_alloc0
Diffstat (limited to 'vis-motions.c')
-rw-r--r--vis-motions.c8
1 files changed, 1 insertions, 7 deletions
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 */