diff options
author | ZyX <kp-pav@yandex.ru> | 2018-01-03 00:00:16 +0300 |
---|---|---|
committer | ZyX <kp-pav@yandex.ru> | 2018-01-14 01:33:16 +0300 |
commit | 9ea1752d60589e8fc5e7184144bc6d1c1b9f16a3 (patch) | |
tree | 8d7fd11beeb2a300bd21f997e3fdca5b4f29382e /src/nvim/lua/converter.c | |
parent | 9ddeb6e187e6ef6045bf037e4225dc46c8efb693 (diff) | |
download | rneovim-9ea1752d60589e8fc5e7184144bc6d1c1b9f16a3.tar.gz rneovim-9ea1752d60589e8fc5e7184144bc6d1c1b9f16a3.tar.bz2 rneovim-9ea1752d60589e8fc5e7184144bc6d1c1b9f16a3.zip |
*: Provide list length when allocating lists
Diffstat (limited to 'src/nvim/lua/converter.c')
-rw-r--r-- | src/nvim/lua/converter.c | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/src/nvim/lua/converter.c b/src/nvim/lua/converter.c index 61cb428923..9e3063b164 100644 --- a/src/nvim/lua/converter.c +++ b/src/nvim/lua/converter.c @@ -211,7 +211,7 @@ bool nlua_pop_typval(lua_State *lstate, typval_T *ret_tv) size_t len; const char *s = lua_tolstring(lstate, -2, &len); if (cur.special) { - list_T *const kv_pair = tv_list_alloc(); + list_T *const kv_pair = tv_list_alloc(2); typval_T s_tv = decode_string(s, len, kTrue, false, false); if (s_tv.v_type == VAR_UNKNOWN) { @@ -321,7 +321,7 @@ bool nlua_pop_typval(lua_State *lstate, typval_T *ret_tv) switch (table_props.type) { case kObjectTypeArray: { cur.tv->v_type = VAR_LIST; - cur.tv->vval.v_list = tv_list_alloc(); + cur.tv->vval.v_list = tv_list_alloc((ptrdiff_t)table_props.maxidx); tv_list_ref(cur.tv->vval.v_list); if (table_props.maxidx != 0) { cur.container = true; @@ -338,7 +338,8 @@ bool nlua_pop_typval(lua_State *lstate, typval_T *ret_tv) } else { cur.special = table_props.has_string_with_nul; if (table_props.has_string_with_nul) { - decode_create_map_special_dict(cur.tv); + decode_create_map_special_dict( + cur.tv, (ptrdiff_t)table_props.string_keys_num); assert(cur.tv->v_type == VAR_DICT); dictitem_T *const val_di = tv_dict_find(cur.tv->vval.v_dict, S_LEN("_VAL")); |