]> git.ipfire.org Git - thirdparty/git.git/commitdiff
csum-file: add hashwrite_be64()
authorRené Scharfe <l.s.r@web.de>
Thu, 12 Nov 2020 12:20:19 +0000 (13:20 +0100)
committerJunio C Hamano <gitster@pobox.com>
Thu, 12 Nov 2020 17:40:06 +0000 (09:40 -0800)
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>
csum-file.h

index f9cbd317fbbce89547a405783fb5cc69e7815efa..e54d53d1d0b3537b4fb4b0f22f9699cf38a2c3cf 100644 (file)
@@ -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