Re: [PATCH v6 3/7] eoie: add End of Index Entry (EOIE) extension
- From
Duy Nguyen <pclouds@gmail.com>
- Date
- Sep 29, 2018, 05:45 UTC
- Message-ID
- <20180929054520.GA21901@duynguyen.home>
- In-Reply-To
- <20180926195442.1380-4-benpeart@microsoft.com>
On Wed, Sep 26, 2018 at 03:54:38PM -0400, Ben Peart wrote:
> + > +#define EOIE_SIZE (4 + GIT_SHA1_RAWSZ) /* <4-byte offset> + <20-byte hash> */ > +#define EOIE_SIZE_WITH_HEADER (4 + 4 + EOIE_SIZE) /* <4-byte signature> + <4-byte length> + EOIE_SIZE */
If you make these variables instead of macros, you can use the_hash_algo, which makes this code sha256-friendlier and probably can explain less, e.g. ...
Show 12 quoted lines
> +
> +static size_t read_eoie_extension(const char *mmap, size_t mmap_size)
> +{
> + /*
> + * The end of index entries (EOIE) extension is guaranteed to be last
> + * so that it can be found by scanning backwards from the EOF.
> + *
> + * "EOIE"
> + * <4-byte length>
> + * <4-byte offset>
> + * <20-byte hash>
> + */uint32_t EOIE_SIZE = 4 + the_hash_algo->rawsz; uint32_t EOIE_SIZE_WITH_HEADER = 4 + 4 + EOIE_SIZE;
Show 5 quoted lines
> + const char *index, *eoie; > + uint32_t extsize; > + size_t offset, src_offset; > + unsigned char hash[GIT_MAX_RAWSZ]; > + git_hash_ctx c;
-- Duy