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

[PATCH] packfile: free packed_git memory when closing object store

From
Mike Hommey <mh@glandium.org>
Date
Aug 26, 2019, 02:45 UTC
Message-ID
<20190826024508.8444-1-mh@glandium.org>
Signed-off-by: Mike Hommey <mh@glandium.org>
---
 packfile.c | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)
Note, I'm not sure this is the right place to do it.
diff --git a/packfile.c b/packfile.c
index fc43a6c52c..b0cb84adda 100644
--- a/packfile.c
+++ b/packfile.c
@@ -339,13 +339,16 @@ void close_pack(struct packed_git *p)
 
 void close_object_store(struct raw_object_store *o)
 {
-	struct packed_git *p;
+	struct packed_git *p = o->packed_git;
 
-	for (p = o->packed_git; p; p = p->next)
+	while (p) {
+		struct packed_git *current = p;
 		if (p->do_not_close)
 			BUG("want to close pack marked 'do-not-close'");
-		else
-			close_pack(p);
+		close_pack(p);
+		p = p->next;
+		free(current);
+	}
 
 	if (o->multi_pack_index) {
 		close_midx(o->multi_pack_index);
-- 
2.23.0
Next: Junio C Hamano
Message 1 of 3 in “packfile: free packed_git memory when closing object store”
  1. packfile: free packed_git memory when closing object storeMike Hommey, Aug 26, 2019
  2. Junio C HamanoAug 26, 2019
  3. Mike HommeyAug 27, 2019

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.