Hello everyone, I'm having a little problem with numhash tables in 64 bit
system:

the problem seems to be in this function:

long numhash_get_char_key(char *nro)
{
   int len;
   long key;
   if (!nro) return -1;
   len = strlen(nro);

   if (len > precision)
   key = atoi(nro + len -precision);
   else
   key = atoi(nro);

   return key;
}


precision should be 9 if size of long is egual (or bigger) to 4 and 18 if
it's equal (or bigger) than  8, for my system sizeof long is 8 so precision
is 18, the problem comes with msisdn of 7123999999 (value of nro), the size
of it is 10, so all of it is taken for making the hash, when it's passed to
atoi, atoi returns -1465934593 maybe due to the fact that int max limit is
2147483647 (according to /usr/include/limits.h in my system), I change all
atoi calls in numhash.c to atol and it seems to work right...

comments appreciated :)

thanks


PS: in 32 bit systems it works fine, since the maximum possible value is
99999999 who is inside the bounds of max int limit...

Reply via email to