Use handy ALLOC_GROW macro in fast-import when possible
authorShawn O. Pearce <spearce@spearce.org>
Wed, 1 Aug 2007 04:32:36 +0000 (00:32 -0400)
committerShawn O. Pearce <spearce@spearce.org>
Sun, 19 Aug 2007 07:38:34 +0000 (03:38 -0400)
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>
fast-import.c

index 7e136a616e7a50018f4101f72d84beb376df43a0..d7fa2b7baaf19f9db46d268ac8954bf9623c76b1 100644 (file)
@@ -1487,12 +1487,7 @@ static void *cmd_data (size_t *size)
                        if (term_len == command_buf.len
                                && !strcmp(term, command_buf.buf))
                                break;
-                       if (sz < (length + command_buf.len)) {
-                               sz = sz * 3 / 2 + 16;
-                               if (sz < (length + command_buf.len))
-                                       sz = length + command_buf.len;
-                               buffer = xrealloc(buffer, sz);
-                       }
+                       ALLOC_GROW(buffer, length + command_buf.len, sz);
                        memcpy(buffer + length,
                                command_buf.buf,
                                command_buf.len - 1);