* @param n Number of elements in the Hash table
* @retval num Cryptographic hash of the string
*/
-static unsigned int gen_string_hash(union HashKey key, unsigned int n)
+static size_t gen_string_hash(union HashKey key, size_t n)
{
- unsigned int h = 0;
+ size_t h = 0;
unsigned char *s = (unsigned char *) key.strkey;
while (*s)
* @param n Number of elements in the Hash table
* @retval num Cryptographic hash of the string
*/
-static unsigned int gen_case_string_hash(union HashKey key, unsigned int n)
+static size_t gen_case_string_hash(union HashKey key, size_t n)
{
- unsigned int h = 0;
+ size_t h = 0;
unsigned char *s = (unsigned char *) key.strkey;
while (*s)
* @param n Number of elements in the Hash table
* @retval num Cryptographic hash of the integer
*/
-static unsigned int gen_int_hash(union HashKey key, unsigned int n)
+static size_t gen_int_hash(union HashKey key, size_t n)
{
return key.intkey % n;
}
* The Hash table can contain more elements than nelem, but they will be
* chained together.
*/
-static struct Hash *new_hash(int nelem)
+static struct Hash *new_hash(size_t nelem)
{
struct Hash *table = mutt_mem_calloc(1, sizeof(struct Hash));
if (nelem == 0)
* @param flags Flags, e.g. #MUTT_HASH_STRCASECMP
* @retval ptr New Hash table
*/
-struct Hash *mutt_hash_create(int nelem, int flags)
+struct Hash *mutt_hash_create(size_t nelem, int flags)
{
struct Hash *table = new_hash(nelem);
if (flags & MUTT_HASH_STRCASECMP)
* @param flags Flags, e.g. #MUTT_HASH_ALLOW_DUPS
* @retval ptr New Hash table
*/
-struct Hash *mutt_hash_int_create(int nelem, int flags)
+struct Hash *mutt_hash_int_create(size_t nelem, int flags)
{
struct Hash *table = new_hash(nelem);
table->gen_hash = gen_int_hash;
return;
pptr = *ptr;
- for (int i = 0; i < pptr->nelem; i++)
+ for (size_t i = 0; i < pptr->nelem; i++)
{
for (elem = pptr->table[i]; elem;)
{
*/
struct Hash
{
- int nelem;
+ size_t nelem;
bool strdup_keys : 1; /**< if set, the key->strkey is strdup'ed */
bool allow_dups : 1; /**< if set, duplicate keys are allowed */
struct HashElem **table;
- unsigned int (*gen_hash)(union HashKey, unsigned int);
+ size_t (*gen_hash)(union HashKey, size_t);
int (*cmp_key)(union HashKey, union HashKey);
hash_destructor destroy;
intptr_t dest_data;
#define MUTT_HASH_STRDUP_KEYS (1 << 1) /**< make a copy of the keys */
#define MUTT_HASH_ALLOW_DUPS (1 << 2) /**< allow duplicate keys to be inserted */
-struct Hash * mutt_hash_create(int nelem, int flags);
+struct Hash * mutt_hash_create(size_t nelem, int flags);
void mutt_hash_delete(struct Hash *table, const char *strkey, const void *data);
void mutt_hash_destroy(struct Hash **ptr);
struct HashElem *mutt_hash_find_bucket(const struct Hash *table, const char *strkey);
struct HashElem *mutt_hash_insert(struct Hash *table, const char *strkey, void *data);
void mutt_hash_set_destructor(struct Hash *table, hash_destructor fn, intptr_t fn_data);
struct HashElem *mutt_hash_typed_insert(struct Hash *table, const char *strkey, int type, void *data);
-struct Hash * mutt_hash_int_create(int nelem, int flags);
+struct Hash * mutt_hash_int_create(size_t nelem, int flags);
void mutt_hash_int_delete(struct Hash *table, unsigned int intkey, const void *data);
void * mutt_hash_int_find(const struct Hash *table, unsigned int intkey);
struct HashElem *mutt_hash_int_insert(struct Hash *table, unsigned int intkey, void *data);
*/
struct HashWalkState
{
- int index;
+ size_t index;
struct HashElem *last;
};