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

[PATCH] fast-import: use mem_pool_calloc()

From
René Scharfe <l.s.r@web.de>
Date
Dec 26, 2023, 08:17 UTC
Message-ID
<50c1f410-ca37-4c1c-a28b-3e9fad49f2b4@web.de>

Use mem_pool_calloc() to get a zeroed buffer instead of zeroing it ourselves. This makes the code clearer and less repetitive.

Signed-off-by: René Scharfe <l.s.r@web.de>
---
 builtin/fast-import.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/builtin/fast-import.c b/builtin/fast-import.c
index 444f41cf8c..92eda20683 100644
--- a/builtin/fast-import.c
+++ b/builtin/fast-import.c
@@ -2809,8 +2809,7 @@ static void parse_new_tag(const char *arg)
 	enum object_type type;
 	const char *v;

-	t = mem_pool_alloc(&fi_mem_pool, sizeof(struct tag));
-	memset(t, 0, sizeof(struct tag));
+	t = mem_pool_calloc(&fi_mem_pool, 1, sizeof(struct tag));
 	t->name = mem_pool_strdup(&fi_mem_pool, arg);
 	if (last_tag)
 		last_tag->next_tag = t;
--
2.43.0
Next: Elijah Newren
Message 1 of 2 in “fast-import: use mem_pool_calloc()”
  1. fast-import: use mem_pool_calloc()René Scharfe, Dec 26, 2023
  2. Elijah NewrenDec 26, 2023

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.