mirror of
https://github.com/neovim/neovim
synced 2025-07-16 01:01:49 +00:00
Merge pull request #31539 from bfredl/wininfo
refactor(wininfo): change wininfo from a linked list to an array
This commit is contained in:
@ -5163,8 +5163,8 @@ win_T *win_alloc(win_T *after, bool hidden)
|
||||
return new_wp;
|
||||
}
|
||||
|
||||
// Free one wininfo_T.
|
||||
void free_wininfo(wininfo_T *wip, buf_T *bp)
|
||||
// Free one WinInfo.
|
||||
void free_wininfo(WinInfo *wip, buf_T *bp)
|
||||
{
|
||||
if (wip->wi_optset) {
|
||||
clear_winopt(&wip->wi_opt);
|
||||
@ -5229,30 +5229,24 @@ void win_free(win_T *wp, tabpage_T *tp)
|
||||
// Remove the window from the b_wininfo lists, it may happen that the
|
||||
// freed memory is re-used for another window.
|
||||
FOR_ALL_BUFFERS(buf) {
|
||||
for (wininfo_T *wip = buf->b_wininfo; wip != NULL; wip = wip->wi_next) {
|
||||
WinInfo *wip_wp = NULL;
|
||||
size_t pos_null = kv_size(buf->b_wininfo);
|
||||
for (size_t i = 0; i < kv_size(buf->b_wininfo); i++) {
|
||||
WinInfo *wip = kv_A(buf->b_wininfo, i);
|
||||
if (wip->wi_win == wp) {
|
||||
wininfo_T *wip2;
|
||||
wip_wp = wip;
|
||||
} else if (wip->wi_win == NULL) {
|
||||
pos_null = i;
|
||||
}
|
||||
}
|
||||
|
||||
// If there already is an entry with "wi_win" set to NULL it
|
||||
// must be removed, it would never be used.
|
||||
// Skip "wip" itself, otherwise Coverity complains.
|
||||
for (wip2 = buf->b_wininfo; wip2 != NULL; wip2 = wip2->wi_next) {
|
||||
// `wip2 != wip` to satisfy Coverity. #14884
|
||||
if (wip2 != wip && wip2->wi_win == NULL) {
|
||||
if (wip2->wi_next != NULL) {
|
||||
wip2->wi_next->wi_prev = wip2->wi_prev;
|
||||
}
|
||||
if (wip2->wi_prev == NULL) {
|
||||
buf->b_wininfo = wip2->wi_next;
|
||||
} else {
|
||||
wip2->wi_prev->wi_next = wip2->wi_next;
|
||||
}
|
||||
free_wininfo(wip2, buf);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
wip->wi_win = NULL;
|
||||
if (wip_wp) {
|
||||
wip_wp->wi_win = NULL;
|
||||
// If there already is an entry with "wi_win" set to NULL it
|
||||
// must be removed, it would never be used.
|
||||
if (pos_null < kv_size(buf->b_wininfo)) {
|
||||
free_wininfo(kv_A(buf->b_wininfo, pos_null), buf);
|
||||
kv_shift(buf->b_wininfo, pos_null, 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user