summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 61bf126)
raw | patch | inline | side by side (parent: 61bf126)
author | Jared Hance <jaredhance@gmail.com> | |
Sat, 31 Jul 2010 12:54:55 +0000 (08:54 -0400) | ||
committer | Junio C Hamano <gitster@pobox.com> | |
Mon, 2 Aug 2010 18:53:18 +0000 (11:53 -0700) |
Creating a variable nr here to use throughout the function only to change
refspec_nr to nr at the end, having not used refspec_nr the entire time,
is rather pointless. Instead, simply increment refspec_nr.
While at it, use ALLOC_GROW() instead of xrealloc().
Signed-off-by: Jared Hance <jaredhance@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
refspec_nr to nr at the end, having not used refspec_nr the entire time,
is rather pointless. Instead, simply increment refspec_nr.
While at it, use ALLOC_GROW() instead of xrealloc().
Signed-off-by: Jared Hance <jaredhance@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin/push.c | patch | blob | history |
diff --git a/builtin/push.c b/builtin/push.c
index f4358b9d230f6d8d7a9a67fdfbc60279c5ec71ee..a2cc9fdea1b22739681c26ee3723058c91018d81 100644 (file)
--- a/builtin/push.c
+++ b/builtin/push.c
static const char **refspec;
static int refspec_nr;
+static int refspec_alloc;
static void add_refspec(const char *ref)
{
- int nr = refspec_nr + 1;
- refspec = xrealloc(refspec, nr * sizeof(char *));
- refspec[nr-1] = ref;
- refspec_nr = nr;
+ refspec_nr++;
+ ALLOC_GROW(refspec, refspec_nr, refspec_alloc);
+ refspec[refspec_nr-1] = ref;
}
static void set_refspecs(const char **refs, int nr)