aboutsummaryrefslogtreecommitdiffstats
path: root/t/unit-tests
diff options
context:
space:
mode:
authorChandra Pratap <chandrapratap3519@gmail.com>2024-08-21 18:00:57 +0530
committerJunio C Hamano <gitster@pobox.com>2024-08-21 09:41:41 -0700
commit29ee6d5a200e95df64d55a3e1fbbaa004f50c46c (patch)
treed43d6e7727d3c250d9ebc0d03176f0c40b8a874b /t/unit-tests
parent31216ee28a452d39d9fba6cd72d8b072eab50af1 (diff)
downloadgit-29ee6d5a200e95df64d55a3e1fbbaa004f50c46c.tar.gz
t-reftable-block: use xstrfmt() instead of xstrdup()
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>
Diffstat (limited to 't/unit-tests')
-rw-r--r--t/unit-tests/t-reftable-block.c5
1 files changed, 1 insertions, 4 deletions
diff --git a/t/unit-tests/t-reftable-block.c b/t/unit-tests/t-reftable-block.c
index ad3d128ea7..81484bc646 100644
--- a/t/unit-tests/t-reftable-block.c
+++ b/t/unit-tests/t-reftable-block.c
@@ -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);