mirror of
https://github.com/neovim/neovim.git
synced 2025-10-03 16:36:30 +00:00
tv_dict_watcher_notify: any_needs_free
This commit is contained in:

committed by
Jan Edmund Lazo

parent
aca002e7d5
commit
d6cac809b0
@@ -1267,6 +1267,7 @@ void tv_dict_watcher_notify(dict_T *const dict, const char *const key,
|
|||||||
|
|
||||||
typval_T rettv;
|
typval_T rettv;
|
||||||
|
|
||||||
|
bool any_needs_free = false;
|
||||||
dict->dv_refcount++;
|
dict->dv_refcount++;
|
||||||
QUEUE *w;
|
QUEUE *w;
|
||||||
QUEUE_FOREACH(w, &dict->watchers, {
|
QUEUE_FOREACH(w, &dict->watchers, {
|
||||||
@@ -1277,15 +1278,20 @@ void tv_dict_watcher_notify(dict_T *const dict, const char *const key,
|
|||||||
callback_call(&watcher->callback, 3, argv, &rettv);
|
callback_call(&watcher->callback, 3, argv, &rettv);
|
||||||
watcher->busy = false;
|
watcher->busy = false;
|
||||||
tv_clear(&rettv);
|
tv_clear(&rettv);
|
||||||
|
if (watcher->needs_free) {
|
||||||
|
any_needs_free = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
QUEUE_FOREACH(w, &dict->watchers, {
|
if (any_needs_free) {
|
||||||
DictWatcher *watcher = tv_dict_watcher_node_data(w);
|
QUEUE_FOREACH(w, &dict->watchers, {
|
||||||
if (watcher->needs_free) {
|
DictWatcher *watcher = tv_dict_watcher_node_data(w);
|
||||||
QUEUE_REMOVE(w);
|
if (watcher->needs_free) {
|
||||||
tv_dict_watcher_free(watcher);
|
QUEUE_REMOVE(w);
|
||||||
}
|
tv_dict_watcher_free(watcher);
|
||||||
})
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
tv_dict_unref(dict);
|
tv_dict_unref(dict);
|
||||||
|
|
||||||
for (size_t i = 1; i < ARRAY_SIZE(argv); i++) {
|
for (size_t i = 1; i < ARRAY_SIZE(argv); i++) {
|
||||||
|
Reference in New Issue
Block a user