get_str_line: Simplify growarray usage

This commit is contained in:
Fabian Viöl 2021-04-30 14:42:02 +02:00
parent ef8afa0eb7
commit 4d5516dc05

View File

@ -2723,15 +2723,9 @@ static char_u *get_str_line(int c, void *cookie, int indent, bool do_concat)
garray_T ga; garray_T ga;
ga_init(&ga, (int)sizeof(char_u), (int)line_length); ga_init(&ga, (int)sizeof(char_u), (int)line_length);
ga_concat_len(&ga, (char *)p->buf + p->offset, line_length); ga_concat_len(&ga, (char *)p->buf + p->offset, line_length);
if (ga.ga_len != (int)line_length) {
smsg(_(":source error parsing command %s"), p->buf);
return NULL;
}
ga_append(&ga, '\0'); ga_append(&ga, '\0');
p->offset = i + 1; p->offset = i + 1;
char_u *line = (char_u *)xstrdup(ga.ga_data); return ga.ga_data;
ga_clear(&ga);
return line;
} }
static int source_using_linegetter(void *cookie, static int source_using_linegetter(void *cookie,