• J
    alternates: store scratch buffer as strbuf · 38dbe5f0
    Jeff King 提交于
    We pre-size the scratch buffer to hold a loose object
    filename of the form "xx/yyyy...", which leads to allocation
    code that is hard to verify. We have to use some magic
    numbers during the initial allocation, and then writers must
    blindly assume that the buffer is big enough. Using a strbuf
    makes it more clear that we cannot overflow.
    
    Unfortunately, we do still need some magic numbers to grow
    our strbuf before calling fill_sha1_path(), but the strbuf
    growth is much closer to the point of use. This makes it
    easier to see that it's correct, and opens the possibility
    of pushing it even further down if fill_sha1_path() learns
    to work on strbufs.
    Signed-off-by: NJeff King <peff@peff.net>
    Signed-off-by: NJunio C Hamano <gitster@pobox.com>
    38dbe5f0
cache.h 68.9 KB