From: Jeff King <peff@peff.net>
To: Junio C Hamano <gitster@pobox.com>
Cc: git@vger.kernel.org
Subject: Re: [PATCH] pathspec: rename free_pathspec() to clear_pathspec()
Date: Thu, 2 Jun 2016 17:29:38 -0400 [thread overview]
Message-ID: <20160602212938.GA13071@sigill.intra.peff.net> (raw)
In-Reply-To: <xmqq60trthl4.fsf@gitster.mtv.corp.google.com>
On Thu, Jun 02, 2016 at 02:18:47PM -0700, Junio C Hamano wrote:
> The function takes a pointer to a pathspec structure, and releases
> the resources held by it, but does not free() the structure itself.
> Such a function should be called "clear", not "free".
Hmm, makes sense, though...
> * This is just something I noticed. Among the hits in
>
> $ git grep free_ \*.h
>
> I think free_notes() is also a candidate for such renaming, but
> because we are not actively working on that subsystem, we may
> want to leave that dog sleeping to avoid unnecessary code churn.
> The same for diff_free_filespec_data(), for which a better name
> would have been diff_filespec_clear().
I think diff_filespec_clear() would not be quite right. It is freeing
only the allocated _data_, but leaving the other portions intact.
Generally our _clear() functions reset the object back to an initial
state, from which it can be reused. I don't see that as a big problem
because there is an other object for the verb "free" here: "data". We
are just freeing its data, but the rest of the object remains intact and
we may fill in the data again later.
But I think pathspec is in similar boat; it has not been cleared back to
its initial state. But it is in a much _worse_ state than the filespec,
which you can continue to use. It is in a totally broken state where
"nr" does not correspond to the actual number of items, the has_wildcard
flag is bogus, etc.
So I think it would be OK to move it to "clear", but we should probably
also zero the whole thing, too.
-Peff
next prev parent reply other threads:[~2016-06-02 21:29 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-06-02 21:18 [PATCH] pathspec: rename free_pathspec() to clear_pathspec() Junio C Hamano
2016-06-02 21:29 ` Jeff King [this message]
2016-06-02 22:03 ` Junio C Hamano
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=20160602212938.GA13071@sigill.intra.peff.net \
--to=peff@peff.net \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.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 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 NNTP newsgroup(s).