Re: [PATCH 4/6] delta, packfile: use size_t for delta header sizes
- From
Johannes Schindelin <johannes.schindelin@gmx.de>
- Date
- May 3, 2026, 14:49 UTC
- Message-ID
- <d40c5d8a-9f03-43fd-f6bf-0b7516d21804@gmx.de>
- In-Reply-To
- <1b2ce8fe-7c99-4dde-ae07-1443d03cf523@gmail.com>
Hi Stolee,
On Sun, 3 May 2026, Derrick Stolee wrote:
Show 25 quoted lines
> On 4/28/26 12:26 PM, Johannes Schindelin via GitGitGadget wrote:
> > 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)
> ...
> > +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.Thank you! That was indeed the exact thing I wanted to achieve: To allow for incremental, easy-to-review patch series.
Ciao, Johannes