slimina / memagent

Automatically exported from code.google.com/p/memagent
0 stars 0 forks source link

static unsigned int ketama_hashi( const char* inString ) not correct #6

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
ketama_hashi return unsigned int ,but in this function you made the ret 
unsigned char.
so the return just are the lower 4 bits of the (int) ret;
static unsigned int ketama_hashi( const char* inString )
{
    unsigned char digest[16], ret;
    ketama_md5_digest( inString, digest );
    ret = ( digest[3] << 24 )
                        | ( digest[2] << 16 )
                        | ( digest[1] <<  8 )
                        |   digest[0];

    return ret;
}
in file ketama.c 355 line.
---------------------------------------------------------
so this make the balance of memcaches fail.

Original issue reported on code.google.com by wangmh....@gmail.com on 28 Feb 2011 at 3:02

GoogleCodeExporter commented 9 years ago
< unsigned char digest[16], ret;
---
> unsigned char digest[16];
> unsigned int ret;

是否应该这么改?

Original comment by Liny...@gmail.com on 28 Mar 2011 at 10:05