OSDN Git Service

fast-import: simplify allocation in start_packfile
authorJeff King <peff@peff.net>
Mon, 22 Feb 2016 22:44:46 +0000 (17:44 -0500)
committerJunio C Hamano <gitster@pobox.com>
Mon, 22 Feb 2016 22:51:09 +0000 (14:51 -0800)
commita78c188a32dd2ce02db2b966a70bffec52c98d20
tree420a86e890f7d3850693b3859aca3b8133026da3
parente0b837351084c3cb52c5acaf8a505835e631744a
fast-import: simplify allocation in start_packfile

This function allocate a packed_git flex-array, and adds a
mysterious 2 bytes to the length of the pack_name field. One
is for the trailing NUL, but the other has no purpose. This
is probably cargo-culted from add_packed_git, which gets the
".idx" path and needed to allocate enough space to hold the
matching ".pack" (though since 48bcc1c, we calculate the
size there differently).

This site, however, is using the raw path of a tempfile, and
does not need the extra byte. We can just replace the
allocation with FLEX_ALLOC_STR, which handles the allocation
and the NUL for us.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
fast-import.c