mirror of
https://github.com/neovim/neovim
synced 2025-07-16 17:21:49 +00:00
fix(api): don't leak memory with nvim_win_get_ns (#27570)
This commit is contained in:
@ -1254,18 +1254,18 @@ Boolean nvim_win_add_ns(Window window, Integer ns_id, Error *err)
|
|||||||
///
|
///
|
||||||
/// @param window Window handle, or 0 for current window
|
/// @param window Window handle, or 0 for current window
|
||||||
/// @return a list of namespaces ids
|
/// @return a list of namespaces ids
|
||||||
ArrayOf(Integer) nvim_win_get_ns(Window window, Error *err)
|
ArrayOf(Integer) nvim_win_get_ns(Window window, Arena *arena, Error *err)
|
||||||
FUNC_API_SINCE(12)
|
FUNC_API_SINCE(12)
|
||||||
{
|
{
|
||||||
Array rv = ARRAY_DICT_INIT;
|
|
||||||
|
|
||||||
win_T *win = find_window_by_handle(window, err);
|
win_T *win = find_window_by_handle(window, err);
|
||||||
if (!win) {
|
if (!win) {
|
||||||
return rv;
|
return (Array)ARRAY_DICT_INIT;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Array rv = arena_array(arena, set_size(&win->w_ns_set));
|
||||||
uint32_t i;
|
uint32_t i;
|
||||||
set_foreach(&win->w_ns_set, i, {
|
set_foreach(&win->w_ns_set, i, {
|
||||||
ADD(rv, INTEGER_OBJ((Integer)(i)));
|
ADD_C(rv, INTEGER_OBJ((Integer)(i)));
|
||||||
});
|
});
|
||||||
|
|
||||||
return rv;
|
return rv;
|
||||||
@ -1288,7 +1288,7 @@ Boolean nvim_win_remove_ns(Window window, Integer ns_id, Error *err)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
set_del_uint32_t(&win->w_ns_set, (uint32_t)ns_id);
|
set_del(uint32_t, &win->w_ns_set, (uint32_t)ns_id);
|
||||||
|
|
||||||
changed_window_setting_win(win);
|
changed_window_setting_win(win);
|
||||||
|
|
||||||
|
@ -5792,7 +5792,8 @@ describe('decorations: window scoped', function()
|
|||||||
end_col = 3,
|
end_col = 3,
|
||||||
})
|
})
|
||||||
|
|
||||||
api.nvim_win_add_ns(0, ns)
|
eq(true, api.nvim_win_add_ns(0, ns))
|
||||||
|
eq({ ns }, api.nvim_win_get_ns(0))
|
||||||
|
|
||||||
screen:expect {
|
screen:expect {
|
||||||
grid = [[
|
grid = [[
|
||||||
@ -5803,10 +5804,12 @@ describe('decorations: window scoped', function()
|
|||||||
|
|
||||||
command 'split'
|
command 'split'
|
||||||
command 'only'
|
command 'only'
|
||||||
|
eq({}, api.nvim_win_get_ns(0))
|
||||||
|
|
||||||
screen:expect(noextmarks)
|
screen:expect(noextmarks)
|
||||||
|
|
||||||
api.nvim_win_add_ns(0, ns)
|
eq(true, api.nvim_win_add_ns(0, ns))
|
||||||
|
eq({ ns }, api.nvim_win_get_ns(0))
|
||||||
|
|
||||||
screen:expect {
|
screen:expect {
|
||||||
grid = [[
|
grid = [[
|
||||||
|
Reference in New Issue
Block a user