kbtree: make warning free and delete deprecated macros

This commit is contained in:
Björn Linse
2016-08-28 13:26:01 +02:00
parent 14e19b8aaf
commit 28a549d597
4 changed files with 53 additions and 70 deletions

View File

@@ -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);
}