aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/eval/funcs.c
diff options
context:
space:
mode:
authorbfredl <bjorn.linse@gmail.com>2024-02-11 15:46:14 +0100
committerbfredl <bjorn.linse@gmail.com>2024-02-13 11:54:44 +0100
commit0353dd3029f9ce31c3894530385443a90f6677ee (patch)
treefa288427461ee2c1ce1c271d01a760977a161bf5 /src/nvim/eval/funcs.c
parent89135cff030b06f60cd596a9ae81cd9583987517 (diff)
downloadrneovim-0353dd3029f9ce31c3894530385443a90f6677ee.tar.gz
rneovim-0353dd3029f9ce31c3894530385443a90f6677ee.tar.bz2
rneovim-0353dd3029f9ce31c3894530385443a90f6677ee.zip
refactor(lua): use Arena when converting from lua stack to API args
and for return value of nlua_exec/nlua_call_ref, as this uses the same family of functions. NB: the handling of luaref:s is a bit of a mess. add api_luarefs_free_XX functions as a stop-gap as refactoring luarefs is a can of worms for another PR:s. as a minor feature/bug-fix, nvim_buf_call and nvim_win_call now preserves arbitrary return values.
Diffstat (limited to 'src/nvim/eval/funcs.c')
-rw-r--r--src/nvim/eval/funcs.c11
1 files changed, 5 insertions, 6 deletions
diff --git a/src/nvim/eval/funcs.c b/src/nvim/eval/funcs.c
index e4d2a219d9..726b9ce758 100644
--- a/src/nvim/eval/funcs.c
+++ b/src/nvim/eval/funcs.c
@@ -3278,13 +3278,11 @@ static bool has_wsl(void)
static TriState has_wsl = kNone;
if (has_wsl == kNone) {
Error err = ERROR_INIT;
- Object o = nlua_exec(STATIC_CSTR_AS_STRING("return vim.uv.os_uname()['release']:lower()"
- ":match('microsoft') and true or false"),
- (Array)ARRAY_DICT_INIT, &err);
+ Object o = NLUA_EXEC_STATIC("return vim.uv.os_uname()['release']:lower()"
+ ":match('microsoft')",
+ (Array)ARRAY_DICT_INIT, kRetNilBool, NULL, &err);
assert(!ERROR_SET(&err));
- assert(o.type == kObjectTypeBoolean);
- has_wsl = o.data.boolean ? kTrue : kFalse;
- api_free_object(o);
+ has_wsl = LUARET_TRUTHY(o) ? kTrue : kFalse;
}
return has_wsl == kTrue;
}
@@ -6963,6 +6961,7 @@ static void f_rpcrequest(typval_T *argvars, typval_T *rettv, EvalFuncData fptr)
ArenaMem res_mem = NULL;
Object result = rpc_send_call(chan_id, method, args, &res_mem, &err);
+ api_free_array(args);
if (l_provider_call_nesting) {
current_sctx = save_current_sctx;