mirror of
https://github.com/neovim/neovim.git
synced 2025-09-25 04:28:33 +00:00
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.
This commit is contained in:
@@ -5669,7 +5669,7 @@ static void read_file_or_blob(typval_T *argvars, typval_T *rettv, bool always_bl
|
||||
}
|
||||
if (prevlen == 0) {
|
||||
assert(len < INT_MAX);
|
||||
s = xstrnsave(start, len);
|
||||
s = xmemdupz(start, len);
|
||||
} else {
|
||||
// Change "prev" buffer to be the right size. This way
|
||||
// the bytes are only copied once, and very long lines are
|
||||
@@ -6305,7 +6305,7 @@ static void reduce_string(typval_T *argvars, typval_T *expr, typval_T *rettv)
|
||||
*rettv = (typval_T){
|
||||
.v_type = VAR_STRING,
|
||||
.v_lock = VAR_UNLOCKED,
|
||||
.vval.v_string = xstrnsave(p, (size_t)len),
|
||||
.vval.v_string = xmemdupz(p, (size_t)len),
|
||||
};
|
||||
p += len;
|
||||
} else if (tv_check_for_string_arg(argvars, 2) == FAIL) {
|
||||
@@ -6321,7 +6321,7 @@ static void reduce_string(typval_T *argvars, typval_T *expr, typval_T *rettv)
|
||||
argv[1] = (typval_T){
|
||||
.v_type = VAR_STRING,
|
||||
.v_lock = VAR_UNLOCKED,
|
||||
.vval.v_string = xstrnsave(p, (size_t)len),
|
||||
.vval.v_string = xmemdupz(p, (size_t)len),
|
||||
};
|
||||
|
||||
const int r = eval_expr_typval(expr, true, argv, 2, rettv);
|
||||
|
Reference in New Issue
Block a user