]> git.ipfire.org Git - thirdparty/git.git/commitdiff
t-reftable-block: use xstrfmt() instead of xstrdup()
authorChandra Pratap <chandrapratap3519@gmail.com>
Wed, 21 Aug 2024 12:30:57 +0000 (18:00 +0530)
committerJunio C Hamano <gitster@pobox.com>
Wed, 21 Aug 2024 16:41:41 +0000 (09:41 -0700)
Use xstrfmt() to assign a formatted string to a ref record's
refname instead of xstrdup(). This helps save the overhead of
a local 'char' buffer as well as makes the test more compact.

Mentored-by: Patrick Steinhardt <ps@pks.im>
Mentored-by: Christian Couder <chriscool@tuxfamily.org>
Signed-off-by: Chandra Pratap <chandrapratap3519@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
t/unit-tests/t-reftable-block.c

index ad3d128ea72086bb6aa8823db7bbf50545d655d3..81484bc646b3763570eb52ce83306873a004bd22 100644 (file)
@@ -44,10 +44,7 @@ static void t_block_read_write(void)
        check_int(ret, ==, REFTABLE_API_ERROR);
 
        for (i = 0; i < N; i++) {
-               char name[100];
-               snprintf(name, sizeof(name), "branch%02"PRIuMAX, (uintmax_t)i);
-
-               rec.u.ref.refname = xstrdup(name);
+               rec.u.ref.refname = xstrfmt("branch%02"PRIuMAX, (uintmax_t)i);
                rec.u.ref.value_type = REFTABLE_REF_VAL1;
                memset(rec.u.ref.value.val1, i, GIT_SHA1_RAWSZ);