summaryrefslogtreecommitdiff
path: root/csum-file.h
diff options
context:
space:
mode:
authorJeff King <peff@peff.net>2019-12-18 11:25:42 (GMT)
committerJunio C Hamano <gitster@pobox.com>2020-01-23 18:51:50 (GMT)
commit2f4af776990b59f569d68ffd3cb3556213537b04 (patch)
tree4e8ffb9cac0703bb5cf79162c74c1eebd3885d3d /csum-file.h
parent8ebf5296611228a49605327021e6be74cc2fb4c9 (diff)
downloadgit-2f4af776990b59f569d68ffd3cb3556213537b04.zip
git-2f4af776990b59f569d68ffd3cb3556213537b04.tar.gz
git-2f4af776990b59f569d68ffd3cb3556213537b04.tar.bz2
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>
Diffstat (limited to 'csum-file.h')
-rw-r--r--csum-file.h9
1 files changed, 9 insertions, 0 deletions
diff --git a/csum-file.h b/csum-file.h
index a98b1ee..f9cbd31 100644
--- a/csum-file.h
+++ b/csum-file.h
@@ -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));