Skip to content

Commit

Permalink
Use handy ALLOC_GROW macro in fast-import when possible
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Shawn O. Pearce committed Aug 19, 2007
1 parent ea08a6f commit 3149007
Showing 1 changed file with 1 addition and 6 deletions.
7 changes: 1 addition & 6 deletions fast-import.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 3149007

Please sign in to comment.