From patchwork Mon Aug 26 02:45:08 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Hommey X-Patchwork-Id: 11113855 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id E870413B1 for ; Mon, 26 Aug 2019 02:45:13 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id CF69F2168B for ; Mon, 26 Aug 2019 02:45:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729248AbfHZCpN (ORCPT ); Sun, 25 Aug 2019 22:45:13 -0400 Received: from ns332406.ip-37-187-123.eu ([37.187.123.207]:39320 "EHLO glandium.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729244AbfHZCpM (ORCPT ); Sun, 25 Aug 2019 22:45:12 -0400 Received: from glandium by mitsuha.glandium.org with local (Exim 4.92) (envelope-from ) id 1i250G-0002Cx-Ot; Mon, 26 Aug 2019 11:45:08 +0900 From: Mike Hommey To: git@vger.kernel.org Cc: gitster@pobox.com Subject: [PATCH] packfile: free packed_git memory when closing object store Date: Mon, 26 Aug 2019 11:45:08 +0900 Message-Id: <20190826024508.8444-1-mh@glandium.org> X-Mailer: git-send-email 2.23.0 MIME-Version: 1.0 Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Signed-off-by: Mike Hommey --- 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);