On Wed, 2012-09-26 at 14:45 +0100, David Laight wrote:
> Amazing how something simple gets lots of comments and versions :-)
>
> > ...
> > + * This has to be a macro since HASH_BITS() will not work on pointers since
> > + * it calculates the size during preprocessing.
> > + */
> > +#define hash_empty(hashtable)
> > \
> > +({
> > \
> > + int __i;
> > \
> > + bool __ret = true;
> > \
> > +
> > \
> > + for (__i = 0; __i < HASH_SIZE(hashtable); __i++)
> > \
> > + if (!hlist_empty(&hashtable[__i]))
> > \
> > + __ret = false;
> > \
> > +
> > \
> > + __ret;
> > \
> > +})
>
> Actually you could have a #define that calls a function
> passing in the address and size.
Probably would be cleaner to do so.
> Also, should the loop have a 'break' in it?
Yeah it should, and could do:
for (i = 0; i < HASH_SIZE(hashtable); i++)
if (!hlist_empty(&hashtable[i]))
break;
return i < HASH_SIZE(hashtable);
-- Steve
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/