git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
* [PATCH 1/3] csum-file: add hashwrite_be64()
@ 2020-11-12 12:20 René Scharfe
  2020-11-12 12:22 ` [PATCH 2/3] midx: use hashwrite_be64() René Scharfe
                   ` (3 more replies)
  0 siblings, 4 replies; 6+ messages in thread
From: René Scharfe @ 2020-11-12 12:20 UTC (permalink / raw)
  To: Git Mailing List; +Cc: Junio C Hamano, Taylor Blau, Derrick Stolee

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>
---
 csum-file.h | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/csum-file.h b/csum-file.h
index f9cbd317fb..e54d53d1d0 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
--
2.29.2

^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2020-11-12 14:51 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-11-12 12:20 [PATCH 1/3] csum-file: add hashwrite_be64() René Scharfe
2020-11-12 12:22 ` [PATCH 2/3] midx: use hashwrite_be64() René Scharfe
2020-11-12 12:23 ` [PATCH 3/3] pack-write: " René Scharfe
2020-11-12 13:52 ` [PATCH 1/3] csum-file: add hashwrite_be64() Derrick Stolee
2020-11-12 14:47   ` Taylor Blau
2020-11-12 14:51 ` Taylor Blau

Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).