From: Patrick Steinhardt <ps@pks.im>
To: Junio C Hamano <gitster@pobox.com>
Cc: Toon Claes <toon@iotcl.com>, git@vger.kernel.org
Subject: Re: [PATCH 4/6] packfile: introduce function to free a packfile
Date: Wed, 2 Dec 2026 09:38:25 +0100 [thread overview]
Message-ID: <aw_ZAY6k6CgHZQPc@pks.im> (raw)
In-Reply-To: <xmqqik1jiava.fsf@gitster.g>
On Thu, Nov 26, 2026 at 12:41:29PM -0800, Junio C Hamano wrote:
> Toon Claes <toon@iotcl.com> writes:
>
> >> It seems that we have three kinds of free()-like functions in our
> >> system.
> >>
> >> - Ones that make it the responsibility of the caller not to pass NULL
> >> (this one falls into this category).
> >>
> >> - Ones that allows the caller to pass NULL.
> >>
> >> - Ones that not just frees, but clears the pointer the caller has to
> >> prevent future headaches coming from use-after-free (the caller must
> >> pass a pointer to the pointer pointing at the resource being freed).
> >>
> >> It seems all the callsites never passes NULL to this function, so this
> >> is fine as-is, but I wonder if we want to move it to the second category
> >> by guarding against NULL, making it behave similar to free(NULL)?
> >
> > Yeah, I was wondering about that as well, because there are a few
> > callsites doing `if (X) _free(X);`. Having the _free() function
> > NULL-safe would simplify them.
> >
> > For what it's worth, the pattern isn't described in CodingGuidelines, so
> > technically speaking it's fine. But I wouldn't mind extending the
> > guidelines to adopt the second kind.
>
> Yeah. Helpers that are file-scope static may not matter, but we may
> want to standardise public helpers like this one, especially the ones
> named TYPEOFTHETHING_free().
Agreed. We nowadays already have coding guidelines around how to name
such functions (release vs clear vs free), and we already document
expected semantics there. It would make sense to extend that and
document that a free function should work alright with a NULL pointer.
Patrick
next prev parent reply other threads:[~2026-12-02 8:38 UTC|newest]
Thread overview: 35+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-20 12:02 [PATCH 0/6] packfile: some lifecycle improvements Patrick Steinhardt
2026-11-20 12:02 ` [PATCH 1/6] builtin/fast-import: stop reporting packfile statistics Patrick Steinhardt
2026-11-24 20:43 ` Junio C Hamano
2026-12-02 8:38 ` Patrick Steinhardt
2026-11-24 22:19 ` brian m. carlson
2026-12-02 8:38 ` Patrick Steinhardt
2026-11-26 14:15 ` Toon Claes
2026-11-20 12:02 ` [PATCH 2/6] packfile: rename lifecycle functions Patrick Steinhardt
2026-11-24 23:47 ` Junio C Hamano
2026-12-02 8:38 ` Patrick Steinhardt
2026-11-26 14:16 ` Toon Claes
2026-12-02 8:38 ` Patrick Steinhardt
2026-11-20 12:02 ` [PATCH 3/6] packfile: inline `open_packed_git_1()` Patrick Steinhardt
2026-11-24 22:04 ` Junio C Hamano
2026-11-26 14:16 ` Toon Claes
2026-12-02 8:38 ` Patrick Steinhardt
2026-11-26 14:16 ` Toon Claes
2026-11-26 20:39 ` Junio C Hamano
2026-11-20 12:02 ` [PATCH 4/6] packfile: introduce function to free a packfile Patrick Steinhardt
2026-11-24 21:34 ` Junio C Hamano
2026-11-26 14:13 ` Toon Claes
2026-11-26 20:41 ` Junio C Hamano
2026-12-02 8:38 ` Patrick Steinhardt [this message]
2026-12-02 8:38 ` Patrick Steinhardt
2026-11-20 12:02 ` [PATCH 5/6] packfile: maintain process-wide limits globally Patrick Steinhardt
2026-11-24 23:24 ` Junio C Hamano
2026-12-02 8:38 ` Patrick Steinhardt
2026-11-26 15:11 ` Toon Claes
2026-12-02 8:38 ` Patrick Steinhardt
2026-11-20 12:02 ` [PATCH 6/6] packfile: skip closing packs marked as do-not-close Patrick Steinhardt
2026-11-24 21:14 ` Junio C Hamano
2026-11-26 15:26 ` Toon Claes
2026-11-26 19:56 ` Junio C Hamano
2026-12-02 8:38 ` Patrick Steinhardt
2026-11-26 15:29 ` [PATCH 0/6] packfile: some lifecycle improvements Toon Claes
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=aw_ZAY6k6CgHZQPc@pks.im \
--to=ps@pks.im \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=toon@iotcl.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.