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

Re: [PATCH v4 1/2] builtin/apply: add 'lock_file' pointer into 'struct apply_state'

From
Christian Couder <christian.couder@gmail.com>
Date
Jun 6, 2016, 10:03 UTC
Message-ID
<CAP8UFD3DAg02u95+227ZbsF=nQn+1jC_P7DAQUY9jaOwBoCk1w@mail.gmail.com>
In-Reply-To
<xmqq4m9ap2ub.fsf@gitster.mtv.corp.google.com>
On Fri, Jun 3, 2016 at 8:03 PM, Junio C Hamano <gitster@pobox.com> wrote:
Show 39 quoted lines
> 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().
Ok, I just resent without this comment.
I still don't understand why there is an added:
From: Christian Couder <christian.couder@gmail.com>
at the beginning of the emails.
> Other than that this looks great.

Thanks, Christian.

Previous: Junio C Hamano
Message 5 of 5 in “builtin/apply: add 'lock_file' pointer into 'struct apply_state'”
  1. 1/2 builtin/apply: add 'lock_file' pointer into 'struct apply_state'Christian Couder, Jun 3, 2016
  2. 2/2 builtin/apply: move 'newfd' global into 'struct apply_state'Christian Couder, Jun 3, 2016
  3. Christian CouderJun 3, 2016
  4. Junio C HamanoJun 3, 2016
  5. Christian CouderJun 6, 2016

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.