diff options
author | Junio C Hamano <gitster@pobox.com> | 2024-06-12 22:37:15 +0200 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2024-06-12 22:37:15 +0200 |
commit | 22cf18fd9ede79bdfe5ac93e09986a64052e5781 (patch) | |
tree | 8ab7f912a4b11df3c9397d4a7332510eb3594205 /strbuf.c | |
parent | Merge branch 'cp/reftable-unit-test' (diff) | |
parent | t/: migrate helper/test-{sha1, sha256} to unit-tests/t-hash (diff) | |
download | git-22cf18fd9ede79bdfe5ac93e09986a64052e5781.tar.xz git-22cf18fd9ede79bdfe5ac93e09986a64052e5781.zip |
Merge branch 'gt/t-hash-unit-test'
A pair of test helpers that essentially are unit tests on hash
algorithms have been rewritten using the unit-tests framework.
* gt/t-hash-unit-test:
t/: migrate helper/test-{sha1, sha256} to unit-tests/t-hash
strbuf: introduce strbuf_addstrings() to repeatedly add a string
Diffstat (limited to 'strbuf.c')
-rw-r--r-- | strbuf.c | 9 |
1 files changed, 9 insertions, 0 deletions
@@ -313,6 +313,15 @@ void strbuf_add(struct strbuf *sb, const void *data, size_t len) strbuf_setlen(sb, sb->len + len); } +void strbuf_addstrings(struct strbuf *sb, const char *s, size_t n) +{ + size_t len = strlen(s); + + strbuf_grow(sb, st_mult(len, n)); + for (size_t i = 0; i < n; i++) + strbuf_add(sb, s, len); +} + void strbuf_addbuf(struct strbuf *sb, const struct strbuf *sb2) { strbuf_grow(sb, sb2->len); |