Skip to content

Commit 9bef642

Browse files
committed
Merge branch 'jk/tighten-alloc' into maint
Small code and comment clean-up. * jk/tighten-alloc: receive-pack: use FLEX_ALLOC_MEM in queue_command() correct FLEXPTR_* example in comment
2 parents 5e469ab + ddd0bfa commit 9bef642

File tree

2 files changed

+2
-4
lines changed

2 files changed

+2
-4
lines changed

builtin/receive-pack.c

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

13761376
refname = line + 82;
13771377
reflen = linelen - 82;
1378-
cmd = xcalloc(1, st_add3(sizeof(struct command), reflen, 1));
1378+
FLEX_ALLOC_MEM(cmd, ref_name, refname, reflen);
13791379
hashcpy(cmd->old_sha1, old_sha1);
13801380
hashcpy(cmd->new_sha1, new_sha1);
1381-
memcpy(cmd->ref_name, refname, reflen);
1382-
cmd->ref_name[reflen] = '\0';
13831381
*tail = cmd;
13841382
return &cmd->next;
13851383
}

git-compat-util.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -802,7 +802,7 @@ extern FILE *fopen_for_writing(const char *path);
802802
* you can do:
803803
*
804804
* struct foo *f;
805-
* FLEX_ALLOC_STR(f, name, src);
805+
* FLEXPTR_ALLOC_STR(f, name, src);
806806
*
807807
* and "name" will point to a block of memory after the struct, which will be
808808
* freed along with the struct (but the pointer can be repointed anywhere).

0 commit comments

Comments
 (0)