refactor(api): make freeing of return-value opt-in instead of opt out

As only a few API functions make use of explicit freeing of the return
value, make it opt-in instead. The arena is always present under the
hood, so `Arena *arena` arg now doesn't mean anything other than getting
access to this arena. Also it is in principle possible to return an
allocated value while still using the arena as scratch space for other
stuff (unlikely, but there no reason to not allow it).
This commit is contained in:
bfredl
2024-02-20 13:44:50 +01:00
parent 9bb046d1be
commit 3cc54586be
13 changed files with 33 additions and 37 deletions

View File

@@ -32,8 +32,8 @@
/// @deprecated Use nvim_exec2() instead.
/// @see nvim_exec2
String nvim_exec(uint64_t channel_id, String src, Boolean output, Error *err)
FUNC_API_SINCE(7)
FUNC_API_DEPRECATED_SINCE(11)
FUNC_API_SINCE(7) FUNC_API_DEPRECATED_SINCE(11)
FUNC_API_RET_ALLOC
{
Dict(exec_opts) opts = { .output = output };
return exec_impl(channel_id, src, &opts, err);
@@ -42,8 +42,8 @@ String nvim_exec(uint64_t channel_id, String src, Boolean output, Error *err)
/// @deprecated
/// @see nvim_exec2
String nvim_command_output(uint64_t channel_id, String command, Error *err)
FUNC_API_SINCE(1)
FUNC_API_DEPRECATED_SINCE(7)
FUNC_API_SINCE(1) FUNC_API_DEPRECATED_SINCE(7)
FUNC_API_RET_ALLOC
{
Dict(exec_opts) opts = { .output = true };
return exec_impl(channel_id, command, &opts, err);
@@ -541,7 +541,7 @@ void nvim_set_option(uint64_t channel_id, String name, Object value, Error *err)
/// @param name Option name
/// @param[out] err Error details, if any
/// @return Option value (global)
Object nvim_get_option(String name, Arena *arena, Error *err)
Object nvim_get_option(String name, Error *err)
FUNC_API_SINCE(1)
FUNC_API_DEPRECATED_SINCE(11)
{
@@ -555,7 +555,7 @@ Object nvim_get_option(String name, Arena *arena, Error *err)
/// @param name Option name
/// @param[out] err Error details, if any
/// @return Option value
Object nvim_buf_get_option(Buffer buffer, String name, Arena *arena, Error *err)
Object nvim_buf_get_option(Buffer buffer, String name, Error *err)
FUNC_API_SINCE(1)
FUNC_API_DEPRECATED_SINCE(11)
{
@@ -597,7 +597,7 @@ void nvim_buf_set_option(uint64_t channel_id, Buffer buffer, String name, Object
/// @param name Option name
/// @param[out] err Error details, if any
/// @return Option value
Object nvim_win_get_option(Window window, String name, Arena *arena, Error *err)
Object nvim_win_get_option(Window window, String name, Error *err)
FUNC_API_SINCE(1)
FUNC_API_DEPRECATED_SINCE(11)
{