mirror of
https://github.com/neovim/neovim.git
synced 2024-12-23 20:55:18 -07:00
fix(api): don't leak memory with nvim_win_get_ns (#27570)
This commit is contained in:
parent
2137edbd4f
commit
711a2f5ff6
@ -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
|
||||
/// @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)
|
||||
{
|
||||
Array rv = ARRAY_DICT_INIT;
|
||||
|
||||
win_T *win = find_window_by_handle(window, err);
|
||||
if (!win) {
|
||||
return rv;
|
||||
return (Array)ARRAY_DICT_INIT;
|
||||
}
|
||||
|
||||
Array rv = arena_array(arena, set_size(&win->w_ns_set));
|
||||
uint32_t i;
|
||||
set_foreach(&win->w_ns_set, i, {
|
||||
ADD(rv, INTEGER_OBJ((Integer)(i)));
|
||||
ADD_C(rv, INTEGER_OBJ((Integer)(i)));
|
||||
});
|
||||
|
||||
return rv;
|
||||
@ -1288,7 +1288,7 @@ Boolean nvim_win_remove_ns(Window window, Integer ns_id, Error *err)
|
||||
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);
|
||||
|
||||
|
@ -5792,7 +5792,8 @@ describe('decorations: window scoped', function()
|
||||
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 {
|
||||
grid = [[
|
||||
@ -5803,10 +5804,12 @@ describe('decorations: window scoped', function()
|
||||
|
||||
command 'split'
|
||||
command 'only'
|
||||
eq({}, api.nvim_win_get_ns(0))
|
||||
|
||||
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 {
|
||||
grid = [[
|
||||
|
Loading…
Reference in New Issue
Block a user