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

[PATCH 1/2] code cleanup in sha1_file.c: xmalloc -> xcalloc

From
GLGuanqun Lu <guanqun.lu@gmail.com>
Date
Feb 11, 2009, 06:43 UTC
Message-ID
<1234334612-24907-1-git-send-email-guanqun.lu@gmail.com>

'xmalloc' followed immediately by 'memset' is replaced with 'xcalloc', and a simple grep in this project seems to show that it's the only place.

Signed-off-by: Guanqun Lu <guanqun.lu@gmail.com>
---
 sha1_file.c |    3 +--
 1 files changed, 1 insertions(+), 2 deletions(-)
diff --git a/sha1_file.c b/sha1_file.c
index 8868b80..93e5fc0 100644
--- a/sha1_file.c
+++ b/sha1_file.c
@@ -858,8 +858,7 @@ unsigned char* use_pack(struct packed_git *p,
 
 static struct packed_git *alloc_packed_git(int extra)
 {
-	struct packed_git *p = xmalloc(sizeof(*p) + extra);
-	memset(p, 0, sizeof(*p));
+	struct packed_git *p = xcalloc(1, sizeof(*p) + extra);
 	p->pack_fd = -1;
 	return p;
 }
-- 
1.6.1.2.392.gb04d1
Next: Brandon Casey
Message 1 of 5 in “code cleanup in sha1_file.c: xmalloc -> xcalloc”
  1. 1/2 code cleanup in sha1_file.c: xmalloc -> xcallocGuanqun Lu, Feb 11, 2009
  2. Brandon CaseyFeb 10, 2009
  3. Junio C HamanoFeb 10, 2009
  4. 2/2 lockfile: set lk->fd = -1 in 'rollback_lock_file()'Guanqun Lu, Feb 11, 2009
  5. Junio C HamanoFeb 10, 2009

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.