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