diff options
| author | Patrick Steinhardt <ps@pks.im> | 2024-11-20 14:39:38 +0100 |
|---|---|---|
| committer | Junio C Hamano <gitster@pobox.com> | 2024-11-21 08:23:42 +0900 |
| commit | 3f5fadef3718f0ada963aeb25be70c8ba71b5c7c (patch) | |
| tree | 07f9f131ae73d94429cd0ddf6024ce0a39f1e645 /strvec.h | |
| parent | 141766d1bb801ae2a9c7358920ce8dc9697f53c4 (diff) | |
| download | git-3f5fadef3718f0ada963aeb25be70c8ba71b5c7c.tar.gz | |
strvec: introduce new `strvec_splice()` function
Introduce a new `strvec_splice()` function that can replace a range of
strings in the vector with another array of strings. This function will
be used in subsequent commits.
Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'strvec.h')
| -rw-r--r-- | strvec.h | 9 |
1 files changed, 9 insertions, 0 deletions
@@ -67,6 +67,15 @@ void strvec_pushl(struct strvec *, ...); /* Push a null-terminated array of strings onto the end of the array. */ void strvec_pushv(struct strvec *, const char **); +/* + * Replace `len` values starting at `idx` with the provided replacement + * strings. If `len` is zero this is effectively an insert at the given `idx`. + * If `replacement_len` is zero this is effectively a delete of `len` items + * starting at `idx`. + */ +void strvec_splice(struct strvec *array, size_t idx, size_t len, + const char **replacement, size_t replacement_len); + /** * Replace the value at the given index with a new value. The index must be * valid. Returns a pointer to the inserted value. |
