From 0bb1519f05aed047a969b9fe0bfa80e6ef804c7f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9=20Scharfe?= Date: Sat, 13 Aug 2016 11:01:21 +0200 Subject: correct FLEXPTR_* example in comment This section is about "The FLEXPTR_* variants", so use FLEXPTR_ALLOC_STR in the example. Signed-off-by: Rene Scharfe Signed-off-by: Junio C Hamano --- git-compat-util.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/git-compat-util.h b/git-compat-util.h index 1459f9b87..17918d028 100644 --- a/git-compat-util.h +++ b/git-compat-util.h @@ -803,7 +803,7 @@ extern FILE *fopen_for_writing(const char *path); * you can do: * * struct foo *f; - * FLEX_ALLOC_STR(f, name, src); + * FLEXPTR_ALLOC_STR(f, name, src); * * and "name" will point to a block of memory after the struct, which will be * freed along with the struct (but the pointer can be repointed anywhere). -- cgit v1.2.1 From ddd0bfac7cfaabc7c0422ecee9604ede9c4841d1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9=20Scharfe?= Date: Sat, 13 Aug 2016 17:38:56 +0200 Subject: 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 Signed-off-by: Junio C Hamano --- builtin/receive-pack.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/builtin/receive-pack.c b/builtin/receive-pack.c index c8e32b297..b55d0aaee 100644 --- a/builtin/receive-pack.c +++ b/builtin/receive-pack.c @@ -1372,11 +1372,9 @@ static struct command **queue_command(struct command **tail, refname = line + 82; reflen = linelen - 82; - cmd = xcalloc(1, st_add3(sizeof(struct command), reflen, 1)); + FLEX_ALLOC_MEM(cmd, ref_name, refname, reflen); hashcpy(cmd->old_sha1, old_sha1); hashcpy(cmd->new_sha1, new_sha1); - memcpy(cmd->ref_name, refname, reflen); - cmd->ref_name[reflen] = '\0'; *tail = cmd; return &cmd->next; } -- cgit v1.2.1