diff mbox series

[2/3] line-log: free the diff queues' arrays when processing merge commits

Message ID 20221102220142.574890-3-szeder.dev@gmail.com (mailing list archive)
State Accepted
Commit ef84222fa9b3ed163bacd6dc59a1d855dfbfbd75
Headers show
Series line-log: plug some memory leaks | expand

Commit Message

SZEDER Gábor Nov. 2, 2022, 10:01 p.m. UTC
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(-)

Comments

Taylor Blau Nov. 3, 2022, 12:21 a.m. UTC | #1
On Wed, Nov 02, 2022 at 11:01:41PM +0100, SZEDER Gábor wrote:
> ---
>  line-log.c | 6 ++----
>  1 file changed, 2 insertions(+), 4 deletions(-)

Looking good.

Thanks,
Taylor
diff mbox series

Patch

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);
 }