git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH 1/3] csum-file: add hashwrite_be64()

From
René Scharfe <l.s.r@web.de>
Date
Nov 12, 2020, 12:20 UTC
Message-ID
<16932ced-8bcd-89bd-b927-cae1bce0365a@web.de>

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
Next: René Scharfe
Message 1 of 6 in “csum-file: add hashwrite_be64()”
  1. 1/3 csum-file: add hashwrite_be64()René Scharfe, Nov 12, 2020
  2. 2/3 midx: use hashwrite_be64()René Scharfe, Nov 12, 2020
  3. 3/3 pack-write: use hashwrite_be64()René Scharfe, Nov 12, 2020
  4. Derrick StoleeNov 12, 2020
  5. Taylor BlauNov 12, 2020
  6. Taylor BlauNov 12, 2020

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.