git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] annotate: use argv_array
@ 2014-07-16  8:51 René Scharfe
  0 siblings, 0 replies; only message in thread
From: René Scharfe @ 2014-07-16  8:51 UTC (permalink / raw)
  To: Git Mailing List; +Cc: Junio C Hamano

Simplify the code and get rid of some magic constants by using
argv_array to build the argument list for cmd_blame.  Be lazy and let
the OS release our allocated memory, as before.

Signed-off-by: Rene Scharfe <l.s.r@web.de>
---
 builtin/annotate.c | 12 +++++-------
 1 file changed, 5 insertions(+), 7 deletions(-)

diff --git a/builtin/annotate.c b/builtin/annotate.c
index fc43eed..da413ae 100644
--- a/builtin/annotate.c
+++ b/builtin/annotate.c
@@ -5,20 +5,18 @@
  */
 #include "git-compat-util.h"
 #include "builtin.h"
+#include "argv-array.h"
 
 int cmd_annotate(int argc, const char **argv, const char *prefix)
 {
-	const char **nargv;
+	struct argv_array args = ARGV_ARRAY_INIT;
 	int i;
-	nargv = xmalloc(sizeof(char *) * (argc + 2));
 
-	nargv[0] = "annotate";
-	nargv[1] = "-c";
+	argv_array_pushl(&args, "annotate", "-c", NULL);
 
 	for (i = 1; i < argc; i++) {
-		nargv[i+1] = argv[i];
+		argv_array_push(&args, argv[i]);
 	}
-	nargv[argc + 1] = NULL;
 
-	return cmd_blame(argc + 1, nargv, prefix);
+	return cmd_blame(args.argc, args.argv, prefix);
 }
-- 
2.0.0

^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2014-07-16  8:51 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-07-16  8:51 [PATCH] annotate: use argv_array René Scharfe

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 NNTP newsgroup(s).