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

[PATCH 1/2] Added use of xmalloc() on diff-delta.c

From
BRBruno Ribas <ribas@c3sl.ufpr.br>
Date
Apr 4, 2007, 18:50 UTC
Message-ID
<11757126093105-git-send-email-ribas@c3sl.ufpr.br>
Signed-off-by: Bruno Ribas <ribas@c3sl.ufpr.br>
---
 diff-delta.c |    9 +++------
 1 files changed, 3 insertions(+), 6 deletions(-)
diff --git a/diff-delta.c b/diff-delta.c
index 9f998d0..74a8377 100644
--- a/diff-delta.c
+++ b/diff-delta.c
@@ -157,9 +157,8 @@ struct delta_index * create_delta_index(const void *buf, unsigned long bufsize)
 	memsize = sizeof(*index) +
 		  sizeof(*hash) * hsize +
 		  sizeof(*entry) * entries;
-	mem = malloc(memsize);
-	if (!mem)
-		return NULL;
+	mem = xmalloc(memsize);
+
 	index = mem;
 	mem = index + 1;
 	hash = mem;
@@ -258,9 +257,7 @@ create_delta(const struct delta_index *index,
 	outsize = 8192;
 	if (max_size && outsize >= max_size)
 		outsize = max_size + MAX_OP_SIZE + 1;
-	out = malloc(outsize);
-	if (!out)
-		return NULL;
+	out = xmalloc(outsize);
 
 	/* store reference buffer size */
 	i = index->src_size;
-- 
1.5.0.3
Next: Bruno Ribas
Message 1 of 5 in “Added use of xmalloc() on diff-delta.c”
  1. 1/2 Added use of xmalloc() on diff-delta.cBruno Ribas, Apr 4, 2007
  2. 2/2 Removed NULL check on builtin-pack-objects.c from create_delta_index() as it just checks for Out of MemoryBruno Ribas, Apr 4, 2007
  3. Junio C HamanoApr 4, 2007
  4. Linus TorvaldsApr 4, 2007
  5. Junio C HamanoApr 5, 2007

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.