Re: What's in git.git, and announcing GIT 1.4.2-rc4

From: Junio C Hamano <junkio@cox.net>
Date: 2006-08-10 17:59:26
Johannes Schindelin <Johannes.Schindelin@gmx.de> writes:

> While in this particular case, desc.alloc cannot be smaller than desc.size 
> (and therefore the condition in the if() is misleading), it might be 
> better to write "desc.alloc = desc.size + 1;" for others to understand...

We overallocate desc.alloc in apply_one_fragment for growth, so
that if() is needed, but after this part of the code we discard
the desc hence the increment is not needed ;-).

diff --git a/builtin-apply.c b/builtin-apply.c
index c159873..be2c715 100644
--- a/builtin-apply.c
+++ b/builtin-apply.c
@@ -1700,10 +1700,8 @@ static int apply_data(struct patch *patc
 		return -1;
 
 	/* NUL terminate the result */
-	if (desc.alloc <= desc.size) {
+	if (desc.alloc <= desc.size)
 		desc.buffer = xrealloc(desc.buffer, desc.size + 1);
-		desc.alloc++;
-	}
 	desc.buffer[desc.size] = 0;
 
 	patch->result = desc.buffer;


-
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Received on Thu Aug 10 18:00:09 2006

This archive was generated by hypermail 2.1.8 : 2006-08-10 18:01:11 EST