[PATCH 2/2] Use ALLOC_GROW in builtin/push.c
- From
Jared Hance <jaredhance@gmail.com>
- Date
- Jul 31, 2010, 12:57 UTC
- Message-ID
- <fbf6f49fa7c1d6b265d6cf6cfa772ec133550389.1280580026.git.jaredhance@gmail.com>
- In-Reply-To
- <cover.1280580026.git.jaredhance@gmail.com>
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 <jaredhance@gmail.com> --- 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