{"thread":{"id":"43805","subject":"[PATCH] receive-pack: use FLEX_ALLOC_MEM in queue_command()","startedAt":"2016-08-13T15:39:14Z","lastAt":"2016-08-14T10:34:40Z","messageCount":2,"participants":["René Scharfe","Jeff King"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"298973","messageId":"57AF3F10.3050508@web.de","threadId":"43805","inReplyTo":null,"subject":"[PATCH] receive-pack: use FLEX_ALLOC_MEM in queue_command()","fromName":"René Scharfe","fromEmail":"l.s.r@web.de","sentAt":"2016-08-13T15:38:56Z","receivedAt":"2016-08-13T15:39:14Z","isPatch":true,"sender":{"key":"l.s.r@web.de","avatar":"https://avatars.githubusercontent.com/u/26122331?v=4"},"body":"Use the macro FLEX_ALLOC_MEM instead of open-coding it.  This shortens\nand simplifies the code a bit.\n\nSigned-off-by: Rene Scharfe <l.s.r@web.de>\n---\n builtin/receive-pack.c | 4 +---\n 1 file changed, 1 insertion(+), 3 deletions(-)\n\ndiff --git a/builtin/receive-pack.c b/builtin/receive-pack.c\nindex 92e1213..011db00 100644\n--- a/builtin/receive-pack.c\n+++ b/builtin/receive-pack.c\n@@ -1478,11 +1478,9 @@ static struct command **queue_command(struct command **tail,\n \n \trefname = line + 82;\n \treflen = linelen - 82;\n-\tcmd = xcalloc(1, st_add3(sizeof(struct command), reflen, 1));\n+\tFLEX_ALLOC_MEM(cmd, ref_name, refname, reflen);\n \thashcpy(cmd->old_sha1, old_sha1);\n \thashcpy(cmd->new_sha1, new_sha1);\n-\tmemcpy(cmd->ref_name, refname, reflen);\n-\tcmd->ref_name[reflen] = '\\0';\n \t*tail = cmd;\n \treturn &cmd->next;\n }\n-- \n2.9.3\n\n"},{"id":"299264","messageId":"20160813183429.lhgl3qfx7gf4duvj@sigill.intra.peff.net","threadId":"43805","inReplyTo":"57AF3F10.3050508@web.de","subject":"Re: [PATCH] receive-pack: use FLEX_ALLOC_MEM in queue_command()","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2016-08-13T18:34:29Z","receivedAt":"2016-08-14T10:34:40Z","isPatch":true,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Sat, Aug 13, 2016 at 05:38:56PM +0200, René Scharfe wrote:\n\n> Use the macro FLEX_ALLOC_MEM instead of open-coding it.  This shortens\n> and simplifies the code a bit.\n\nThanks, looks good (I obviously missed a few opportunities for\nconversion during the initial introduction of FLEX_ALLOC simply by not\nnoticing; I don't think there is any more reason that this one was not\nconverted).\n\n-Peff\n"}]}