0
0
mirror of https://github.com/vim/vim.git synced 2025-09-27 04:14:06 -04:00

patch 8.2.4040: keeping track of allocated lines is too complicated

Problem:    Keeping track of allocated lines in user functions is too
            complicated.
Solution:   Instead of freeing individual lines keep them all until the end.
This commit is contained in:
Bram Moolenaar
2022-01-08 15:39:39 +00:00
parent 67ffb41786
commit 9f1a39a5d1
10 changed files with 82 additions and 47 deletions

View File

@@ -702,7 +702,7 @@ ga_init(garray_T *gap)
}
void
ga_init2(garray_T *gap, int itemsize, int growsize)
ga_init2(garray_T *gap, size_t itemsize, int growsize)
{
ga_init(gap);
gap->ga_itemsize = itemsize;
@@ -789,7 +789,7 @@ ga_concat_strings(garray_T *gap, char *sep)
* When out of memory nothing changes and FAIL is returned.
*/
int
ga_add_string(garray_T *gap, char_u *p)
ga_copy_string(garray_T *gap, char_u *p)
{
char_u *cp = vim_strsave(p);
@@ -805,6 +805,19 @@ ga_add_string(garray_T *gap, char_u *p)
return OK;
}
/*
* Add string "p" to "gap".
* When out of memory "p" is freed and FAIL is returned.
*/
int
ga_add_string(garray_T *gap, char_u *p)
{
if (ga_grow(gap, 1) == FAIL)
return FAIL;
((char_u **)(gap->ga_data))[gap->ga_len++] = p;
return OK;
}
/*
* Concatenate a string to a growarray which contains bytes.
* When "s" is NULL does not do anything.