All of lore.kernel.org
 help / color / mirror / Atom feed
From: Sasha Levin <levinsasha928@gmail.com>
To: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Cc: torvalds@linux-foundation.org, tj@kernel.org,
	linux-kernel@vger.kernel.org, rostedt@goodmis.org,
	ebiederm@xmission.com, josh@joshtriplett.org,
	David.Laight@ACULAB.COM, palves@redhat.com, rmallon@gmail.com,
	bfields@fieldses.org
Subject: Re: [PATCH v4] hashtable: introduce a small and naive hashtable
Date: Mon, 10 Sep 2012 14:18:51 +0200	[thread overview]
Message-ID: <504DDAAB.7090001@gmail.com> (raw)
In-Reply-To: <20120910024813.GA32008@Krystal>

On 09/10/2012 04:48 AM, Mathieu Desnoyers wrote:
> * Sasha Levin (levinsasha928@gmail.com) wrote:
>> +#define hash_init(hashtable)							\
>> +({										\
>> +	int __i;								\
>> +										\
>> +	for (__i = 0; __i < HASH_BITS(hashtable); __i++)			\
>> +		INIT_HLIST_HEAD(hashtable + __i);				\
> 
> I suspect that hashtable will be a pointer, and you use the "+" operator
> to do an offset on this pointer. Any thought on using:
> 
>             INIT_HLIST_HEAD(&hashtable[__i]);
> 
> instead ? It would provide the same result, but would ensure that the
> user is indeed passing a pointer, and not an integer.

It also looks nicer :)

> Also, why isn't it a static inline ? I'm probably missing something. If
> there is a reason why it needs to stay a #define, please document it in
> the comment.

It's a define because it needs to get the size of the hashtable.

I'll document that.


Thanks,
Sasha

      reply	other threads:[~2012-09-10 12:18 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-09-09 12:52 [PATCH v4] hashtable: introduce a small and naive hashtable Sasha Levin
2012-09-10  2:48 ` Mathieu Desnoyers
2012-09-10 12:18   ` Sasha Levin [this message]

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=504DDAAB.7090001@gmail.com \
    --to=levinsasha928@gmail.com \
    --cc=David.Laight@ACULAB.COM \
    --cc=bfields@fieldses.org \
    --cc=ebiederm@xmission.com \
    --cc=josh@joshtriplett.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mathieu.desnoyers@efficios.com \
    --cc=palves@redhat.com \
    --cc=rmallon@gmail.com \
    --cc=rostedt@goodmis.org \
    --cc=tj@kernel.org \
    --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 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.