diff options
author | Justin M. Keyes <justinkz@gmail.com> | 2015-12-12 20:41:00 -0500 |
---|---|---|
committer | Justin M. Keyes <justinkz@gmail.com> | 2015-12-12 20:41:00 -0500 |
commit | 5c4a5d067731c72f12344130da200049f4e53bca (patch) | |
tree | 8ecf60bd3d300c3c571948a5fa373a6ed7dad689 | |
parent | cc203e4b93d920cb749f80336504d7e6df0081a2 (diff) | |
parent | 5b96d370dfff77acad6bf327384be40b2213d4ee (diff) | |
download | rneovim-5c4a5d067731c72f12344130da200049f4e53bca.tar.gz rneovim-5c4a5d067731c72f12344130da200049f4e53bca.tar.bz2 rneovim-5c4a5d067731c72f12344130da200049f4e53bca.zip |
Merge pull request #3589 from ZyX-I/remove-internal_refcount
eval: Replace internal_refcount hack with proper copyID setting
-rw-r--r-- | src/nvim/eval.c | 16 | ||||
-rw-r--r-- | src/nvim/eval_defs.h | 2 |
2 files changed, 10 insertions, 8 deletions
diff --git a/src/nvim/eval.c b/src/nvim/eval.c index 4a2bf2ac7a..b60886704e 100644 --- a/src/nvim/eval.c +++ b/src/nvim/eval.c @@ -5651,6 +5651,14 @@ bool garbage_collect(void) ABORTING(set_ref_in_ht)(&fc->l_avars.dv_hashtab, copyID, NULL); } + // Jobs + { + TerminalJobData *data; + map_foreach_value(jobs, data, { + ABORTING(set_ref_dict)(data->self, copyID); + }) + } + // v: vars ABORTING(set_ref_in_ht)(&vimvarht, copyID, NULL); @@ -5728,8 +5736,7 @@ static int free_unref_items(int copyID) // Go through the list of dicts and free items without the copyID. // Don't free dicts that are referenced internally. for (dict_T *dd = first_dict; dd != NULL; ) { - if ((dd->dv_copyID & COPYID_MASK) != (copyID & COPYID_MASK) - && !dd->internal_refcount) { + if ((dd->dv_copyID & COPYID_MASK) != (copyID & COPYID_MASK)) { // Free the Dictionary and ordinary items it contains, but don't // recurse into Lists and Dictionaries, they will be in the list // of dicts or list of lists. */ @@ -5970,7 +5977,6 @@ dict_T *dict_alloc(void) FUNC_ATTR_NONNULL_RET d->dv_scope = 0; d->dv_refcount = 0; d->dv_copyID = 0; - d->internal_refcount = 0; QUEUE_INIT(&d->watchers); return d; @@ -21620,7 +21626,6 @@ static inline bool common_job_callbacks(dict_T *vopts, ufunc_T **on_stdout, if (get_dict_callback(vopts, "on_stdout", on_stdout) && get_dict_callback(vopts, "on_stderr", on_stderr) && get_dict_callback(vopts, "on_exit", on_exit)) { - vopts->internal_refcount++; vopts->dv_refcount++; return true; } @@ -21682,7 +21687,6 @@ static inline void free_term_job_data_event(void **argv) } if (data->self) { - data->self->internal_refcount--; dict_unref(data->self); } queue_free(data->events); @@ -21933,7 +21937,7 @@ typval_T eval_call_provider(char *provider, char *method, list_T *arguments) true, NULL); - arguments->lv_refcount--; + list_unref(arguments); // Restore caller scope information restore_funccal(provider_caller_scope.funccalp); provider_caller_scope = saved_provider_caller_scope; diff --git a/src/nvim/eval_defs.h b/src/nvim/eval_defs.h index bd50d6b829..ed419268d2 100644 --- a/src/nvim/eval_defs.h +++ b/src/nvim/eval_defs.h @@ -118,8 +118,6 @@ struct dictvar_S { dict_T *dv_copydict; /* copied dict used by deepcopy() */ dict_T *dv_used_next; /* next dict in used dicts list */ dict_T *dv_used_prev; /* previous dict in used dicts list */ - int internal_refcount; // number of internal references to - // prevent garbage collection QUEUE watchers; // dictionary key watchers set by user code }; |