eval/typval: Make tv_list_item_alloc static

Better write this bit in lua then make reviewers or clint filter out 
tv_list_item_alloc().
This commit is contained in:
ZyX 2017-12-24 01:52:11 +03:00
parent 0c533a488f
commit 6bf3dc77c4
2 changed files with 8 additions and 4 deletions

View File

@ -52,7 +52,7 @@ const char *const tv_empty_string = "";
/// and specifically set lv_lock.
///
/// @return [allocated] new list item.
listitem_T *tv_list_item_alloc(void)
static listitem_T *tv_list_item_alloc(void)
FUNC_ATTR_NONNULL_RET FUNC_ATTR_MALLOC
{
return xmalloc(sizeof(listitem_T));

View File

@ -7,7 +7,7 @@ local ffi = helpers.ffi
local eq = helpers.eq
local eval = cimport('./src/nvim/eval.h', './src/nvim/eval/typval.h',
'./src/nvim/hashtab.h')
'./src/nvim/hashtab.h', './src/nvim/memory.h')
local null_string = {[true]='NULL string'}
local null_list = {[true]='NULL list'}
@ -24,10 +24,14 @@ local nil_value = {[true]='nil'}
local lua2typvalt
local function tv_list_item_alloc()
return ffi.cast('listitem_T*', eval.xmalloc(ffi.sizeof('listitem_T')))
end
local function li_alloc(nogc)
local gcfunc = eval.tv_list_item_free
if nogc then gcfunc = nil end
local li = ffi.gc(eval.tv_list_item_alloc(), gcfunc)
local li = ffi.gc(tv_list_item_alloc(), gcfunc)
li.li_next = nil
li.li_prev = nil
li.li_tv = {v_type=eval.VAR_UNKNOWN, v_lock=eval.VAR_UNLOCKED}
@ -41,7 +45,7 @@ local function populate_list(l, lua_l, processed)
processed[lua_l] = l
for i = 1, #lua_l do
local item_tv = ffi.gc(lua2typvalt(lua_l[i], processed), nil)
local item_li = eval.tv_list_item_alloc()
local item_li = tv_list_item_alloc()
item_li.li_tv = item_tv
eval.tv_list_append(l, item_li)
end