ngx_hash_init

Maxim Dounin mdounin at mdounin.ru
Mon Jan 12 15:19:06 UTC 2015


Hello!

On Thu, Jan 08, 2015 at 12:34:39PM -0500, Ian Labbé wrote:

> Hello,
> 
> Maybe i am not in the right mailing list, please refer me to the good one
> if i am at the wrong one.
> 
> I just want to understand the " for (size = start; size <= hinit->max_size;
> size++) " loop in the ngx_hash_init function.
> I do not understand what "size", "key" and "test[key]" mean in first place.

The ngx_hash_init() functions tries to build a hash by using a 
varying number of buckets.  The "size" variable corresponds to the 
number of buckets we test at the current loop iteration.  For each 
size we iterate over all hash items to check how buckets will be 
("key" is a bucket number for a given hash item, "test[key]" 
stores how many bytes will be stored in the bucket).

-- 
Maxim Dounin
http://nginx.org/



More information about the nginx-devel mailing list