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

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

From
SZEDER Gábor <szeder.dev@gmail.com>
Date
Nov 2, 2022, 22:01 UTC
Message-ID
<20221102220142.574890-3-szeder.dev@gmail.com>
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
Previous: Taylor BlauNext: Taylor Blau
Message 11 of 17 in “Bug report: git -L requires excessive memory.”
  1. man dogOct 29, 2022
  2. SZEDER GáborOct 31, 2022
  3. Taylor BlauOct 31, 2022
  4. 0/3 line-log: plug some memory leaksSZEDER Gábor, Nov 2, 2022
  5. 1/3 line-log: free diff queue when processing non-merge commitsSZEDER Gábor, Nov 2, 2022
  6. Taylor BlauNov 3, 2022
  7. SZEDER GáborNov 7, 2022
  8. Ævar Arnfjörð BjarmasonNov 7, 2022
  9. SZEDER GáborNov 7, 2022
  10. Taylor BlauNov 8, 2022
  11. 2/3 line-log: free the diff queues' arrays when processing merge commitsSZEDER Gábor, Nov 2, 2022
  12. Taylor BlauNov 3, 2022
  13. 3/3 diff.c: use diff_free_queue()SZEDER Gábor, Nov 2, 2022
  14. Taylor BlauNov 3, 2022
  15. SZEDER GáborNov 7, 2022
  16. Taylor BlauNov 8, 2022
  17. Ævar Arnfjörð BjarmasonNov 3, 2022

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.