Messages in this thread | | | Subject | RE: [PATCH v6] hashtable: introduce a small and naive hashtable | Date | Wed, 26 Sep 2012 14:45:53 +0100 | From | "David Laight" <> |
| |
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. Also, should the loop have a 'break' in it?
David
| |