aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/api
diff options
context:
space:
mode:
Diffstat (limited to 'src/nvim/api')
-rw-r--r--src/nvim/api/buffer.c2
-rw-r--r--src/nvim/api/deprecated.c14
-rw-r--r--src/nvim/api/extmark.c2
-rw-r--r--src/nvim/api/options.c2
-rw-r--r--src/nvim/api/private/dispatch.h4
-rw-r--r--src/nvim/api/private/helpers.h7
-rw-r--r--src/nvim/api/vim.c17
-rw-r--r--src/nvim/api/vimscript.c2
8 files changed, 22 insertions, 28 deletions
diff --git a/src/nvim/api/buffer.c b/src/nvim/api/buffer.c
index ad25451054..41a3743895 100644
--- a/src/nvim/api/buffer.c
+++ b/src/nvim/api/buffer.c
@@ -956,7 +956,7 @@ void nvim_buf_del_var(Buffer buffer, String name, Error *err)
/// @param buffer Buffer handle, or 0 for current buffer
/// @param[out] err Error details, if any
/// @return Buffer name
-String nvim_buf_get_name(Buffer buffer, Arena *arena, Error *err)
+String nvim_buf_get_name(Buffer buffer, Error *err)
FUNC_API_SINCE(1)
{
String rv = STRING_INIT;
diff --git a/src/nvim/api/deprecated.c b/src/nvim/api/deprecated.c
index f805c945f3..404e85cf91 100644
--- a/src/nvim/api/deprecated.c
+++ b/src/nvim/api/deprecated.c
@@ -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)
{
diff --git a/src/nvim/api/extmark.c b/src/nvim/api/extmark.c
index 0b5f3471fb..fb729be23e 100644
--- a/src/nvim/api/extmark.c
+++ b/src/nvim/api/extmark.c
@@ -1203,7 +1203,7 @@ free_exit:
}
String nvim__buf_debug_extmarks(Buffer buffer, Boolean keys, Boolean dot, Error *err)
- FUNC_API_SINCE(7)
+ FUNC_API_SINCE(7) FUNC_API_RET_ALLOC
{
buf_T *buf = find_buffer_by_handle(buffer, err);
if (!buf) {
diff --git a/src/nvim/api/options.c b/src/nvim/api/options.c
index 8128fdf67b..7deadb8eb5 100644
--- a/src/nvim/api/options.c
+++ b/src/nvim/api/options.c
@@ -150,7 +150,7 @@ static buf_T *do_ft_buf(char *filetype, aco_save_T *aco, Error *err)
/// @param[out] err Error details, if any
/// @return Option value
Object nvim_get_option_value(String name, Dict(option) *opts, Error *err)
- FUNC_API_SINCE(9)
+ FUNC_API_SINCE(9) FUNC_API_RET_ALLOC
{
OptIndex opt_idx = 0;
int scope = 0;
diff --git a/src/nvim/api/private/dispatch.h b/src/nvim/api/private/dispatch.h
index 6d051176ac..288f368fba 100644
--- a/src/nvim/api/private/dispatch.h
+++ b/src/nvim/api/private/dispatch.h
@@ -18,8 +18,8 @@ struct MsgpackRpcRequestHandler {
///< uv loop (the loop is run very frequently due to breakcheck).
///< If "fast" is false, the function is deferred, i e the call will
///< be put in the event queue, for safe handling later.
- bool arena_return; ///< return value is allocated in the arena (or statically)
- ///< and should not be freed as such.
+ bool ret_alloc; ///< return value is allocated and should be freed using api_free_object
+ ///< otherwise it uses arena and/or static memory
};
extern const MsgpackRpcRequestHandler method_handlers[];
diff --git a/src/nvim/api/private/helpers.h b/src/nvim/api/private/helpers.h
index 20bc889a0a..7eda8ffaf6 100644
--- a/src/nvim/api/private/helpers.h
+++ b/src/nvim/api/private/helpers.h
@@ -125,13 +125,6 @@ typedef kvec_withinit_t(Object, 16) ArrayBuilder;
#define KEYDICT_INIT { 0 }
-#define api_free_boolean(value)
-#define api_free_integer(value)
-#define api_free_float(value)
-#define api_free_buffer(value)
-#define api_free_window(value)
-#define api_free_tabpage(value)
-
EXTERN PMap(int) buffer_handles INIT( = MAP_INIT);
EXTERN PMap(int) window_handles INIT( = MAP_INIT);
EXTERN PMap(int) tabpage_handles INIT( = MAP_INIT);
diff --git a/src/nvim/api/vim.c b/src/nvim/api/vim.c
index c6043a2871..2888656a7a 100644
--- a/src/nvim/api/vim.c
+++ b/src/nvim/api/vim.c
@@ -461,7 +461,7 @@ error:
/// @see replace_termcodes
/// @see cpoptions
String nvim_replace_termcodes(String str, Boolean from_part, Boolean do_lt, Boolean special)
- FUNC_API_SINCE(1)
+ FUNC_API_SINCE(1) FUNC_API_RET_ALLOC
{
if (str.size == 0) {
// Empty string
@@ -601,6 +601,7 @@ static bool find_runtime_cb(int num_fnames, char **fnames, bool all, void *c)
}
String nvim__get_lib_dir(void)
+ FUNC_API_RET_ALLOC
{
return cstr_as_string(get_lib_dir());
}
@@ -1726,7 +1727,7 @@ Array nvim_call_atomic(uint64_t channel_id, Array calls, Arena *arena, Error *er
// directly here. But `result` might become invalid when next api function
// is called in the loop.
ADD_C(results, copy_object(result, arena));
- if (!handler.arena_return) {
+ if (handler.ret_alloc) {
api_free_object(result);
}
}
@@ -1806,9 +1807,9 @@ static void write_msg(String message, bool to_err, bool writeln)
/// @param[in] obj Object to return.
///
/// @return its argument.
-Object nvim__id(Object obj)
+Object nvim__id(Object obj, Arena *arena)
{
- return copy_object(obj, NULL);
+ return copy_object(obj, arena);
}
/// Returns array given as argument.
@@ -1819,9 +1820,9 @@ Object nvim__id(Object obj)
/// @param[in] arr Array to return.
///
/// @return its argument.
-Array nvim__id_array(Array arr)
+Array nvim__id_array(Array arr, Arena *arena)
{
- return copy_array(arr, NULL);
+ return copy_array(arr, arena);
}
/// Returns dictionary given as argument.
@@ -1832,9 +1833,9 @@ Array nvim__id_array(Array arr)
/// @param[in] dct Dictionary to return.
///
/// @return its argument.
-Dictionary nvim__id_dictionary(Dictionary dct)
+Dictionary nvim__id_dictionary(Dictionary dct, Arena *arena)
{
- return copy_dictionary(dct, NULL);
+ return copy_dictionary(dct, arena);
}
/// Returns floating-point value given as argument.
diff --git a/src/nvim/api/vimscript.c b/src/nvim/api/vimscript.c
index db32eac3d1..7239971c21 100644
--- a/src/nvim/api/vimscript.c
+++ b/src/nvim/api/vimscript.c
@@ -51,7 +51,7 @@
/// @return Dictionary containing information about execution, with these keys:
/// - output: (string|nil) Output if `opts.output` is true.
Dictionary nvim_exec2(uint64_t channel_id, String src, Dict(exec_opts) *opts, Error *err)
- FUNC_API_SINCE(11)
+ FUNC_API_SINCE(11) FUNC_API_RET_ALLOC
{
Dictionary result = ARRAY_DICT_INIT;