Dynamic hash table size (with static has load)

Wayne Davison wayned at samba.org
Sun Feb 26 16:12:30 GMT 2006


On Sun, Feb 26, 2006 at 10:34:25AM +0200, Shachar Shemesh wrote:
> A line of credit would have been nice :-)

Sure 'nuff.

> I think we can save the memory when handling smaller files.

Yeah, I've been leaning the same way, so I like your change here.  I
also like your reason for realloc() being the wrong choice (since we
don't need any of the old memory copied).

> 1. I guess it's a matter of taste, but when you want to make sure a type
> has enough states to keep count of the number of elements in an array, I
> prefer using "size_t" to "int32".

Since all the indexes into the array are all int32 values (and that's
not going to be changed easily), I like the size of the array to use the
same type.

> 2. In "sum_buf", sum1 is defined to be unsigned. It seems dangerous to
> me to hash it into a signed index, even if it's almost guarenteed to be ok.

The result is an index into the array (and can be no larger than the max
size of the array), so I like to use the same type as the other indexes.

> I also did some style suggestions (use sizeof(sum_table[0]) instead of
> sizeof(int32), initialize the chain element to -1 instead of 0, as
> that's the "null" value).

The latter was a bug, since it results in the 0th element being checked
in every chain -- good catch.

Thanks for your input!  I've updated the version of the patch in CVS
(with the same URL as before).

..wayne..


More information about the rsync mailing list