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 <l.s.r@web.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
René Scharfe committed
Aug 13, 2016 at 17:38 UTC
ddd0bfac7cfaabc7c0422ecee9604ede9c4841d1
1 file changed
+1
-3
builtin/receive-pack.c
+1
-3
@@ -1372,11 +1372,9 @@ static struct command **queue_command(struct command **tail,
1372
1373
refname = line + 82;
1374
reflen = linelen - 82;
1375
- cmd = xcalloc(1, st_add3(sizeof(struct command), reflen, 1));
1375
+ FLEX_ALLOC_MEM(cmd, ref_name, refname, reflen);
1376
hashcpy(cmd->old_sha1, old_sha1);
1377
hashcpy(cmd->new_sha1, new_sha1);
1378
- memcpy(cmd->ref_name, refname, reflen);
1379
- cmd->ref_name[reflen] = '\0';
1378
*tail = cmd;
1379
return &cmd->next;
1380
}