From: Jared Hance Date: Sat, 31 Jul 2010 12:57:36 GMT Subject: [PATCH 2/2] Use ALLOC_GROW in builtin/push.c Message-ID: In-Reply-To: The current implementation of add_refspec(const char *ref) duplicates functionality found in the xalloc api. Use ALLOC_GROW instead to prevent code duplication. Signed-off-by: Jared Hance --- builtin/push.c | 3 ++- 1 files changed, 2 insertions(+), 1 deletions(-) diff --git a/builtin/push.c b/builtin/push.c index 79d8192..0da0ec8 100644 --- a/builtin/push.c +++ b/builtin/push.c @@ -22,11 +22,12 @@ static int progress; static const char **refspec; static int refspec_nr; +static size_t refspec_alloc; static void add_refspec(const char *ref) { refspec_nr++; - refspec = xrealloc(refspec, refspec_nr * sizeof(char *)); + ALLOC_GROW(refspec, refspec_nr, refspec_alloc); refspec[refspec_nr-1] = ref; } -- 1.7.2