diff options
author | zeertzjq <zeertzjq@outlook.com> | 2023-11-10 08:39:21 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-11-10 08:39:21 +0800 |
commit | cd63a9addd6e1114c3524fa041ece560550cfe7b (patch) | |
tree | 846797f471b5de4c230838620ceaeda860de9e17 /src/nvim/autocmd.c | |
parent | ae8ca79920a8d0e928ac1502a10d1d063a06cae5 (diff) | |
download | rneovim-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/autocmd.c')
-rw-r--r-- | src/nvim/autocmd.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/src/nvim/autocmd.c b/src/nvim/autocmd.c index bdb3983ab3..1a83dd30c0 100644 --- a/src/nvim/autocmd.c +++ b/src/nvim/autocmd.c @@ -1031,7 +1031,7 @@ int autocmd_register(int64_t id, event_T event, const char *pat, int patlen, int } ap->refcount = 0; - ap->pat = xstrnsave(pat, (size_t)patlen); + ap->pat = xmemdupz(pat, (size_t)patlen); ap->patlen = patlen; // need to initialize last_mode for the first ModeChanged autocmd @@ -2514,7 +2514,7 @@ static int arg_augroup_get(char **argp) return AUGROUP_ALL; } - char *group_name = xstrnsave(arg, (size_t)(p - arg)); + char *group_name = xmemdupz(arg, (size_t)(p - arg)); int group = augroup_find(group_name); if (group == AUGROUP_ERROR) { group = AUGROUP_ALL; // no match, use all groups |