Skip to content

Commit ddd0bfa

Browse files
rscharfegitster
authored andcommitted
receive-pack: use FLEX_ALLOC_MEM in queue_command()
Use the macro FLEX_ALLOC_MEM instead of open-coding it. This shortens and simplifies the code a bit. Signed-off-by: Rene Scharfe <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 0bb1519 commit ddd0bfa

File tree

1 file changed

+1
-3
lines changed

1 file changed

+1
-3
lines changed

builtin/receive-pack.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1372,11 +1372,9 @@ static struct command **queue_command(struct command **tail,
13721372

13731373
refname = line + 82;
13741374
reflen = linelen - 82;
1375-
cmd = xcalloc(1, st_add3(sizeof(struct command), reflen, 1));
1375+
FLEX_ALLOC_MEM(cmd, ref_name, refname, reflen);
13761376
hashcpy(cmd->old_sha1, old_sha1);
13771377
hashcpy(cmd->new_sha1, new_sha1);
1378-
memcpy(cmd->ref_name, refname, reflen);
1379-
cmd->ref_name[reflen] = '\0';
13801378
*tail = cmd;
13811379
return &cmd->next;
13821380
}

0 commit comments

Comments
 (0)