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

Re: [PATCH 3/4] combine-diff: Optimize combine_diff_path sets intersection

From
Kirill Smelkov <kirr@mns.spb.ru>
Date
Jan 28, 2014, 15:46 UTC
Message-ID
<20140128154654.GA5925@tugrik.mns.mnsspb.ru>
In-Reply-To
<b97e63128093f6c5f5cab854b9b9487c4e6b955a.1390234183.git.kirr@mns.spb.ru>

On Mon, Jan 20, 2014 at 08:20:40PM +0400, Kirill Smelkov wrote: [...]

Show 22 quoted lines
> @@ -1343,6 +1374,26 @@ void diff_tree_combined(const unsigned char *sha1,
>  		if (p->len)
>  			num_paths++;
>  	}
> +
> +	/* order paths according to diffcore_order */
> +	if (opt->orderfile && num_paths) {
> +		struct obj_order *o;
> +
> +		o = xmalloc(sizeof(*o) * num_paths);
> +		for (i = 0, p = paths; p; p = p->next, i++)
> +			o[i].obj = p;
> +		order_objects(opt->orderfile, path_path, o, num_paths);
> +		for (i = 0; i < num_paths - 1; i++) {
> +			p = o[i].obj;
> +			p->next = o[i+1].obj;
> +		}
> +
> +		p = o[num_paths-1].obj;
> +		p->next = NULL;
> +		paths = o[0].obj;
> +	}

I found I've introduced memory leak here (malloc without free). Please apply the fix. Thanks, Kirill.

---- 8< ----
From: Kirill Smelkov <kirr@mns.spb.ru>
Date: Tue, 28 Jan 2014 19:39:16 +0400
Subject: [PATCH] fixup! combine-diff: Optimize combine_diff_path sets intersection
Plug a memory leak.
---
 combine-diff.c | 1 +
 1 file changed, 1 insertion(+)
diff --git a/combine-diff.c b/combine-diff.c
index 07faa96..2d79312 100644
--- a/combine-diff.c
+++ b/combine-diff.c
@@ -1383,6 +1383,7 @@ void diff_tree_combined(const unsigned char *sha1,
 		p = o[num_paths-1].obj;
 		p->next = NULL;
 		paths = o[0].obj;
+		free(o);
 	}
 
 
-- 
1.9.rc1.181.g641f458
Previous: Kirill SmelkovNext: Junio C Hamano
Message 5 of 8 in “`log -c` speedup”
  1. 0/4 `log -c` speedupKirill Smelkov, Jan 20, 2014
  2. 1/4 diffcore-order: Export generic ordering interfaceKirill Smelkov, Jan 20, 2014
  3. 2/4 diff test: Add tests for combine-diff with orderfileKirill Smelkov, Jan 20, 2014
  4. 3/4 combine-diff: Optimize combine_diff_path sets intersectionKirill Smelkov, Jan 20, 2014
  5. Kirill SmelkovJan 28, 2014
  6. Junio C HamanoJan 28, 2014
  7. Kirill SmelkovJan 29, 2014
  8. 4/4 combine-diff: combine_diff_path.len is not needed anymoreKirill Smelkov, Jan 20, 2014

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.