summaryrefslogtreecommitdiff
path: root/builtin
diff options
context:
space:
mode:
authorJeff King <peff@peff.net>2014-06-19 21:19:43 (GMT)
committerJunio C Hamano <gitster@pobox.com>2014-06-19 22:20:53 (GMT)
commit95244ae3dd49b3eed4dbfe09299b9d8847622218 (patch)
treeb70932b2e4e8205c2f6f6b0cfcb88ca172c2d9d9 /builtin
parentfa3f60b783b42e0d07c667a8f582c3df12791cec (diff)
downloadgit-95244ae3dd49b3eed4dbfe09299b9d8847622218.zip
git-95244ae3dd49b3eed4dbfe09299b9d8847622218.tar.gz
git-95244ae3dd49b3eed4dbfe09299b9d8847622218.tar.bz2
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>
Diffstat (limited to 'builtin')
-rw-r--r--builtin/receive-pack.c5
1 files changed, 1 insertions, 4 deletions
diff --git a/builtin/receive-pack.c b/builtin/receive-pack.c
index c323081..18458e8 100644
--- a/builtin/receive-pack.c
+++ b/builtin/receive-pack.c
@@ -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;