From: Junio C Hamano <gitster@pobox.com>
To: "Ævar Arnfjörð Bjarmason" <avarab@gmail.com>
Cc: git@vger.kernel.org, Jeff King <peff@peff.net>,
Eric Sunshine <sunshine@sunshineco.com>
Subject: Re: [PATCH v3 4/6] log: refactor "rev.pending" code in cmd_show()
Date: Wed, 03 Aug 2022 10:59:52 -0700 [thread overview]
Message-ID: <xmqqo7x19pif.fsf@gitster.g> (raw)
In-Reply-To: <patch-v3-4.6-fd474666e7c-20220802T152925Z-avarab@gmail.com> ("Ævar Arnfjörð Bjarmason"'s message of "Tue, 2 Aug 2022 17:33:14 +0200")
Ævar Arnfjörð Bjarmason <avarab@gmail.com> writes:
> Refactor the juggling of "rev.pending" and our replacement for it
> amended in the preceding commit so that:
> ...
> Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
> Helped-by: Jeff King <peff@peff.net>
List trailer lines chronologically, please.
This does not look wrong per-se, but given that we might want to
rethink the way the original rev_info is reused inside the loop,
as I mentioned in my review of the previous step, this change may be
irrelevant in the longer term.
I may have said this earlier, but once we start using the "prepare a
blank one, copy it to clear another" pattern, we should stop using
memcpy() and use structure assignment, especially if we are trying to
make our intent clear.
> @@ -745,12 +743,19 @@ int cmd_show(int argc, const char **argv, const char *prefix)
> case OBJ_COMMIT:
> {
> struct object_array old;
> + struct object_array blank = OBJECT_ARRAY_INIT;
>
> memcpy(&old, &rev.pending, sizeof(old));
> - rev.pending.nr = rev.pending.alloc = 0;
> - rev.pending.objects = NULL;
> + memcpy(&rev.pending, &blank, sizeof(rev.pending));
> +
> add_object_array(o, name, &rev.pending);
> ret = cmd_log_walk_no_free(&rev);
> +
> + /*
> + * No need for
> + * object_array_clear(&pending). It was
> + * cleared already in prepare_revision_walk()
> + */
> memcpy(&rev.pending, &old, sizeof(rev.pending));
> break;
> }
next prev parent reply other threads:[~2022-08-03 18:00 UTC|newest]
Thread overview: 52+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-07-13 13:10 [PATCH 0/6] revisions API: fix more memory leaks Ævar Arnfjörð Bjarmason
2022-07-13 13:10 ` [PATCH 1/6] bisect.c: add missing "goto" for release_revisions() Ævar Arnfjörð Bjarmason
2022-07-13 13:10 ` [PATCH 2/6] test-fast-rebase helper: use release_revisions() (again) Ævar Arnfjörð Bjarmason
2022-07-13 13:10 ` [PATCH 3/6] log: make the intent of cmd_show()'s "rev.pending" juggling clearer Ævar Arnfjörð Bjarmason
2022-07-18 14:51 ` Jeff King
2022-07-13 13:10 ` [PATCH 4/6] log: fix common "rev.pending" memory leak in "git show" Ævar Arnfjörð Bjarmason
2022-07-18 14:57 ` Jeff King
2022-07-18 15:08 ` Ævar Arnfjörð Bjarmason
2022-07-13 13:10 ` [PATCH 5/6] bisect.c: partially fix bisect_rev_setup() memory leak Ævar Arnfjörð Bjarmason
2022-07-18 15:05 ` Jeff King
2022-07-13 13:10 ` [PATCH 6/6] revisions API: don't leak memory on argv elements that need free()-ing Ævar Arnfjörð Bjarmason
2022-07-18 15:11 ` Jeff King
2022-07-18 15:13 ` Ævar Arnfjörð Bjarmason
2022-07-18 15:45 ` Jeff King
2022-07-29 7:07 ` Ævar Arnfjörð Bjarmason
2022-07-29 18:03 ` Jeff King
2022-07-29 18:37 ` Jeff King
2022-07-29 18:52 ` Junio C Hamano
2022-07-29 19:04 ` Jeff King
2022-07-18 15:14 ` [PATCH 0/6] revisions API: fix more memory leaks Jeff King
2022-07-29 8:31 ` [PATCH v2 " Ævar Arnfjörð Bjarmason
2022-07-29 8:31 ` [PATCH v2 1/6] bisect.c: add missing "goto" for release_revisions() Ævar Arnfjörð Bjarmason
2022-07-29 8:31 ` [PATCH v2 2/6] test-fast-rebase helper: use release_revisions() (again) Ævar Arnfjörð Bjarmason
2022-07-30 5:22 ` Eric Sunshine
2022-07-29 8:31 ` [PATCH v2 3/6] log: make the intent of cmd_show()'s "rev.pending" juggling clearer Ævar Arnfjörð Bjarmason
2022-07-29 18:44 ` Junio C Hamano
2022-07-29 8:31 ` [PATCH v2 4/6] log: fix common "rev.pending" memory leak in "git show" Ævar Arnfjörð Bjarmason
2022-07-29 18:55 ` Jeff King
2022-07-29 19:07 ` Jeff King
2022-07-29 18:59 ` Jeff King
2022-07-29 8:31 ` [PATCH v2 5/6] bisect.c: partially fix bisect_rev_setup() memory leak Ævar Arnfjörð Bjarmason
2022-07-29 8:31 ` [PATCH v2 6/6] revisions API: don't leak memory on argv elements that need free()-ing Ævar Arnfjörð Bjarmason
2022-07-29 19:00 ` Jeff King
2022-07-29 19:02 ` [PATCH v2 0/6] revisions API: fix more memory leaks Jeff King
2022-08-02 15:33 ` [PATCH v3 " Ævar Arnfjörð Bjarmason
2022-08-02 15:33 ` [PATCH v3 1/6] bisect.c: add missing "goto" for release_revisions() Ævar Arnfjörð Bjarmason
2022-08-03 17:13 ` Junio C Hamano
2022-08-02 15:33 ` [PATCH v3 2/6] test-fast-rebase helper: use release_revisions() (again) Ævar Arnfjörð Bjarmason
2022-08-02 15:33 ` [PATCH v3 3/6] log: fix a memory leak in "git show <revision>..." Ævar Arnfjörð Bjarmason
2022-08-03 17:27 ` Jeff King
2022-08-03 17:29 ` Jeff King
2022-08-03 17:54 ` Junio C Hamano
2022-08-02 15:33 ` [PATCH v3 4/6] log: refactor "rev.pending" code in cmd_show() Ævar Arnfjörð Bjarmason
2022-08-03 17:32 ` Jeff King
2022-08-03 17:59 ` Junio C Hamano [this message]
2022-08-04 7:51 ` Ævar Arnfjörð Bjarmason
2022-08-04 15:59 ` Junio C Hamano
2022-08-05 9:01 ` Ævar Arnfjörð Bjarmason
2022-08-02 15:33 ` [PATCH v3 5/6] bisect.c: partially fix bisect_rev_setup() memory leak Ævar Arnfjörð Bjarmason
2022-08-02 15:33 ` [PATCH v3 6/6] revisions API: don't leak memory on argv elements that need free()-ing Ævar Arnfjörð Bjarmason
2022-08-03 18:30 ` Junio C Hamano
2022-08-03 17:33 ` [PATCH v3 0/6] revisions API: fix more memory leaks Jeff King
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: http://vger.kernel.org/majordomo-info.html
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=xmqqo7x19pif.fsf@gitster.g \
--to=gitster@pobox.com \
--cc=avarab@gmail.com \
--cc=git@vger.kernel.org \
--cc=peff@peff.net \
--cc=sunshine@sunshineco.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://80x24.org/mirrors/git.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).