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>
This commit is contained in:
parent
ea08a6fd19
commit
3149007475
@ -1487,12 +1487,7 @@ static void *cmd_data (size_t *size)
|
|||||||
if (term_len == command_buf.len
|
if (term_len == command_buf.len
|
||||||
&& !strcmp(term, command_buf.buf))
|
&& !strcmp(term, command_buf.buf))
|
||||||
break;
|
break;
|
||||||
if (sz < (length + command_buf.len)) {
|
ALLOC_GROW(buffer, length + command_buf.len, sz);
|
||||||
sz = sz * 3 / 2 + 16;
|
|
||||||
if (sz < (length + command_buf.len))
|
|
||||||
sz = length + command_buf.len;
|
|
||||||
buffer = xrealloc(buffer, sz);
|
|
||||||
}
|
|
||||||
memcpy(buffer + length,
|
memcpy(buffer + length,
|
||||||
command_buf.buf,
|
command_buf.buf,
|
||||||
command_buf.len - 1);
|
command_buf.len - 1);
|
||||||
|
Loading…
Reference in New Issue
Block a user