Re: [PATCH 5/6] sequencer: duplicate the result of resolve_ref_unsafe()
- From
SZEDER Gábor <szeder.dev@gmail.com>
- Date
- Oct 9, 2022, 17:23 UTC
- Message-ID
- <20221009172306.GA2052@szeder.dev>
- In-Reply-To
- <1711157b-8f04-008b-1672-f1fbac3c3e81@github.com>
On Fri, Sep 30, 2022 at 01:23:27PM -0400, Derrick Stolee wrote:
Show 9 quoted lines
> > - const char *head_ref = resolve_ref_unsafe("HEAD",
> > + const char *head_ref = xstrdup_or_null(resolve_ref_unsafe("HEAD",
> > RESOLVE_REF_READING,
> > NULL,
> > - NULL);
> > + NULL));
>
> Moving to a 'char *' matches our typical pattern of "I am responsible
> for freeing this or passing that responsibility to someone else."Do we really have such a misleading pattern?
To me 'char*', as opposed to 'const char*', means that "I'll modify the buffer where this pointer points to, and I must be on the lookout for when and how that happens".