From: Richard Russon Date: Sat, 2 Mar 2019 12:21:07 +0000 (+0000) Subject: add typedef for HashFlags X-Git-Tag: 2019-10-25~346^2~3 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=d680b5c54a24c2b16a582bd9be8b827bc2805200;p=neomutt add typedef for HashFlags --- diff --git a/init.c b/init.c index 36d7c71a6..c2031f9b0 100644 --- a/init.c +++ b/init.c @@ -3032,7 +3032,7 @@ int mutt_init(bool skip_sys_rc, struct ListHead *commands) ReverseAliases = mutt_hash_new(1031, MUTT_HASH_STRCASECMP | MUTT_HASH_STRDUP_KEYS | MUTT_HASH_ALLOW_DUPS); TagTransforms = mutt_hash_new(64, MUTT_HASH_STRCASECMP); - TagFormats = mutt_hash_new(64, 0); + TagFormats = mutt_hash_new(64, MUTT_HASH_NO_FLAGS); mutt_menu_init(); mutt_buffer_pool_init(); diff --git a/mutt/hash.c b/mutt/hash.c index f9cc89425..e954ac1cb 100644 --- a/mutt/hash.c +++ b/mutt/hash.c @@ -272,10 +272,10 @@ static void union_hash_delete(struct Hash *table, union HashKey key, const void /** * mutt_hash_new - Create a new Hash table (with string keys) * @param nelem Number of elements it should contain - * @param flags Flags, e.g. #MUTT_HASH_STRCASECMP + * @param flags Flags, see #HashFlags * @retval ptr New Hash table */ -struct Hash *mutt_hash_new(size_t nelem, int flags) +struct Hash *mutt_hash_new(size_t nelem, HashFlags flags) { struct Hash *table = new_hash(nelem); if (flags & MUTT_HASH_STRCASECMP) @@ -298,10 +298,10 @@ struct Hash *mutt_hash_new(size_t nelem, int flags) /** * mutt_hash_int_new - Create a new Hash table (with integer keys) * @param nelem Number of elements it should contain - * @param flags Flags, e.g. #MUTT_HASH_ALLOW_DUPS + * @param flags Flags, see #HashFlags * @retval ptr New Hash table */ -struct Hash *mutt_hash_int_new(size_t nelem, int flags) +struct Hash *mutt_hash_int_new(size_t nelem, HashFlags flags) { struct Hash *table = new_hash(nelem); table->gen_hash = gen_int_hash; diff --git a/mutt/hash.h b/mutt/hash.h index 086cce851..dbd980f28 100644 --- a/mutt/hash.h +++ b/mutt/hash.h @@ -70,10 +70,11 @@ struct Hash intptr_t hash_data; ///< Data to pass to the elem_free() function }; -/* flags for mutt_hash_new() */ -#define MUTT_HASH_STRCASECMP (1 << 0) /**< use strcasecmp() to compare keys */ -#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 */ +typedef uint8_t HashFlags; ///< Flags for mutt_hash_new(), e.g. #MUTT_HASH_STRCASECMP +#define MUTT_HASH_NO_FLAGS 0 ///< No flags are set +#define MUTT_HASH_STRCASECMP (1 << 0) ///< use strcasecmp() to compare keys +#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 void mutt_hash_delete(struct Hash *table, const char *strkey, const void *data); struct HashElem *mutt_hash_find_bucket(const struct Hash *table, const char *strkey); @@ -84,8 +85,8 @@ struct HashElem *mutt_hash_insert(struct Hash *table, const char *strkey, void * 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 Hash * mutt_hash_int_new(size_t nelem, int flags); -struct Hash * mutt_hash_new(size_t nelem, int flags); +struct Hash * mutt_hash_int_new(size_t nelem, HashFlags flags); +struct Hash * mutt_hash_new(size_t nelem, HashFlags flags); void mutt_hash_set_destructor(struct Hash *table, hashelem_free_t fn, intptr_t fn_data); struct HashElem *mutt_hash_typed_insert(struct Hash *table, const char *strkey, int type, void *data);