aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/api
diff options
context:
space:
mode:
authorzeertzjq <zeertzjq@outlook.com>2023-11-10 08:39:21 +0800
committerGitHub <noreply@github.com>2023-11-10 08:39:21 +0800
commitcd63a9addd6e1114c3524fa041ece560550cfe7b (patch)
tree846797f471b5de4c230838620ceaeda860de9e17 /src/nvim/api
parentae8ca79920a8d0e928ac1502a10d1d063a06cae5 (diff)
downloadrneovim-cd63a9addd6e1114c3524fa041ece560550cfe7b.tar.gz
rneovim-cd63a9addd6e1114c3524fa041ece560550cfe7b.tar.bz2
rneovim-cd63a9addd6e1114c3524fa041ece560550cfe7b.zip
refactor: change some xstrndup() and xstrnsave() to xmemdupz() (#25959)
When the given length is exactly the number of bytes to copy, xmemdupz() makes the intention clearer.
Diffstat (limited to 'src/nvim/api')
-rw-r--r--src/nvim/api/command.c2
-rw-r--r--src/nvim/api/private/helpers.h2
2 files changed, 1 insertions, 3 deletions
diff --git a/src/nvim/api/command.c b/src/nvim/api/command.c
index f4c6f646eb..9d51f2a4dc 100644
--- a/src/nvim/api/command.c
+++ b/src/nvim/api/command.c
@@ -419,7 +419,7 @@ String nvim_cmd(uint64_t channel_id, Dict(cmd) *cmd, Dict(cmd_opts) *opts, Error
VALIDATE_EXP(!string_iswhite(elem.data.string), "command arg", "non-whitespace", NULL, {
goto end;
});
- data_str = xstrndup(elem.data.string.data, elem.data.string.size);
+ data_str = string_to_cstr(elem.data.string);
break;
default:
VALIDATE_EXP(false, "command arg", "valid type", api_typename(elem.type), {
diff --git a/src/nvim/api/private/helpers.h b/src/nvim/api/private/helpers.h
index 9cf4620acd..8911e145e7 100644
--- a/src/nvim/api/private/helpers.h
+++ b/src/nvim/api/private/helpers.h
@@ -75,8 +75,6 @@
#define PUT_C(dict, k, v) \
kv_push_c(dict, ((KeyValuePair) { .key = cstr_as_string(k), .value = v }))
-#define PUT_BOOL(dict, name, condition) PUT(dict, name, BOOLEAN_OBJ(condition));
-
#define ADD(array, item) \
kv_push(array, item)