csum-file: introduce hashfile_total()
authorJeff King <redacted>
Wed, 18 Dec 2019 11:25:42 +0000 (12:25 +0100)
committerJunio C Hamano <redacted>
Thu, 23 Jan 2020 18:51:50 +0000 (10:51 -0800)
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 <redacted>
Signed-off-by: Christian Couder <redacted>
Signed-off-by: Junio C Hamano <redacted>
csum-file.h

index a98b1eee53f40367ad06c7aa82da7af0ca6ed6bc..f9cbd317fbbce89547a405783fb5cc69e7815efa 100644 (file)
@@ -42,6 +42,15 @@ void hashflush(struct hashfile *f);
 void crc32_begin(struct hashfile *);
 uint32_t crc32_end(struct hashfile *);
 
+/*
+ * Returns the total number of bytes fed to the hashfile so far (including ones
+ * that have not been written out to the descriptor yet).
+ */
+static inline off_t hashfile_total(struct hashfile *f)
+{
+       return f->total + f->offset;
+}
+
 static inline void hashwrite_u8(struct hashfile *f, uint8_t data)
 {
        hashwrite(f, &data, sizeof(data));
git clone https://git.99rst.org/PROJECT