From: Derrick Stolee Date: Wed, 29 Apr 2026 13:28:45 GMT Subject: Re: [PATCH 4/6] delta, packfile: use size_t for delta header sizes 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: > From: Johannes Schindelin > > 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. Thanks, -Stolee