All of lore.kernel.org
 help / color / mirror / Atom feed
* ulogd - hashtable_find function - question
@ 2012-08-08 14:27 Gomathivinayagam Muthuvinayagam
  2012-08-08 14:50 ` Steffen Heil (Mailinglisten)
  0 siblings, 1 reply; 3+ messages in thread
From: Gomathivinayagam Muthuvinayagam @ 2012-08-08 14:27 UTC (permalink / raw)
  To: netfilter

I'm going through ulogd hash.c code. I have a question on
hashtable_find function.

struct hashtable_node *
hashtable_find(const struct hashtable *table, const void *data, int id)
{
	struct llist_head *e;
	struct hashtable_node *n;

	llist_for_each(e, &table->members[id]) {
		n = llist_entry(e, struct hashtable_node, head);
		if (table->compare(n, data)) {
			return n;
		}
	}
	errno = ENOENT;
	return NULL;
}

In the above function, you are passing the id which is the hash value.
Basically it allows you to find the hashnode in the hashtable.
But why we are again calling  compare function and check the
equivalence of the values? Is the id itself not enough?

Thanks & Regards,

^ permalink raw reply	[flat|nested] 3+ messages in thread

* RE: ulogd - hashtable_find function - question
  2012-08-08 14:27 ulogd - hashtable_find function - question Gomathivinayagam Muthuvinayagam
@ 2012-08-08 14:50 ` Steffen Heil (Mailinglisten)
  2012-08-08 15:20   ` Gomathivinayagam Muthuvinayagam
  0 siblings, 1 reply; 3+ messages in thread
From: Steffen Heil (Mailinglisten) @ 2012-08-08 14:50 UTC (permalink / raw)
  To: Gomathivinayagam Muthuvinayagam, netfilter

[-- Attachment #1: Type: text/plain, Size: 1320 bytes --]

Hi

This is for hash collisions:
What if 2 values have the same hash value?

Regards,
   Steffen


> -----Original Message-----
> From: netfilter-owner@vger.kernel.org [mailto:netfilter-
> owner@vger.kernel.org] On Behalf Of Gomathivinayagam Muthuvinayagam
> Sent: Wednesday, August 08, 2012 4:28 PM
> To: netfilter@vger.kernel.org
> Subject: ulogd - hashtable_find function - question
> 
> I'm going through ulogd hash.c code. I have a question on hashtable_find
> function.
> 
> struct hashtable_node *
> hashtable_find(const struct hashtable *table, const void *data, int id) {
> 	struct llist_head *e;
> 	struct hashtable_node *n;
> 
> 	llist_for_each(e, &table->members[id]) {
> 		n = llist_entry(e, struct hashtable_node, head);
> 		if (table->compare(n, data)) {
> 			return n;
> 		}
> 	}
> 	errno = ENOENT;
> 	return NULL;
> }
> 
> In the above function, you are passing the id which is the hash value.
> Basically it allows you to find the hashnode in the hashtable.
> But why we are again calling  compare function and check the equivalence
of
> the values? Is the id itself not enough?
> 
> Thanks & Regards,
> --
> To unsubscribe from this list: send the line "unsubscribe netfilter" in
the body
> of a message to majordomo@vger.kernel.org More majordomo info at
> http://vger.kernel.org/majordomo-info.html

[-- Attachment #2: smime.p7s --]
[-- Type: application/pkcs7-signature, Size: 6559 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: ulogd - hashtable_find function - question
  2012-08-08 14:50 ` Steffen Heil (Mailinglisten)
@ 2012-08-08 15:20   ` Gomathivinayagam Muthuvinayagam
  0 siblings, 0 replies; 3+ messages in thread
From: Gomathivinayagam Muthuvinayagam @ 2012-08-08 15:20 UTC (permalink / raw)
  To: Steffen Heil (Mailinglisten); +Cc: netfilter

Thank you,

In this function jhash(const void *key, u32 length, u32 initval), what
is the purpose of initval?

Thanks & Regards,




On Wed, Aug 8, 2012 at 7:50 AM, Steffen Heil (Mailinglisten)
<lists@steffen-heil.de> wrote:
> Hi
>
> This is for hash collisions:
> What if 2 values have the same hash value?
>
> Regards,
>    Steffen
>
>
>> -----Original Message-----
>> From: netfilter-owner@vger.kernel.org [mailto:netfilter-
>> owner@vger.kernel.org] On Behalf Of Gomathivinayagam Muthuvinayagam
>> Sent: Wednesday, August 08, 2012 4:28 PM
>> To: netfilter@vger.kernel.org
>> Subject: ulogd - hashtable_find function - question
>>
>> I'm going through ulogd hash.c code. I have a question on hashtable_find
>> function.
>>
>> struct hashtable_node *
>> hashtable_find(const struct hashtable *table, const void *data, int id) {
>>       struct llist_head *e;
>>       struct hashtable_node *n;
>>
>>       llist_for_each(e, &table->members[id]) {
>>               n = llist_entry(e, struct hashtable_node, head);
>>               if (table->compare(n, data)) {
>>                       return n;
>>               }
>>       }
>>       errno = ENOENT;
>>       return NULL;
>> }
>>
>> In the above function, you are passing the id which is the hash value.
>> Basically it allows you to find the hashnode in the hashtable.
>> But why we are again calling  compare function and check the equivalence
> of
>> the values? Is the id itself not enough?
>>
>> Thanks & Regards,
>> --
>> To unsubscribe from this list: send the line "unsubscribe netfilter" in
> the body
>> of a message to majordomo@vger.kernel.org More majordomo info at
>> http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2012-08-08 15:20 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-08-08 14:27 ulogd - hashtable_find function - question Gomathivinayagam Muthuvinayagam
2012-08-08 14:50 ` Steffen Heil (Mailinglisten)
2012-08-08 15:20   ` Gomathivinayagam Muthuvinayagam

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.