aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/buffer.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/nvim/buffer.c')
-rw-r--r--src/nvim/buffer.c23
1 files changed, 13 insertions, 10 deletions
diff --git a/src/nvim/buffer.c b/src/nvim/buffer.c
index fc28b0de70..39014d903a 100644
--- a/src/nvim/buffer.c
+++ b/src/nvim/buffer.c
@@ -5144,22 +5144,25 @@ void sign_mark_adjust(linenr_T line1, linenr_T line2, long amount, long amount_a
// bufhl: plugin highlights associated with a buffer
-/// Get reference to line in kbtree_t, allocating it if neccessary.
+/// Get reference to line in kbtree_t
+///
+/// @param b the three
+/// @param line the linenumber to lookup
+/// @param put if true, put a new line when not found
+/// if false, return NULL when not found
BufhlLine *bufhl_tree_ref(kbtree_t(bufhl) *b, linenr_T line, bool put) {
- BufhlLine t, *p, **pp;
- t.line = line;
+ BufhlLine t = BUFHLLINE_INIT(line);
- // put() only works if key is absent
- pp = kb_get(bufhl, b, &t);
+ // kp_put() only works if key is absent, try get first
+ BufhlLine **pp = kb_get(bufhl, b, &t);
if (pp) {
return *pp;
} else if (!put) {
return NULL;
}
- p = xcalloc(sizeof(*p), 1);
- p->line = line;
- // p->items zero initialized
+ BufhlLine *p = xmalloc(sizeof(*p));
+ *p = (BufhlLine)BUFHLLINE_INIT(line);
kb_put(bufhl, b, p);
return p;
}
@@ -5231,7 +5234,7 @@ void bufhl_clear_line_range(buf_T *buf,
linenr_T first_changed = MAXLNUM, last_changed = -1;
kbitr_t(bufhl) itr;
- BufhlLine *l, t = {line_start};
+ BufhlLine *l, t = BUFHLLINE_INIT(line_start);
if (!kb_itr_get(bufhl, &buf->b_bufhl_info, &t, &itr)) {
kb_itr_next(bufhl, &buf->b_bufhl_info, &itr);
}
@@ -5313,7 +5316,7 @@ void bufhl_mark_adjust(buf_T* buf,
// we need to detect this case and
kbitr_t(bufhl) itr;
- BufhlLine *l, t = {line1};
+ BufhlLine *l, t = BUFHLLINE_INIT(line1);
if (!kb_itr_get(bufhl, &buf->b_bufhl_info, &t, &itr)) {
kb_itr_next(bufhl, &buf->b_bufhl_info, &itr);
}