Skip to content

Commit 29ee6d5

Browse files
Chandra Pratapgitster
authored andcommitted
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 <[email protected]> Mentored-by: Christian Couder <[email protected]> Signed-off-by: Chandra Pratap <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 31216ee commit 29ee6d5

File tree

1 file changed

+1
-4
lines changed

1 file changed

+1
-4
lines changed

t/unit-tests/t-reftable-block.c

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,7 @@ static void t_block_read_write(void)
4444
check_int(ret, ==, REFTABLE_API_ERROR);
4545

4646
for (i = 0; i < N; i++) {
47-
char name[100];
48-
snprintf(name, sizeof(name), "branch%02"PRIuMAX, (uintmax_t)i);
49-
50-
rec.u.ref.refname = xstrdup(name);
47+
rec.u.ref.refname = xstrfmt("branch%02"PRIuMAX, (uintmax_t)i);
5148
rec.u.ref.value_type = REFTABLE_REF_VAL1;
5249
memset(rec.u.ref.value.val1, i, GIT_SHA1_RAWSZ);
5350

0 commit comments

Comments
 (0)