use xstrdup instead of xmalloc + strcpy
This is one line shorter, and makes sure the length in the malloc and copy steps match. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:

committed by
Junio C Hamano

parent
fa3f60b783
commit
95244ae3dd
@ -614,12 +614,9 @@ static void run_update_post_hook(struct command *commands)
|
||||
argv[0] = hook;
|
||||
|
||||
for (argc = 1, cmd = commands; cmd; cmd = cmd->next) {
|
||||
char *p;
|
||||
if (cmd->error_string || cmd->did_not_exist)
|
||||
continue;
|
||||
p = xmalloc(strlen(cmd->ref_name) + 1);
|
||||
strcpy(p, cmd->ref_name);
|
||||
argv[argc] = p;
|
||||
argv[argc] = xstrdup(cmd->ref_name);
|
||||
argc++;
|
||||
}
|
||||
argv[argc] = NULL;
|
||||
|
Reference in New Issue
Block a user