Introduce ga_append_via_ptr() and GA_APPEND_VIA_PTR()

Similar to GA_APPEND(). Replaces this pattern:

    ga_grow(&ga, 1);
    item_type *p = ((item_type *)ga.ga_data) + ga.ga_len;
    p->field1 = v1;
    p->field2 = v2;
    ga.ga_len++;
This commit is contained in:
Felipe Oliveira Carvalho
2014-06-11 03:01:46 -03:00
committed by Justin M. Keyes
parent 45e7814e6a
commit 5ed74cfb7c
8 changed files with 82 additions and 111 deletions

View File

@@ -1037,10 +1037,9 @@ static char_u *get_loop_line(int c, void *cookie, int indent)
*/
static void store_loop_line(garray_T *gap, char_u *line)
{
ga_grow(gap, 1);
((wcmd_T *)(gap->ga_data))[gap->ga_len].line = vim_strsave(line);
((wcmd_T *)(gap->ga_data))[gap->ga_len].lnum = sourcing_lnum;
++gap->ga_len;
wcmd_T *p = GA_APPEND_VIA_PTR(wcmd_T, gap);
p->line = vim_strsave(line);
p->lnum = sourcing_lnum;
}
/*