diff options
author | Justin M. Keyes <justinkz@gmail.com> | 2016-02-23 04:27:52 -0500 |
---|---|---|
committer | Justin M. Keyes <justinkz@gmail.com> | 2016-02-23 04:27:52 -0500 |
commit | 47b5294b0f4111a1541438fa882e096d1555dbbf (patch) | |
tree | 95c93773700daae5d1acb43fff12c9b96f86600e | |
parent | 6f833c7881eb878b6b0650997f84aeb16b67b3f7 (diff) | |
parent | 5c09d5c3dee905303e5f6861fa6c2eb9d60f7743 (diff) | |
download | rneovim-47b5294b0f4111a1541438fa882e096d1555dbbf.tar.gz rneovim-47b5294b0f4111a1541438fa882e096d1555dbbf.tar.bz2 rneovim-47b5294b0f4111a1541438fa882e096d1555dbbf.zip |
Merge pull request #4330 from justinmk/set_vim_var_dict
set_vim_var_dict: Allow NULL `val`.
-rw-r--r-- | src/nvim/eval.c | 24 |
1 files changed, 12 insertions, 12 deletions
diff --git a/src/nvim/eval.c b/src/nvim/eval.c index 96fc79504f..b011ee9d54 100644 --- a/src/nvim/eval.c +++ b/src/nvim/eval.c @@ -18104,23 +18104,23 @@ void set_vim_var_list(int idx, list_T *val) } /// Set Dictionary v: variable to "val". -void set_vim_var_dict(int idx, dict_T *val) FUNC_ATTR_NONNULL_ALL +void set_vim_var_dict(int idx, dict_T *val) { dict_unref(vimvars[idx].vv_dict); + vimvars[idx].vv_dict = val; - // Set readonly - int todo = (int)val->dv_hashtab.ht_used; - for (hashitem_T *hi = val->dv_hashtab.ht_array; todo > 0 ; ++hi) { - if (HASHITEM_EMPTY(hi)) { - continue; + if (val != NULL) { + ++val->dv_refcount; + // Set readonly + size_t todo = val->dv_hashtab.ht_used; + for (hashitem_T *hi = val->dv_hashtab.ht_array; todo > 0 ; ++hi) { + if (HASHITEM_EMPTY(hi)) { + continue; + } + --todo; + HI2DI(hi)->di_flags = DI_FLAGS_RO | DI_FLAGS_FIX; } - - --todo; - HI2DI(hi)->di_flags = DI_FLAGS_RO | DI_FLAGS_FIX; } - - vimvars[idx].vv_dict = val; - ++val->dv_refcount; } /* |