forked from aniani/vim
patch 8.1.2107: various memory leaks reported by asan
Problem: Various memory leaks reported by asan. Solution: Free the memory. (Ozaki Kiichi, closes #5003)
This commit is contained in:
20
src/change.c
20
src/change.c
@@ -300,7 +300,7 @@ f_listener_remove(typval_T *argvars, typval_T *rettv)
|
||||
int id = tv_get_number(argvars);
|
||||
buf_T *buf;
|
||||
|
||||
for (buf = firstbuf; buf != NULL; buf = buf->b_next)
|
||||
FOR_ALL_BUFFERS(buf)
|
||||
{
|
||||
prev = NULL;
|
||||
for (lnr = buf->b_listener; lnr != NULL; lnr = next)
|
||||
@@ -402,6 +402,24 @@ invoke_listeners(buf_T *buf)
|
||||
after_updating_screen(TRUE);
|
||||
recursive = FALSE;
|
||||
}
|
||||
|
||||
/*
|
||||
* Remove all listeners associated with "buf".
|
||||
*/
|
||||
void
|
||||
remove_listeners(buf_T *buf)
|
||||
{
|
||||
listener_T *lnr;
|
||||
listener_T *next;
|
||||
|
||||
for (lnr = buf->b_listener; lnr != NULL; lnr = next)
|
||||
{
|
||||
next = lnr->lr_next;
|
||||
free_callback(&lnr->lr_callback);
|
||||
vim_free(lnr);
|
||||
}
|
||||
buf->b_listener = NULL;
|
||||
}
|
||||
#endif
|
||||
|
||||
/*
|
||||
|
Reference in New Issue
Block a user