Subject: [PATCH 2/2] pack-objects: use ALLOC_GROW

From: Jonathan Nieder <[email-masked]>
Date: Fri, 8 Oct 2010 11:47:40 -0500

Invoke ALLOC_GROW from cache.h instead of recaping its definition
verbatim.  When this code was first written, the ALLOC_GROW macro
didn't exist yet; now that the macro does exist, it can make the
source a little shorter and more readable.

No functional change intended.

Signed-off-by: Jonathan Nieder <[email-masked]>
---
 builtin/pack-objects.c |   15 ++++-----------
 1 files changed, 4 insertions(+), 11 deletions(-)

diff --git a/builtin/pack-objects.c b/builtin/pack-objects.c
index 3756cf3..60b792d 100644
--- a/builtin/pack-objects.c
+++ b/builtin/pack-objects.c
@@ -896,12 +896,9 @@ static int check_pbase_path(unsigned hash)
 	if (0 <= pos)
 		return 1;
 	pos = -pos - 1;
-	if (done_pbase_paths_alloc <= done_pbase_paths_num) {
-		done_pbase_paths_alloc = alloc_nr(done_pbase_paths_alloc);
-		done_pbase_paths = xrealloc(done_pbase_paths,
-					    done_pbase_paths_alloc *
-					    sizeof(unsigned));
-	}
+	ALLOC_GROW(done_pbase_paths,
+		   done_pbase_paths_num + 1,
+		   done_pbase_paths_alloc);
 	done_pbase_paths_num++;
 	if (pos < done_pbase_paths_num)
 		memmove(done_pbase_paths + pos + 1,
@@ -2248,11 +2245,7 @@ int cmd_pack_objects(int argc, const char **argv, const char *prefix)
 		    !strcmp("--reflog", arg) ||
 		    !strcmp("--all", arg)) {
 			use_internal_rev_list = 1;
-			if (rp_ac >= rp_ac_alloc - 1) {
-				rp_ac_alloc = alloc_nr(rp_ac_alloc);
-				rp_av = xrealloc(rp_av,
-						 rp_ac_alloc * sizeof(*rp_av));
-			}
+			ALLOC_GROW(rp_av, rp_ac + 2, rp_ac_alloc);
 			rp_av[rp_ac++] = arg;
 			continue;
 		}
-- 
1.7.2.3