Use handy ALLOC_GROW macro in fast-import when possible
Instead of growing our buffer by hand during the inline variant of cmd_data() we can save a few lines of code and just use the nifty new ALLOC_GROW macro already available to us. Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
Shawn O. Pearce committed
Aug 1, 2007 at 00:32 UTC
3149007475f8c38ee66b448af9c55fc102534c46
1 file changed
+1
-6
fast-import.c
+1
-6
@@ -1487,12 +1487,7 @@ static void *cmd_data (size_t *size)
1487
if (term_len == command_buf.len
1488
&& !strcmp(term, command_buf.buf))
1489
break;
1490
- if (sz < (length + command_buf.len)) {
1491
- sz = sz * 3 / 2 + 16;
1492
- if (sz < (length + command_buf.len))
1493
- sz = length + command_buf.len;
1494
- buffer = xrealloc(buffer, sz);
1495
- }
1490
+ ALLOC_GROW(buffer, length + command_buf.len, sz);
1491
memcpy(buffer + length,
1492
command_buf.buf,
1493
command_buf.len - 1);