<<< Date Index >>>     <<< Thread Index >>>

Re: mutt: 11 new changesets



On 2009-01-03 13:57:03 -0800, Brendan Cully wrote:
> Sorry, I forgot to reply to this earlier. I think since h is now
> unsigned, h * SOMEPRIME is unsigned and so (h * SOMEPRIME) % n will
> also be signed. (n should never be negative -- I am not sure why it
          ^^^^^^ unsigned
> isn't typed as unsigned).

Perhaps consistency between types? Everywhere else in the code,
the type int seems to be used for hashes (not unsigned int).
Indeed one still has:

In hash.h:

typedef struct
{
  int nelem;
  struct hash_elem **table;
}
HASH;

In hash.c:

HASH *hash_create (int nelem)

and

  int h;
[...]
  h = hash_string ((unsigned char *) key, table->nelem);

In thread.c:

  int hash;
[...]
    hash = hash_string ((unsigned char *) subjects->data,
                        ctx->subj_hash->nelem);

Also, with the current (lack of) comments in the code, it is a bit
difficult to see whether there can be a problem. For instance, say
that the hash_string() function returns a value between 0 and n-1.

-- 
Vincent Lefèvre <vincent@xxxxxxxxxx> - Web: <http://www.vinc17.org/>
100% accessible validated (X)HTML - Blog: <http://www.vinc17.org/blog/>
Work: CR INRIA - computer arithmetic / Arenaire project (LIP, ENS-Lyon)