aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/api/buffer.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/nvim/api/buffer.c')
-rw-r--r--src/nvim/api/buffer.c9
1 files changed, 1 insertions, 8 deletions
diff --git a/src/nvim/api/buffer.c b/src/nvim/api/buffer.c
index 640b4d27a9..49b34e8dff 100644
--- a/src/nvim/api/buffer.c
+++ b/src/nvim/api/buffer.c
@@ -154,14 +154,7 @@ void buffer_set_slice(Buffer buffer,
size_t new_len = replacement.size;
size_t old_len = (size_t)(end - start);
ssize_t extra = 0; // lines added to text, can be negative
- char **lines;
-
- if (new_len == 0) {
- // avoid allocating zero bytes
- lines = NULL;
- } else {
- lines = xcalloc(sizeof(char *), new_len);
- }
+ char **lines = (new_len != 0) ? xmalloc(new_len * sizeof(char *)) : NULL;
for (size_t i = 0; i < new_len; i++) {
String l = replacement.items[i];