From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-3.3 required=5.0 tests=MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 25070 invoked from network); 13 Feb 2022 15:35:13 -0000 Received: from lists.zx2c4.com (165.227.139.114) by inbox.vuxu.org with ESMTPUTF8; 13 Feb 2022 15:35:13 -0000 Received: by lists.zx2c4.com (OpenSMTPD) with ESMTP id 7d024229; Sun, 13 Feb 2022 15:34:56 +0000 (UTC) Return-Path: Received: from mta02.prd.rdg.aluminati.org (mta02.prd.rdg.aluminati.org [94.76.243.215]) by lists.zx2c4.com (OpenSMTPD) with ESMTPS id 2b72c73f (TLSv1.3:AEAD-AES256-GCM-SHA384:256:NO) for ; Sun, 13 Feb 2022 15:34:55 +0000 (UTC) Received: from mta02.prd.rdg.aluminati.org (localhost [127.0.0.1]) by mta.aluminati.local (Postfix) with ESMTP id 423C11FF60; Sun, 13 Feb 2022 15:34:55 +0000 (GMT) Received: from localhost (localhost [127.0.0.1]) by mta02.prd.rdg.aluminati.org (Postfix) with ESMTP id 3C61329D; Sun, 13 Feb 2022 15:34:55 +0000 (GMT) X-Quarantine-ID: X-Virus-Scanned: Debian amavisd-new at mta02.prd.rdg.aluminati.org Received: from mta.aluminati.local ([127.0.0.1]) by localhost (mta02.prd.rdg.aluminati.org [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id snZ2MpqQ5Mww; Sun, 13 Feb 2022 15:34:54 +0000 (GMT) Received: from river.lan (unknown [81.174.171.191]) by svc01-1.prd.rdg.aluminati.org (Postfix) with ESMTPSA id 8CE4E1C0003; Sun, 13 Feb 2022 15:34:51 +0000 (GMT) From: John Keeping To: cgit@lists.zx2c4.com Cc: John Keeping Subject: [PATCH] treewide: use release_commit_memory() Date: Sun, 13 Feb 2022 15:34:50 +0000 Message-Id: <98d70d24a2a37f9bbfec2f25d2c026005757a246.1644766431.git.john@keeping.me.uk> X-Mailer: git-send-email 2.35.1 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-BeenThere: cgit@lists.zx2c4.com X-Mailman-Version: 2.1.30rc1 Precedence: list List-Id: List for cgit developers and users List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: cgit-bounces@lists.zx2c4.com Sender: "CGit" Instead of calling two separate Git functions to free memory associated with a commit object, use Git's wrapper which does this. This also counts as a potential future bug fix since release_commit_memory() also resets the parsed state of the commit, meaning any attempt to use it in the future will correctly fill out the fields again. release_commit_memory() does not set parents to zero, so keep that for additional safety in case CGit checks this without calling parse_commit() again. Signed-off-by: John Keeping --- ui-atom.c | 3 +-- ui-log.c | 6 ++---- ui-stats.c | 3 +-- 3 files changed, 4 insertions(+), 8 deletions(-) diff --git a/ui-atom.c b/ui-atom.c index 1056f36..83fde7d 100644 --- a/ui-atom.c +++ b/ui-atom.c @@ -140,8 +140,7 @@ void cgit_print_atom(char *tip, const char *path, int= max_count) } while ((commit =3D get_revision(&rev)) !=3D NULL) { add_entry(commit, host); - free_commit_buffer(the_repository->parsed_objects, commit); - free_commit_list(commit->parents); + release_commit_memory(the_repository->parsed_objects, commit); commit->parents =3D NULL; } html("\n"); diff --git a/ui-log.c b/ui-log.c index 20774bf..db63424 100644 --- a/ui-log.c +++ b/ui-log.c @@ -489,8 +489,7 @@ void cgit_print_log(const char *tip, int ofs, int cnt= , char *grep, char *pattern for (i =3D 0; i < ofs && (commit =3D get_revision(&rev)) !=3D NULL; /* = nop */) { if (show_commit(commit, &rev)) i++; - free_commit_buffer(the_repository->parsed_objects, commit); - free_commit_list(commit->parents); + release_commit_memory(the_repository->parsed_objects, commit); commit->parents =3D NULL; } =20 @@ -511,8 +510,7 @@ void cgit_print_log(const char *tip, int ofs, int cnt= , char *grep, char *pattern i++; print_commit(commit, &rev); } - free_commit_buffer(the_repository->parsed_objects, commit); - free_commit_list(commit->parents); + release_commit_memory(the_repository->parsed_objects, commit); commit->parents =3D NULL; } if (pager) { diff --git a/ui-stats.c b/ui-stats.c index 09b3625..40ed6c2 100644 --- a/ui-stats.c +++ b/ui-stats.c @@ -241,8 +241,7 @@ static struct string_list collect_stats(const struct = cgit_period *period) memset(&authors, 0, sizeof(authors)); while ((commit =3D get_revision(&rev)) !=3D NULL) { add_commit(&authors, commit, period); - free_commit_buffer(the_repository->parsed_objects, commit); - free_commit_list(commit->parents); + release_commit_memory(the_repository->parsed_objects, commit); commit->parents =3D NULL; } return authors; --=20 2.35.1