Skip to content

Commit

Permalink
add typedef for HashFlags
Browse files Browse the repository at this point in the history
  • Loading branch information
flatcap committed Mar 2, 2019
1 parent 2f5a75b commit d680b5c
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 11 deletions.
2 changes: 1 addition & 1 deletion init.c
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
8 changes: 4 additions & 4 deletions mutt/hash.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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;
Expand Down
13 changes: 7 additions & 6 deletions mutt/hash.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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);

Expand Down

0 comments on commit d680b5c

Please sign in to comment.