From: Taylor Blau <me@ttaylorr.com>
To: Junio C Hamano <gitster@pobox.com>
Cc: Jeff King <peff@peff.net>, git@vger.kernel.org
Subject: Re: [PATCH] git-compat-util.h: introduce CALLOC(x)
Date: Tue, 6 Dec 2022 21:38:02 -0500 [thread overview]
Message-ID: <Y4/8ilFBfGApR8YR@nand.local> (raw)
In-Reply-To: <xmqqv8mpnwjp.fsf@gitster.g>
On Tue, Dec 06, 2022 at 10:35:54AM +0900, Junio C Hamano wrote:
> Jeff King <peff@peff.net> writes:
>
> > So you can think of "allocate this one element and zero it" as "calloc,
> > but don't multiply" or as "malloc, but zero". Naming it CALLOC() is
> > thinking of it as the former. If we think of it as the latter it could
> > perhaps be MALLOCZ() or something. I don't know if that name is too
> > subtle or not. We have xmemdupz(), which is basically the same thing;
> > it's only a zero-terminator, but that is because we are writing non-zero
> > bytes in the rest of it. Mostly I'd worry that it is easy to glance past
> > the "Z".
>
> I think the name for the former would be CALLOC_ONE(), as I would
> rephrase it as "calloc, but just one element". I agree MALLOCZ()
> would be fine for the other interpretation, and I do not have much
> problem as much problem with the name as calling it CALLOC().
Between CALLOC_ONE() and MALLOCZ(), I prefer the latter for brevity. But
between that and CALLOC(), I prefer the latter, since "CALLOC()" reminds
me of the zero-initialization of calloc()-proper, and the "Z" in
"MALLOCZ()" feels easy-ish to miss.
Thanks,
Taylor
next prev parent reply other threads:[~2022-12-07 2:38 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-12-05 18:54 [PATCH] git-compat-util.h: introduce CALLOC(x) Taylor Blau
2022-12-05 21:01 ` René Scharfe
2022-12-05 22:36 ` Taylor Blau
2022-12-05 23:12 ` Ævar Arnfjörð Bjarmason
2022-12-06 1:47 ` Jeff King
2022-12-06 1:58 ` Ævar Arnfjörð Bjarmason
2022-12-07 6:02 ` Jeff King
2022-12-07 2:36 ` Taylor Blau
2022-12-07 2:34 ` Taylor Blau
2022-12-07 3:17 ` Ævar Arnfjörð Bjarmason
2022-12-06 1:43 ` Jeff King
2022-12-07 2:29 ` Taylor Blau
2022-12-07 3:51 ` Ævar Arnfjörð Bjarmason
2022-12-05 23:57 ` Junio C Hamano
2022-12-06 0:29 ` Taylor Blau
2022-12-06 1:21 ` Jeff King
2022-12-06 1:35 ` Junio C Hamano
2022-12-07 2:38 ` Taylor Blau [this message]
2022-12-07 6:08 ` Jeff King
2022-12-06 2:12 ` Ævar Arnfjörð Bjarmason
2022-12-07 6:06 ` Jeff King
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=Y4/8ilFBfGApR8YR@nand.local \
--to=me@ttaylorr.com \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=peff@peff.net \
/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.