Skip to content

Commit 54273d1

Browse files
rscharfegitster
authored andcommitted
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 <[email protected]> Original-patch-by: Taylor Blau <[email protected]> Signed-off-by: René Scharfe <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 898f807 commit 54273d1

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

csum-file.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,4 +62,11 @@ static inline void hashwrite_be32(struct hashfile *f, uint32_t data)
6262
hashwrite(f, &data, sizeof(data));
6363
}
6464

65+
static inline size_t hashwrite_be64(struct hashfile *f, uint64_t data)
66+
{
67+
data = htonll(data);
68+
hashwrite(f, &data, sizeof(data));
69+
return sizeof(data);
70+
}
71+
6572
#endif

0 commit comments

Comments
 (0)