Re: [PATCH 4/9] csum-file: provide a function to release checkpoints
- From
Patrick Steinhardt <ps@pks.im>
- Date
- Jul 3, 2026, 11:27 UTC
- Message-ID
- <akecoptZrCq1PcFV@pks.im>
- In-Reply-To
- <20260702080319.GD2029434@coredump.intra.peff.net>
On Thu, Jul 02, 2026 at 04:03:19AM -0400, Jeff King wrote:
Show 10 quoted lines
> A hashfile_checkpoint struct is basically just a copy of the hash_ctx > state at a given point in the file. As such, it contains its own > git_hash_ctx which may (depending on the underlying hash implementation) > need to be discarded when we're done with it. > > Let's add a "release" function which cleans up the hash context it > holds. I chose "release" here and not "discard" because you'd use this > to clean up every checkpoint, whether you used it or not. As opposed to > git_hash_discard(), which is needed only if you didn't call > git_hash_final().
Okay, I was wondering about that a bit. With this explanation I'm also somewhat fine with the `git_hash_discard()` name. It's still a function that has release semantics, but you want to convey more intent than that.
One thing I was wondering: is it safe to have a `git_hash_discard()` that is being called on a potentially-already-discarded hash? If so, we wouldn't have to discern whether the hash context was used successfully or not.
Patrick