Files
git/strvec.c
Taylor Blau cd45bf0f3e strvec: introduce strvec_init_alloc()
When the caller knows upfront how many elements will be pushed onto a
`strvec`, it is useful to pre-allocate enough space in the array to fit
that many elements (and one additional slot to store NULL, indicating
the end of the list.)

Introduce `strvec_init_alloc()`, which allocates the backing array large
enough to hold `alloc` elements and the termination marker without
further reallocation. Reimplement `strvec_init()` as a special case of
`strvec_init_alloc()`, namely when `alloc` is zero.

Helped-by: Junio C Hamano <gitster@pobox.com>
Signed-off-by: Taylor Blau <me@ttaylorr.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2026-03-29 19:13:12 -07:00

3.5 KiB