@matheusbsbs / matheus-bagliano / commits / 2f4af77699
Fork 0

csum-file: introduce hashfile_total()

We will need this helper function in a following commit to give us total number of bytes fed to the hashfile so far. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Christian Couder <chriscool@tuxfamily.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Jeff King committed Dec 18, 2019 at 12:25 UTC 2f4af776990b59f569d68ffd3cb3556213537b04
1 file changed +9
csum-file.h
+9
@@ -42,6 +42,15 @@ void hashflush(struct hashfile *f);
42 void crc32_begin(struct hashfile *);
43 uint32_t crc32_end(struct hashfile *);
44
45 +/*
46 + * Returns the total number of bytes fed to the hashfile so far (including ones
47 + * that have not been written out to the descriptor yet).
48 + */
49 +static inline off_t hashfile_total(struct hashfile *f)
50 +{
51 + return f->total + f->offset;
52 +}
53 +
54 static inline void hashwrite_u8(struct hashfile *f, uint8_t data)
55 {
56 hashwrite(f, &data, sizeof(data));