git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: "SZEDER Gábor" <szeder.dev@gmail.com>
To: git@vger.kernel.org
Cc: "Taylor Blau" <me@ttaylorr.com>,
	"man dog" <dogman888888@gmail.com>,
	"SZEDER Gábor" <szeder.dev@gmail.com>
Subject: [PATCH 2/3] line-log: free the diff queues' arrays when processing merge commits
Date: Wed,  2 Nov 2022 23:01:41 +0100	[thread overview]
Message-ID: <20221102220142.574890-3-szeder.dev@gmail.com> (raw)
In-Reply-To: <20221102220142.574890-1-szeder.dev@gmail.com>

When processing merge commits, the line-level log first creates an
array of diff queues, each comparing the merge commit with one of its
parents, to check whether any of the files in the given line ranges
were modified.  Alas, when freeing these queues it only frees the
filepairs in the queues, but not the queues' internal arrays holding
pointers to those filepairs.

Use the diff_free_queue() helper function introduced in the previous
commit to free the diff queues' internal arrays as well.

Signed-off-by: SZEDER Gábor <szeder.dev@gmail.com>
---
 line-log.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/line-log.c b/line-log.c
index 7a74daf2e8..a7f3e7f6ce 100644
--- a/line-log.c
+++ b/line-log.c
@@ -1089,10 +1089,8 @@ static struct diff_filepair *diff_filepair_dup(struct diff_filepair *pair)
 
 static void free_diffqueues(int n, struct diff_queue_struct *dq)
 {
-	int i, j;
-	for (i = 0; i < n; i++)
-		for (j = 0; j < dq[i].nr; j++)
-			diff_free_filepair(dq[i].queue[j]);
+	for (int i = 0; i < n; i++)
+		diff_free_queue(&dq[i]);
 	free(dq);
 }
 
-- 
2.38.1.564.g99c012faba


  parent reply	other threads:[~2022-11-02 22:01 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-10-29 16:59 Bug report: git -L requires excessive memory man dog
2022-10-31 21:45 ` SZEDER Gábor
2022-10-31 21:56   ` Taylor Blau
2022-11-02 22:01     ` [PATCH 0/3] line-log: plug some memory leaks SZEDER Gábor
2022-11-02 22:01       ` [PATCH 1/3] line-log: free diff queue when processing non-merge commits SZEDER Gábor
2022-11-03  0:20         ` Taylor Blau
2022-11-07 15:11           ` SZEDER Gábor
2022-11-07 15:29             ` Ævar Arnfjörð Bjarmason
2022-11-07 15:57               ` SZEDER Gábor
2022-11-08  2:14                 ` Taylor Blau
2022-11-02 22:01       ` SZEDER Gábor [this message]
2022-11-03  0:21         ` [PATCH 2/3] line-log: free the diff queues' arrays when processing merge commits Taylor Blau
2022-11-02 22:01       ` [PATCH 3/3] diff.c: use diff_free_queue() SZEDER Gábor
2022-11-03  0:24         ` Taylor Blau
2022-11-07 16:13           ` SZEDER Gábor
2022-11-08  2:14             ` Taylor Blau
2022-11-03  9:05       ` [PATCH 0/3] line-log: plug some memory leaks Ævar Arnfjörð Bjarmason

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: http://vger.kernel.org/majordomo-info.html

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20221102220142.574890-3-szeder.dev@gmail.com \
    --to=szeder.dev@gmail.com \
    --cc=dogman888888@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=me@ttaylorr.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).