6 void vec_add1(struct vec_basestruct
*ctl
,size_t sz
)
10 if (SIZE_MAX
/ 8 < sz
)
12 ctl
->buf
= malloc(ctl
->alen
* sz
);
15 } else if (ctl
->len
>= ctl
->alen
) {
17 if (SIZE_MAX
/ ctl
->alen
< sz
)
19 ctl
->buf
= realloc(ctl
->buf
,ctl
->alen
* sz
);
26 void vec_addn(struct vec_basestruct
*ctl
,size_t sz
,size_t n
)
29 if (SIZE_MAX
/ 8 >= sz
)
34 size_t nlen
= ctl
->alen
;
36 while (ctl
->len
> nlen
)
38 if (nlen
> ctl
->alen
) {
40 if (SIZE_MAX
/ nlen
< sz
)
42 ctl
->buf
= realloc(ctl
->buf
,nlen
* sz
);
45 } else if (!ctl
->buf
) {
46 ctl
->buf
= malloc(ctl
->alen
* sz
);