git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: "René Scharfe" <l.s.r@web.de>
To: Git List <git@vger.kernel.org>
Cc: Junio C Hamano <gitster@pobox.com>
Subject: [PATCH 2/2] run-command: use ALLOC_ARRAY
Date: Sun, 1 Oct 2017 17:14:31 +0200	[thread overview]
Message-ID: <6343155c-0986-06b0-8ced-146b23b8a137@web.de> (raw)
In-Reply-To: <c4abb7ac-dafd-57f2-8b46-45d610d656c4@web.de>

Use the macro ALLOC_ARRAY to allocate an array.  This is shorter and
eaasier, as it automatically infers the size of elements.

Patch generated with Coccinelle and contrib/coccinelle/array.cocci.

Signeg-off-by: Rene Scharfe <l.s.r@web.de>
---
 run-command.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/run-command.c b/run-command.c
index b5e6eb37c0..014b2165b5 100644
--- a/run-command.c
+++ b/run-command.c
@@ -452,7 +452,7 @@ static char **prep_childenv(const char *const *deltaenv)
 	}
 
 	/* Create an array of 'char *' to be used as the childenv */
-	childenv = xmalloc((env.nr + 1) * sizeof(char *));
+	ALLOC_ARRAY(childenv, env.nr + 1);
 	for (i = 0; i < env.nr; i++)
 		childenv[i] = env.items[i].util;
 	childenv[env.nr] = NULL;
-- 
2.14.2

  reply	other threads:[~2017-10-01 15:14 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-10-01 15:12 [PATCH 1/2] coccinelle: remove parentheses that become unnecessary René Scharfe
2017-10-01 15:14 ` René Scharfe [this message]
2017-10-02 19:20   ` [PATCH 2/2] run-command: use ALLOC_ARRAY Stefan Beller

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: http://vger.kernel.org/majordomo-info.html

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=6343155c-0986-06b0-8ced-146b23b8a137@web.de \
    --to=l.s.r@web.de \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).