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

[PATCH v3 2/5] strbuf: Added strbuf_add_uint32().

From
Henrik Grubbström (Grubba) <grubba@grubba.org>
Date
May 10, 2010, 09:51 UTC
Message-ID
<127d7018774ac06757bcffb2c691b4ab7b866021.1273482409.git.grubba@grubba.org>
In-Reply-To
<cover.1273482409.git.grubba@grubba.org>

Added convenience function for adding an unsigned 32bit integer in network byte-order to a strbuf.

Signed-off-by: Henrik Grubbström <grubba@grubba.org>
---
New trivial function.
 strbuf.h |    4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)
diff --git a/strbuf.h b/strbuf.h
index fac2dbc..52cd71e 100644
--- a/strbuf.h
+++ b/strbuf.h
@@ -107,6 +107,10 @@ static inline void strbuf_addbuf(struct strbuf *sb, const struct strbuf *sb2) {
 	strbuf_grow(sb, sb2->len);
 	strbuf_add(sb, sb2->buf, sb2->len);
 }
+static inline void strbuf_add_uint32(struct strbuf *sb, uint32_t val) {
+	val = htonl(val);
+	strbuf_add(sb, &val, sizeof(val));
+}
 extern void strbuf_adddup(struct strbuf *sb, size_t pos, size_t len);
 
 typedef size_t (*expand_fn_t) (struct strbuf *sb, const char *placeholder, void *context);
-- 
1.7.0.4.369.g81e89
Previous: Henrik Grubbström (Grubba)Next: Henrik Grubbström (Grubba)
Message 3 of 6 in “Patches to avoid reporting conversion changes.”
  1. 0/5 Patches to avoid reporting conversion changes.Henrik Grubbström (Grubba), May 10, 2010
  2. 1/5 sha1_file: Added index_blob().Henrik Grubbström (Grubba), May 10, 2010
  3. 2/5 strbuf: Added strbuf_add_uint32().Henrik Grubbström (Grubba), May 10, 2010
  4. 3/5 cache: Keep track of conversion mode changes.Henrik Grubbström (Grubba), May 10, 2010
  5. 4/5 cache: Added index extension "CONV".Henrik Grubbström (Grubba), May 10, 2010
  6. 5/5 t/t0021: Test that conversion changes are detected.Henrik Grubbström (Grubba), May 10, 2010

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.