diff options
Diffstat (limited to 'vis-motions.c')
| -rw-r--r-- | vis-motions.c | 8 |
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 */ |
