From: Junio C Hamano <gitster@pobox.com>
To: Christian Couder <christian.couder@gmail.com>
Cc: git@vger.kernel.org, "Jeff King" <peff@peff.net>,
"Ævar Arnfjörð Bjarmason" <avarab@gmail.com>,
"Karsten Blees" <karsten.blees@gmail.com>,
"Nguyen Thai Ngoc Duy" <pclouds@gmail.com>,
"Stefan Beller" <sbeller@google.com>,
"Matthieu Moy" <Matthieu.Moy@grenoble-inp.fr>,
"Eric Sunshine" <sunshine@sunshineco.com>,
"Ramsay Jones" <ramsay@ramsayjones.plus.com>,
"Christian Couder" <chriscool@tuxfamily.org>
Subject: Re: [PATCH v4 1/2] builtin/apply: add 'lock_file' pointer into 'struct apply_state'
Date: Fri, 03 Jun 2016 11:03:08 -0700 [thread overview]
Message-ID: <xmqq4m9ap2ub.fsf@gitster.mtv.corp.google.com> (raw)
In-Reply-To: <20160603165852.12399-1-chriscool@tuxfamily.org> (Christian Couder's message of "Fri, 3 Jun 2016 18:58:51 +0200")
Christian Couder <christian.couder@gmail.com> writes:
> This is to replace:
>
> "[PATCH v3 48/49] builtin/apply: move 'lock_file' global into 'struct apply_state'"
>
> from the "libify apply and use lib in am, part 1" patch series.
Thanks; will replace the tip 2 patches and requeue.
> diff --git a/builtin/apply.c b/builtin/apply.c
> index 5027f1b..cc635eb 100644
> --- a/builtin/apply.c
> +++ b/builtin/apply.c
> @@ -52,6 +52,12 @@ struct apply_state {
> const char *prefix;
> int prefix_length;
>
> + /*
> + * Since lockfile.c keeps a linked list of all created
> + * lock_file structures, it isn't safe to free(lock_file).
> + */
> + struct lock_file *lock_file;
Is this even an issue for this thing anymore? It is the
responsibilty of the API user to manage the lifetime of what
lock_file points at. The caller may have it on heap and let it
leak, or it may have in BSS in which case it won't even dream about
freeing it.
If a comment were needed for this field, it should say "when
discarding/freeing apply_state, just discard this pointer without
touching what the pointer points at; the storage the pointer points
at does not belong to the API implementation but belongs to the API
user".
But I do not think such a comment is needed, because the situation
is the same as other fields like *prefix, and for the same reason we
do not do anything to these fields in clear_apply_state().
Other than that this looks great.
next prev parent reply other threads:[~2016-06-03 18:03 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-06-03 16:58 [PATCH v4 1/2] builtin/apply: add 'lock_file' pointer into 'struct apply_state' Christian Couder
2016-06-03 16:58 ` [PATCH v4 2/2] builtin/apply: move 'newfd' global " Christian Couder
2016-06-03 17:23 ` [PATCH v4 1/2] builtin/apply: add 'lock_file' pointer " Christian Couder
2016-06-03 18:03 ` Junio C Hamano [this message]
2016-06-06 10:03 ` Christian Couder
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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=xmqq4m9ap2ub.fsf@gitster.mtv.corp.google.com \
--to=gitster@pobox.com \
--cc=Matthieu.Moy@grenoble-inp.fr \
--cc=avarab@gmail.com \
--cc=chriscool@tuxfamily.org \
--cc=christian.couder@gmail.com \
--cc=git@vger.kernel.org \
--cc=karsten.blees@gmail.com \
--cc=pclouds@gmail.com \
--cc=peff@peff.net \
--cc=ramsay@ramsayjones.plus.com \
--cc=sbeller@google.com \
--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.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.