aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/runtime.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/runtime.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/runtime.c')
-rw-r--r--src/nvim/runtime.c13
1 files changed, 7 insertions, 6 deletions
diff --git a/src/nvim/runtime.c b/src/nvim/runtime.c
index 98e9d6c9e6..44fcc29ad1 100644
--- a/src/nvim/runtime.c
+++ b/src/nvim/runtime.c
@@ -592,13 +592,13 @@ Array runtime_inspect(void)
return rv;
}
-ArrayOf(String) runtime_get_named(bool lua, Array pat, bool all)
+ArrayOf(String) runtime_get_named(bool lua, Array pat, bool all, Arena *arena)
{
int ref;
RuntimeSearchPath path = runtime_search_path_get_cached(&ref);
static char buf[MAXPATHL];
- ArrayOf(String) rv = runtime_get_named_common(lua, pat, all, path, buf, sizeof buf);
+ ArrayOf(String) rv = runtime_get_named_common(lua, pat, all, path, buf, sizeof buf, arena);
runtime_search_path_unref(path, &ref);
return rv;
@@ -610,15 +610,16 @@ ArrayOf(String) runtime_get_named_thread(bool lua, Array pat, bool all)
uv_mutex_lock(&runtime_search_path_mutex);
static char buf[MAXPATHL];
ArrayOf(String) rv = runtime_get_named_common(lua, pat, all, runtime_search_path_thread,
- buf, sizeof buf);
+ buf, sizeof buf, NULL);
uv_mutex_unlock(&runtime_search_path_mutex);
return rv;
}
static ArrayOf(String) runtime_get_named_common(bool lua, Array pat, bool all,
- RuntimeSearchPath path, char *buf, size_t buf_len)
+ RuntimeSearchPath path, char *buf, size_t buf_len,
+ Arena *arena)
{
- ArrayOf(String) rv = ARRAY_DICT_INIT;
+ ArrayOf(String) rv = arena_array(arena, kv_size(path) * pat.size);
for (size_t i = 0; i < kv_size(path); i++) {
SearchPathItem *item = &kv_A(path, i);
if (lua) {
@@ -638,7 +639,7 @@ static ArrayOf(String) runtime_get_named_common(bool lua, Array pat, bool all,
item->path, pat_item.data.string.data);
if (size < buf_len) {
if (os_file_is_readable(buf)) {
- ADD(rv, CSTR_TO_OBJ(buf));
+ ADD_C(rv, CSTR_TO_ARENA_OBJ(arena, buf));
if (!all) {
goto done;
}