From: Jeff King <peff@peff.net>
To: "Ævar Arnfjörð Bjarmason" <avarab@gmail.com>
Cc: Jakub Narebski <jnareb@gmail.com>,
Stephen Boyd <bebarino@gmail.com>,
git@vger.kernel.org, Junio C Hamano <gitster@pobox.com>,
Linus Torvalds <torvalds@linux-foundation.org>
Subject: Re: [PATCH] hash: Remove useless init_hash()
Date: Tue, 27 Jul 2010 15:49:46 -0400 [thread overview]
Message-ID: <20100727194946.GA11682@coredump.intra.peff.net> (raw)
In-Reply-To: <AANLkTimrKzDOlJzGpzaHWF24lwfr67bmh8RrKj6uMYWB@mail.gmail.com>
On Tue, Jul 27, 2010 at 10:36:09AM +0000, Ævar Arnfjörð Bjarmason wrote:
> >> -static inline void init_hash(struct hash_table *table)
> >> -{
> >> - table->size = 0;
> >> - table->nr = 0;
> >> - table->array = NULL;
> >> -}
> >
> > *This* could be replaced by memset.
>
> No it couldn't? The second argument to memset is just an int, so
> setting the memory area to 0 isn't portable to systems where the
> representation of NULL isn't "0".
>
> (It's early so I may be misremembering my C..)
You're remembering your C correctly. It isn't portable, but it is so
unlikely on modern machines that we simply don't care (and you will see
memsets zero-ing pointers like this all through the git code, so this is
certainly not introducing anything new).
That being said, I agree with the comments that removing init_hash
actually makes the code _less_ readable. You could just replace these
three lines with a memset, but why? It's just code churn.
-Peff
next prev parent reply other threads:[~2010-07-27 19:49 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-07-27 5:36 [PATCH] hash: Remove useless init_hash() Stephen Boyd
2010-07-27 10:30 ` Jakub Narebski
2010-07-27 10:36 ` Ævar Arnfjörð Bjarmason
2010-07-27 19:49 ` Jeff King [this message]
2010-07-27 19:58 ` Ævar Arnfjörð Bjarmason
2010-07-28 7:33 ` Stephen Boyd
2010-07-27 15:55 ` Linus Torvalds
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=20100727194946.GA11682@coredump.intra.peff.net \
--to=peff@peff.net \
--cc=avarab@gmail.com \
--cc=bebarino@gmail.com \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=jnareb@gmail.com \
--cc=torvalds@linux-foundation.org \
/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).