summaryrefslogtreecommitdiff
path: root/csum-file.h
diff options
context:
space:
mode:
authorRené Scharfe <l.s.r@web.de>2020-11-12 12:20:19 (GMT)
committerJunio C Hamano <gitster@pobox.com>2020-11-12 17:40:06 (GMT)
commit54273d1042b7a7e9a5635ccf15363eec819cb951 (patch)
tree146d60f4db4a74b8bf564da41f7d627e1ed2bacb /csum-file.h
parent898f80736c75878acc02dc55672317fcc0e0a5a6 (diff)
downloadgit-54273d1042b7a7e9a5635ccf15363eec819cb951.zip
git-54273d1042b7a7e9a5635ccf15363eec819cb951.tar.gz
git-54273d1042b7a7e9a5635ccf15363eec819cb951.tar.bz2
csum-file: add hashwrite_be64()
Add a helper function for hashing and writing 64-bit integers in network byte order. It returns the number of written bytes. This simplifies callers that keep track of the file offset, even though this number is a constant. Suggested-by: Derrick Stolee <dstolee@microsoft.com> Original-patch-by: Taylor Blau <me@ttaylorr.com> Signed-off-by: René Scharfe <l.s.r@web.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'csum-file.h')
-rw-r--r--csum-file.h7
1 files changed, 7 insertions, 0 deletions
diff --git a/csum-file.h b/csum-file.h
index f9cbd31..e54d53d 100644
--- a/csum-file.h
+++ b/csum-file.h
@@ -62,4 +62,11 @@ static inline void hashwrite_be32(struct hashfile *f, uint32_t data)
hashwrite(f, &data, sizeof(data));
}
+static inline size_t hashwrite_be64(struct hashfile *f, uint64_t data)
+{
+ data = htonll(data);
+ hashwrite(f, &data, sizeof(data));
+ return sizeof(data);
+}
+
#endif