Re: [PATCH 4/6] delta, packfile: use size_t for delta header sizes
- From
Derrick Stolee <stolee@gmail.com>
- Date
- Apr 29, 2026, 13:28 UTC
- Message-ID
- <1b2ce8fe-7c99-4dde-ae07-1443d03cf523@gmail.com>
- In-Reply-To
- <3274cba862ae42a6813710410274a692ec0f5d29.1777393580.git.gitgitgadget@gmail.com>
On 4/28/26 12:26 PM, Johannes Schindelin via GitGitGadget wrote:
Show 7 quoted lines
> From: Johannes Schindelin <johannes.schindelin@gmx.de> > > The delta header decoding functions return unsigned long, which > truncates on Windows for objects larger than 4GB. Introduce size_t > variants get_delta_hdr_size_sz() and get_size_from_delta_sz() that > preserve the full 64-bit size, and use them in packed_object_info() > where the size is needed for streaming decisions.
> + * Size_t variant that doesn't truncate - use for >4GB objects on Windows. > + */ > +static inline size_t get_delta_hdr_size_sz(const unsigned char **datap, > + const unsigned char *top)
...
Show 6 quoted lines
> +static inline unsigned long get_delta_hdr_size(const unsigned char **datap,
> + const unsigned char *top)
> +{
> + size_t size = get_delta_hdr_size_sz(datap, top);
> return cast_size_t_to_ulong(size);
> }I like this trick to use the 64-bit implementation and only to down-cast for API compatibility. This allows a more gradual transition than if we replaced ulongs with size_ts everywhere at once.
Thanks, -Stolee