]> granicus.if.org Git - neomutt/commitdiff
add typedef for HashFlags
authorRichard Russon <rich@flatcap.org>
Sat, 2 Mar 2019 12:21:07 +0000 (12:21 +0000)
committerRichard Russon <rich@flatcap.org>
Sat, 2 Mar 2019 13:12:59 +0000 (13:12 +0000)
init.c
mutt/hash.c
mutt/hash.h

diff --git a/init.c b/init.c
index 36d7c71a61b29ed9b6a878d8cf6f9e126d4f9e7b..c2031f9b0991b380bef698d96bcfd53b0b5972e5 100644 (file)
--- 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();
index f9cc89425d10dc631bdb595dcb4ba2fe390f23a0..e954ac1cb8f1ed5a00b3f701131d5fb5dd89f81a 100644 (file)
@@ -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;
index 086cce8519cfcf6190f9dcf6db2998218ab08469..dbd980f28a3f4adfb865895f90ef06996b35a892 100644 (file)
@@ -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);