aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/eval/typval.c
diff options
context:
space:
mode:
authorzeertzjq <zeertzjq@outlook.com>2023-02-28 15:45:56 +0800
committerGitHub <noreply@github.com>2023-02-28 15:45:56 +0800
commit8acb3d742ce68adadf1def9e1d1bb5bfd671988c (patch)
tree76c130f2443612e2b5ebd0eafda8f74818205fc8 /src/nvim/eval/typval.c
parentbefb47f2e11a3f1035e6825b6f9fa7574c37ed0e (diff)
parent761a559dbfed99e588d7f306c89331907b2d5a92 (diff)
downloadrneovim-8acb3d742ce68adadf1def9e1d1bb5bfd671988c.tar.gz
rneovim-8acb3d742ce68adadf1def9e1d1bb5bfd671988c.tar.bz2
rneovim-8acb3d742ce68adadf1def9e1d1bb5bfd671988c.zip
Merge pull request #22447 from zeertzjq/vim-8.2.2777
vim-patch:8.2.{1890,2777}
Diffstat (limited to 'src/nvim/eval/typval.c')
-rw-r--r--src/nvim/eval/typval.c17
1 files changed, 17 insertions, 0 deletions
diff --git a/src/nvim/eval/typval.c b/src/nvim/eval/typval.c
index 7e94e03823..d56efe30da 100644
--- a/src/nvim/eval/typval.c
+++ b/src/nvim/eval/typval.c
@@ -2750,6 +2750,23 @@ int tv_blob_set_range(blob_T *dest, long n1, long n2, typval_T *src)
return OK;
}
+/// Store one byte "byte" in blob "blob" at "idx".
+/// Append one byte if needed.
+void tv_blob_set_append(blob_T *blob, int idx, uint8_t byte)
+{
+ garray_T *gap = &blob->bv_ga;
+
+ // Allow for appending a byte. Setting a byte beyond
+ // the end is an error otherwise.
+ if (idx <= gap->ga_len) {
+ if (idx == gap->ga_len) {
+ ga_grow(gap, 1);
+ gap->ga_len++;
+ }
+ tv_blob_set(blob, idx, byte);
+ }
+}
+
/// "remove({blob})" function
void tv_blob_remove(typval_T *argvars, typval_T *rettv, const char *arg_errmsg)
{