diff options
author | Jeff King <peff@peff.net> | 2014-06-19 17:24:33 -0400 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2014-06-19 15:20:54 -0700 |
commit | 283101869bea8feb5d58f6ea1b568e9b197526d3 (patch) | |
tree | 3aba65688e4a5a11a3d0a60d2fa60930fd398898 /merge-recursive.c | |
parent | use xstrdup instead of xmalloc + strcpy (diff) | |
download | tgif-283101869bea8feb5d58f6ea1b568e9b197526d3.tar.xz |
use xstrfmt to replace xmalloc + sprintf
This is one line shorter, and makes sure the length in the
malloc and sprintf steps match.
These conversions are very straightforward; we can drop the
malloc entirely, and replace the sprintf with xstrfmt.
Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'merge-recursive.c')
-rw-r--r-- | merge-recursive.c | 12 |
1 files changed, 4 insertions, 8 deletions
diff --git a/merge-recursive.c b/merge-recursive.c index cab16fafb5..532a1da2b0 100644 --- a/merge-recursive.c +++ b/merge-recursive.c @@ -969,14 +969,10 @@ merge_file_special_markers(struct merge_options *o, char *side2 = NULL; struct merge_file_info mfi; - if (filename1) { - side1 = xmalloc(strlen(branch1) + strlen(filename1) + 2); - sprintf(side1, "%s:%s", branch1, filename1); - } - if (filename2) { - side2 = xmalloc(strlen(branch2) + strlen(filename2) + 2); - sprintf(side2, "%s:%s", branch2, filename2); - } + if (filename1) + side1 = xstrfmt("%s:%s", branch1, filename1); + if (filename2) + side2 = xstrfmt("%s:%s", branch2, filename2); mfi = merge_file_1(o, one, a, b, side1 ? side1 : branch1, side2 ? side2 : branch2); |