From: Richard Russon Date: Thu, 16 Nov 2017 01:36:11 +0000 (+0000) Subject: rename hash functions X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=cd49d502e7623954427ae0fa7a6b51f39d75caf3;p=neomutt rename hash functions --- diff --git a/alias.c b/alias.c index 38234d0a8..12a929ed4 100644 --- a/alias.c +++ b/alias.c @@ -459,7 +459,7 @@ struct Address *alias_reverse_lookup(struct Address *a) if (!a || !a->mailbox) return NULL; - return hash_find(ReverseAliases, a->mailbox); + return mutt_hash_find(ReverseAliases, a->mailbox); } void mutt_alias_add_reverse(struct Alias *t) @@ -476,7 +476,7 @@ void mutt_alias_add_reverse(struct Alias *t) for (ap = t->addr; ap; ap = ap->next) { if (!ap->group && ap->mailbox) - hash_insert(ReverseAliases, ap->mailbox, ap); + mutt_hash_insert(ReverseAliases, ap->mailbox, ap); } } @@ -493,7 +493,7 @@ void mutt_alias_delete_reverse(struct Alias *t) for (ap = t->addr; ap; ap = ap->next) { if (!ap->group && ap->mailbox) - hash_delete(ReverseAliases, ap->mailbox, ap, NULL); + mutt_hash_delete(ReverseAliases, ap->mailbox, ap, NULL); } } diff --git a/curs_main.c b/curs_main.c index 9d6e67c86..687f51e64 100644 --- a/curs_main.c +++ b/curs_main.c @@ -1255,7 +1255,7 @@ int mutt_index_menu(void) } if (!Context->id_hash) Context->id_hash = mutt_make_id_hash(Context); - hdr = hash_find(Context->id_hash, buf); + hdr = mutt_hash_find(Context->id_hash, buf); if (hdr) { if (hdr->virtual != -1) @@ -1321,7 +1321,7 @@ int mutt_index_menu(void) struct ListNode *ref; STAILQ_FOREACH(ref, &CURHDR->env->references, entries) { - if (hash_find(Context->id_hash, ref->data) == NULL) + if (mutt_hash_find(Context->id_hash, ref->data) == NULL) { rc2 = nntp_check_msgid(Context, ref->data); if (rc2 < 0) @@ -1361,7 +1361,7 @@ int mutt_index_menu(void) } /* if the root message was retrieved, move to it */ - hdr = hash_find(Context->id_hash, buf); + hdr = mutt_hash_find(Context->id_hash, buf); if (hdr) menu->current = hdr->virtual; diff --git a/group.c b/group.c index db7d569bc..909d128c0 100644 --- a/group.c +++ b/group.c @@ -38,13 +38,13 @@ struct Group *mutt_pattern_group(const char *k) if (!k) return 0; - p = hash_find(Groups, k); + p = mutt_hash_find(Groups, k); if (!p) { mutt_debug(2, "mutt_pattern_group: Creating group %s.\n", k); p = safe_calloc(1, sizeof(struct Group)); p->name = safe_strdup(k); - hash_insert(Groups, p->name, p); + mutt_hash_insert(Groups, p->name, p); } return p; @@ -54,7 +54,7 @@ static void group_remove(struct Group *g) { if (!g) return; - hash_delete(Groups, g->name, g, NULL); + mutt_hash_delete(Groups, g->name, g, NULL); rfc822_free_address(&g->as); mutt_free_regex_list(&g->rs); FREE(&g->name); diff --git a/hdrline.c b/hdrline.c index 1b89a450c..0b7cadc82 100644 --- a/hdrline.c +++ b/hdrline.c @@ -811,7 +811,7 @@ static const char *hdr_format_str(char *dest, size_t destlen, size_t col, int co format[1] = *src; format[2] = 0; - tag = hash_find(TagFormats, format); + tag = mutt_hash_find(TagFormats, format); if (tag) { tags = driver_tags_get_transformed_for(tag, &hdr->tags); @@ -828,7 +828,7 @@ static const char *hdr_format_str(char *dest, size_t destlen, size_t col, int co format[1] = *prefix; format[2] = 0; - tag = hash_find(TagFormats, format); + tag = mutt_hash_find(TagFormats, format); if (tag) { tags = driver_tags_get_transformed_for(tag, &hdr->tags); diff --git a/header.c b/header.c index 53e681ee8..01b8a252c 100644 --- a/header.c +++ b/header.c @@ -228,14 +228,14 @@ static void label_ref_dec(struct Context *ctx, char *label) struct HashElem *elem = NULL; uintptr_t count; - elem = hash_find_elem(ctx->label_hash, label); + elem = mutt_hash_find_elem(ctx->label_hash, label); if (!elem) return; count = (uintptr_t) elem->data; if (count <= 1) { - hash_delete(ctx->label_hash, label, NULL, NULL); + mutt_hash_delete(ctx->label_hash, label, NULL, NULL); return; } @@ -248,11 +248,11 @@ static void label_ref_inc(struct Context *ctx, char *label) struct HashElem *elem = NULL; uintptr_t count; - elem = hash_find_elem(ctx->label_hash, label); + elem = mutt_hash_find_elem(ctx->label_hash, label); if (!elem) { count = 1; - hash_insert(ctx->label_hash, label, (void *) count); + mutt_hash_insert(ctx->label_hash, label, (void *) count); return; } @@ -336,7 +336,7 @@ void mutt_make_label_hash(struct Context *ctx) /* 131 is just a rough prime estimate of how many distinct * labels someone might have in a mailbox. */ - ctx->label_hash = hash_create(131, MUTT_HASH_STRDUP_KEYS); + ctx->label_hash = mutt_hash_create(131, MUTT_HASH_STRDUP_KEYS); } void mutt_label_hash_add(struct Context *ctx, struct Header *hdr) diff --git a/history.c b/history.c index 434b9a3c9..1f05d5fcf 100644 --- a/history.c +++ b/history.c @@ -155,14 +155,14 @@ static int dup_hash_dec(struct Hash *dup_hash, char *s) struct HashElem *elem = NULL; uintptr_t count; - elem = hash_find_elem(dup_hash, s); + elem = mutt_hash_find_elem(dup_hash, s); if (!elem) return -1; count = (uintptr_t) elem->data; if (count <= 1) { - hash_delete(dup_hash, s, NULL, NULL); + mutt_hash_delete(dup_hash, s, NULL, NULL); return 0; } @@ -176,11 +176,11 @@ static int dup_hash_inc(struct Hash *dup_hash, char *s) struct HashElem *elem = NULL; uintptr_t count; - elem = hash_find_elem(dup_hash, s); + elem = mutt_hash_find_elem(dup_hash, s); if (!elem) { count = 1; - hash_insert(dup_hash, s, (void *) count); + mutt_hash_insert(dup_hash, s, (void *) count); return count; } @@ -207,7 +207,7 @@ static void shrink_histfile(void) if (option(OPT_HISTORY_REMOVE_DUPS)) for (hclass = 0; hclass < HC_LAST; hclass++) - dup_hashes[hclass] = hash_create(MAX(10, SaveHistory * 2), MUTT_HASH_STRDUP_KEYS); + dup_hashes[hclass] = mutt_hash_create(MAX(10, SaveHistory * 2), MUTT_HASH_STRDUP_KEYS); line = 0; while ((linebuf = mutt_file_read_line(linebuf, &buflen, f, &line, 0)) != NULL) @@ -286,7 +286,7 @@ cleanup: } if (option(OPT_HISTORY_REMOVE_DUPS)) for (hclass = 0; hclass < HC_LAST; hclass++) - hash_destroy(&dup_hashes[hclass], NULL); + mutt_hash_destroy(&dup_hashes[hclass], NULL); } static void save_history(enum HistoryClass hclass, const char *s) diff --git a/imap/command.c b/imap/command.c index c9425821c..c02f3e2dc 100644 --- a/imap/command.c +++ b/imap/command.c @@ -610,7 +610,7 @@ static void cmd_parse_search(struct ImapData *idata, const char *s) while ((s = imap_next_word((char *) s)) && *s != '\0') { uid = (unsigned int) atoi(s); - h = (struct Header *) int_hash_find(idata->uid_hash, uid); + h = (struct Header *) mutt_hash_int_find(idata->uid_hash, uid); if (h) h->matched = true; } diff --git a/imap/imap.c b/imap/imap.c index 239692685..1b5d0cb39 100644 --- a/imap/imap.c +++ b/imap/imap.c @@ -905,7 +905,7 @@ void imap_expunge_mailbox(struct ImapData *idata) FREE(&idata->cache[cacheno].path); } - int_hash_delete(idata->uid_hash, HEADER_DATA(h)->uid, h, NULL); + mutt_hash_int_delete(idata->uid_hash, HEADER_DATA(h)->uid, h, NULL); imap_free_header_data((struct ImapHeaderData **) &h->data); } @@ -2326,7 +2326,7 @@ static int imap_close_mailbox(struct Context *ctx) mutt_list_free(&idata->flags); idata->ctx = NULL; - hash_destroy(&idata->uid_hash, NULL); + mutt_hash_destroy(&idata->uid_hash, NULL); FREE(&idata->msn_index); idata->msn_index_size = 0; idata->max_msn = 0; diff --git a/imap/message.c b/imap/message.c index c3fb77af2..9bce11f2c 100644 --- a/imap/message.c +++ b/imap/message.c @@ -93,12 +93,12 @@ static void update_context(struct ImapData *idata, int oldmsgcount) ctx = idata->ctx; if (!idata->uid_hash) - idata->uid_hash = int_hash_create(MAX(6 * ctx->msgcount / 5, 30), 0); + idata->uid_hash = mutt_hash_int_create(MAX(6 * ctx->msgcount / 5, 30), 0); for (int msgno = oldmsgcount; msgno < ctx->msgcount; msgno++) { h = ctx->hdrs[msgno]; - int_hash_insert(idata->uid_hash, HEADER_DATA(h)->uid, h); + mutt_hash_int_insert(idata->uid_hash, HEADER_DATA(h)->uid, h); } } @@ -195,7 +195,7 @@ static int msg_cache_clean_cb(const char *id, struct BodyCache *bcache, void *da return 0; /* bad UID */ - if (uv != idata->uid_validity || !int_hash_find(idata->uid_hash, uid)) + if (uv != idata->uid_validity || !mutt_hash_int_find(idata->uid_hash, uid)) mutt_bcache_del(bcache, id); return 0; diff --git a/init.c b/init.c index 66c5fc029..e59b98591 100644 --- a/init.c +++ b/init.c @@ -4021,12 +4021,12 @@ void mutt_init(int skip_sys_rc, struct ListHead *commands) err.data = safe_malloc(err.dsize); err.dptr = err.data; - Groups = hash_create(1031, 0); + Groups = mutt_hash_create(1031, 0); /* reverse alias keys need to be strdup'ed because of idna conversions */ - ReverseAliases = - hash_create(1031, MUTT_HASH_STRCASECMP | MUTT_HASH_STRDUP_KEYS | MUTT_HASH_ALLOW_DUPS); - TagTransforms = hash_create(64, 1); - TagFormats = hash_create(64, 0); + ReverseAliases = mutt_hash_create( + 1031, MUTT_HASH_STRCASECMP | MUTT_HASH_STRDUP_KEYS | MUTT_HASH_ALLOW_DUPS); + TagTransforms = mutt_hash_create(64, 1); + TagFormats = mutt_hash_create(64, 0); mutt_menu_init(); @@ -4430,7 +4430,7 @@ static int parse_tag_transforms(struct Buffer *b, struct Buffer *s, transform = safe_strdup(b->data); /* avoid duplicates */ - tmp = hash_find(TagTransforms, tag); + tmp = mutt_hash_find(TagTransforms, tag); if (tmp) { mutt_debug(3, "tag transform '%s' already registered as '%s'\n", tag, tmp); @@ -4439,7 +4439,7 @@ static int parse_tag_transforms(struct Buffer *b, struct Buffer *s, continue; } - hash_insert(TagTransforms, tag, transform); + mutt_hash_insert(TagTransforms, tag, transform); } return 0; } @@ -4466,7 +4466,7 @@ static int parse_tag_formats(struct Buffer *b, struct Buffer *s, format = safe_strdup(b->data); /* avoid duplicates */ - tmp = hash_find(TagFormats, format); + tmp = mutt_hash_find(TagFormats, format); if (tmp) { mutt_debug(3, "tag format '%s' already registered as '%s'\n", format, tmp); @@ -4475,7 +4475,7 @@ static int parse_tag_formats(struct Buffer *b, struct Buffer *s, continue; } - hash_insert(TagFormats, format, tag); + mutt_hash_insert(TagFormats, format, tag); } return 0; } @@ -4625,7 +4625,7 @@ int mutt_label_complete(char *buffer, size_t len, int numtabs) memset(Matches, 0, Matches_listsize); memset(Completed, 0, sizeof(Completed)); memset(&state, 0, sizeof(state)); - while ((entry = hash_walk(Context->label_hash, &state))) + while ((entry = mutt_hash_walk(Context->label_hash, &state))) candidate(Completed, User_typed, entry->key.strkey, sizeof(Completed)); matches_ensure_morespace(Num_matched); qsort(Matches, Num_matched, sizeof(char *), (sort_t *) mutt_strcasecmp); diff --git a/mbox.c b/mbox.c index f1b1cb46b..e4be2f2c3 100644 --- a/mbox.c +++ b/mbox.c @@ -692,10 +692,10 @@ static int reopen_mailbox(struct Context *ctx, int *index_hint) /* simulate a close */ if (ctx->id_hash) - hash_destroy(&ctx->id_hash, NULL); + mutt_hash_destroy(&ctx->id_hash, NULL); if (ctx->subj_hash) - hash_destroy(&ctx->subj_hash, NULL); - hash_destroy(&ctx->label_hash, NULL); + mutt_hash_destroy(&ctx->subj_hash, NULL); + mutt_hash_destroy(&ctx->label_hash, NULL); mutt_clear_threads(ctx); FREE(&ctx->v2r); if (ctx->readonly) diff --git a/menu.c b/menu.c index 51d603b5d..8797eb9e9 100644 --- a/menu.c +++ b/menu.c @@ -77,7 +77,7 @@ static int get_color(int index, unsigned char *s) { if (strncmp((const char *) (s + 1), np->pattern, strlen(np->pattern)) == 0) return np->pair; - const char *transform = hash_find(TagTransforms, np->pattern); + const char *transform = mutt_hash_find(TagTransforms, np->pattern); if (transform && (strncmp((const char *) (s + 1), transform, strlen(transform)) == 0)) return np->pair; diff --git a/mh.c b/mh.c index 341be34ec..4f3d29f80 100644 --- a/mh.c +++ b/mh.c @@ -2090,13 +2090,13 @@ static int maildir_check_mailbox(struct Context *ctx, int *index_hint) * of each message we scanned. This is used in the loop over the * existing messages below to do some correlation. */ - fnames = hash_create(count, 0); + fnames = mutt_hash_create(count, 0); for (p = md; p; p = p->next) { maildir_canon_filename(buf, p->h->path, sizeof(buf)); p->canon_fname = safe_strdup(buf); - hash_insert(fnames, p->canon_fname, p); + mutt_hash_insert(fnames, p->canon_fname, p); } /* check for modifications and adjust flags */ @@ -2104,7 +2104,7 @@ static int maildir_check_mailbox(struct Context *ctx, int *index_hint) { ctx->hdrs[i]->active = false; maildir_canon_filename(buf, ctx->hdrs[i]->path, sizeof(buf)); - p = hash_find(fnames, buf); + p = mutt_hash_find(fnames, buf); if (p && p->h) { /* message already exists, merge flags */ @@ -2158,7 +2158,7 @@ static int maildir_check_mailbox(struct Context *ctx, int *index_hint) } /* destroy the file name hash */ - hash_destroy(&fnames, NULL); + mutt_hash_destroy(&fnames, NULL); /* If we didn't just get new mail, update the tables. */ if (occult) @@ -2251,20 +2251,20 @@ static int mh_check_mailbox(struct Context *ctx, int *index_hint) mhs_free_sequences(&mhs); /* check for modifications and adjust flags */ - fnames = hash_create(count, 0); + fnames = mutt_hash_create(count, 0); for (p = md; p; p = p->next) { /* the hash key must survive past the header, which is freed below. */ p->canon_fname = safe_strdup(p->h->path); - hash_insert(fnames, p->canon_fname, p); + mutt_hash_insert(fnames, p->canon_fname, p); } for (i = 0; i < ctx->msgcount; i++) { ctx->hdrs[i]->active = false; - if ((p = hash_find(fnames, ctx->hdrs[i]->path)) && p->h && + if ((p = mutt_hash_find(fnames, ctx->hdrs[i]->path)) && p->h && (mbox_strict_cmp_headers(ctx->hdrs[i], p->h))) { ctx->hdrs[i]->active = true; @@ -2281,7 +2281,7 @@ static int mh_check_mailbox(struct Context *ctx, int *index_hint) /* destroy the file name hash */ - hash_destroy(&fnames, NULL); + mutt_hash_destroy(&fnames, NULL); /* If we didn't just get new mail, update the tables. */ if (occult) diff --git a/mutt/hash.c b/mutt/hash.c index 36db1df71..9998233d9 100644 --- a/mutt/hash.c +++ b/mutt/hash.c @@ -25,20 +25,20 @@ * * Hash table data structure. * - * | Function | Description - * | :--------------------- | :--------------------------------------------------------- - * | hash_create() | Create a new Hash table (with string keys) - * | hash_delete() | Remove an element from a Hash table - * | hash_destroy() | Destroy a hash table - * | hash_find() | Find the HashElem data in a Hash table element using a key - * | hash_find_bucket() | Find the HashElem in a Hash table element using a key - * | hash_find_elem() | Find the HashElem in a Hash table element using a key - * | hash_insert() | Add a new element to the Hash table (with string keys) - * | hash_walk() | Iterate through all the HashElem's in a Hash table - * | int_hash_create() | Create a new Hash table (with integer keys) - * | int_hash_delete() | Remove an element from a Hash table - * | int_hash_find() | Find the HashElem data in a Hash table element using a key - * | int_hash_insert() | Add a new element to the Hash table (with integer keys) + * | Function | Description + * | :---------------------- | :--------------------------------------------------------- + * | mutt_hash_create() | Create a new Hash table (with string keys) + * | mutt_hash_delete() | Remove an element from a Hash table + * | mutt_hash_destroy() | Destroy a hash table + * | mutt_hash_find() | Find the HashElem data in a Hash table element using a key + * | mutt_hash_find_bucket() | Find the HashElem in a Hash table element using a key + * | mutt_hash_find_elem() | Find the HashElem in a Hash table element using a key + * | mutt_hash_insert() | Add a new element to the Hash table (with string keys) + * | mutt_hash_int_create() | Create a new Hash table (with integer keys) + * | mutt_hash_int_delete() | Remove an element from a Hash table + * | mutt_hash_int_find() | Find the HashElem data in a Hash table element using a key + * | mutt_hash_int_insert() | Add a new element to the Hash table (with integer keys) + * | mutt_hash_walk() | Iterate through all the HashElem's in a Hash table */ #include "config.h" @@ -286,12 +286,12 @@ static void union_hash_delete(struct Hash *table, union HashKey key, } /** - * hash_create - Create a new Hash table (with string keys) + * mutt_hash_create - Create a new Hash table (with string keys) * @param nelem Number of elements it should contain * @param flags Flags, e.g. #MUTT_HASH_STRCASECMP * @retval ptr New Hash table */ -struct Hash *hash_create(int nelem, int flags) +struct Hash *mutt_hash_create(int nelem, int flags) { struct Hash *table = new_hash(nelem); if (flags & MUTT_HASH_STRCASECMP) @@ -312,12 +312,12 @@ struct Hash *hash_create(int nelem, int flags) } /** - * int_hash_create - Create a new Hash table (with integer keys) + * mutt_hash_int_create - 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 * @retval ptr New Hash table */ -struct Hash *int_hash_create(int nelem, int flags) +struct Hash *mutt_hash_int_create(int nelem, int flags) { struct Hash *table = new_hash(nelem); table->gen_hash = gen_int_hash; @@ -328,14 +328,14 @@ struct Hash *int_hash_create(int nelem, int flags) } /** - * hash_insert - Add a new element to the Hash table (with string keys) + * mutt_hash_insert - Add a new element to the Hash table (with string keys) * @param table Hash table (with string keys) * @param strkey String key * @param data Private data associated with the key * @retval -1 on error * @retval >=0 on success, index into the hash table */ -int hash_insert(struct Hash *table, const char *strkey, void *data) +int mutt_hash_insert(struct Hash *table, const char *strkey, void *data) { union HashKey key; key.strkey = table->strdup_keys ? safe_strdup(strkey) : strkey; @@ -343,14 +343,14 @@ int hash_insert(struct Hash *table, const char *strkey, void *data) } /** - * int_hash_insert - Add a new element to the Hash table (with integer keys) + * mutt_hash_int_insert - Add a new element to the Hash table (with integer keys) * @param table Hash table (with integer keys) * @param intkey Integer key * @param data Private data associated with the key * @retval -1 on error * @retval >=0 on success, index into the hash table */ -int int_hash_insert(struct Hash *table, unsigned int intkey, void *data) +int mutt_hash_int_insert(struct Hash *table, unsigned int intkey, void *data) { union HashKey key; key.intkey = intkey; @@ -358,12 +358,12 @@ int int_hash_insert(struct Hash *table, unsigned int intkey, void *data) } /** - * hash_find - Find the HashElem data in a Hash table element using a key + * mutt_hash_find - Find the HashElem data in a Hash table element using a key * @param table Hash table to search * @param strkey String key to search for * @retval ptr Data attached to the HashElem matching the key */ -void *hash_find(const struct Hash *table, const char *strkey) +void *mutt_hash_find(const struct Hash *table, const char *strkey) { union HashKey key; key.strkey = strkey; @@ -371,12 +371,12 @@ void *hash_find(const struct Hash *table, const char *strkey) } /** - * hash_find_elem - Find the HashElem in a Hash table element using a key + * mutt_hash_find_elem - Find the HashElem in a Hash table element using a key * @param table Hash table to search * @param strkey String key to search for * @retval ptr HashElem matching the key */ -struct HashElem *hash_find_elem(const struct Hash *table, const char *strkey) +struct HashElem *mutt_hash_find_elem(const struct Hash *table, const char *strkey) { union HashKey key; key.strkey = strkey; @@ -384,12 +384,12 @@ struct HashElem *hash_find_elem(const struct Hash *table, const char *strkey) } /** - * int_hash_find - Find the HashElem data in a Hash table element using a key + * mutt_hash_int_find - Find the HashElem data in a Hash table element using a key * @param table Hash table to search * @param intkey Integer key * @retval ptr Data attached to the HashElem matching the key */ -void *int_hash_find(const struct Hash *table, unsigned int intkey) +void *mutt_hash_int_find(const struct Hash *table, unsigned int intkey) { union HashKey key; key.intkey = intkey; @@ -397,14 +397,14 @@ void *int_hash_find(const struct Hash *table, unsigned int intkey) } /** - * hash_find_bucket - Find the HashElem in a Hash table element using a key + * mutt_hash_find_bucket - Find the HashElem in a Hash table element using a key * @param table Hash table to search * @param strkey String key to search for * @retval ptr HashElem matching the key * - * Unlike hash_find_elem(), this will return the first matching entry. + * Unlike mutt_hash_find_elem(), this will return the first matching entry. */ -struct HashElem *hash_find_bucket(const struct Hash *table, const char *strkey) +struct HashElem *mutt_hash_find_bucket(const struct Hash *table, const char *strkey) { union HashKey key; int hash; @@ -418,14 +418,14 @@ struct HashElem *hash_find_bucket(const struct Hash *table, const char *strkey) } /** - * hash_delete - Remove an element from a Hash table + * mutt_hash_delete - Remove an element from a Hash table * @param table Hash table to use * @param strkey String key to match * @param data Private data to match (or NULL for any match) * @param destroy Callback function to free the HashElem's data */ -void hash_delete(struct Hash *table, const char *strkey, const void *data, - void (*destroy)(void *)) +void mutt_hash_delete(struct Hash *table, const char *strkey, const void *data, + void (*destroy)(void *)) { union HashKey key; key.strkey = strkey; @@ -433,14 +433,14 @@ void hash_delete(struct Hash *table, const char *strkey, const void *data, } /** - * int_hash_delete - Remove an element from a Hash table + * mutt_hash_int_delete - Remove an element from a Hash table * @param table Hash table to use * @param intkey Integer key to match * @param data Private data to match (or NULL for any match) * @param destroy Callback function to free the HashElem's data */ -void int_hash_delete(struct Hash *table, unsigned int intkey, const void *data, - void (*destroy)(void *)) +void mutt_hash_int_delete(struct Hash *table, unsigned int intkey, + const void *data, void (*destroy)(void *)) { union HashKey key; key.intkey = intkey; @@ -448,11 +448,11 @@ void int_hash_delete(struct Hash *table, unsigned int intkey, const void *data, } /** - * hash_destroy - Destroy a hash table + * mutt_hash_destroy - Destroy a hash table * @param ptr Pointer to the hash table to be freed * @param destroy Function to call to free the ->data member (optional) */ -void hash_destroy(struct Hash **ptr, void (*destroy)(void *)) +void mutt_hash_destroy(struct Hash **ptr, void (*destroy)(void *)) { struct Hash *pptr = NULL; struct HashElem *elem = NULL, *tmp = NULL; @@ -479,13 +479,13 @@ void hash_destroy(struct Hash **ptr, void (*destroy)(void *)) } /** - * hash_walk - Iterate through all the HashElem's in a Hash table + * mutt_hash_walk - Iterate through all the HashElem's in a Hash table * @param table Hash table to search * @param state Cursor to keep track * @retval ptr Next HashElem in the Hash table * @retval NULL When the last HashElem has been seen */ -struct HashElem *hash_walk(const struct Hash *table, struct HashWalkState *state) +struct HashElem *mutt_hash_walk(const struct Hash *table, struct HashWalkState *state) { if (state->last && state->last->next) { diff --git a/mutt/hash.h b/mutt/hash.h index 74aaffd21..40ec698ca 100644 --- a/mutt/hash.h +++ b/mutt/hash.h @@ -56,22 +56,22 @@ struct Hash int (*cmp_key)(union HashKey, union HashKey); }; -/* flags for hash_create() */ +/* flags for mutt_hash_create() */ #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 */ -struct Hash * hash_create(int nelem, int flags); -void hash_delete(struct Hash *table, const char *strkey, const void *data, void (*destroy)(void *)); -void hash_destroy(struct Hash **ptr, void (*destroy)(void *)); -struct HashElem *hash_find_bucket(const struct Hash *table, const char *strkey); -void * hash_find(const struct Hash *table, const char *strkey); -struct HashElem *hash_find_elem(const struct Hash *table, const char *strkey); -int hash_insert(struct Hash *table, const char *strkey, void *data); -struct Hash * int_hash_create(int nelem, int flags); -void int_hash_delete(struct Hash *table, unsigned int intkey, const void *data, void (*destroy)(void *)); -void * int_hash_find(const struct Hash *table, unsigned int intkey); -int int_hash_insert(struct Hash *table, unsigned int intkey, void *data); +struct Hash * mutt_hash_create(int nelem, int flags); +void mutt_hash_delete(struct Hash *table, const char *strkey, const void *data, void (*destroy)(void *)); +void mutt_hash_destroy(struct Hash **ptr, void (*destroy)(void *)); +struct HashElem *mutt_hash_find_bucket(const struct Hash *table, const char *strkey); +void * mutt_hash_find(const struct Hash *table, const char *strkey); +struct HashElem *mutt_hash_find_elem(const struct Hash *table, const char *strkey); +int mutt_hash_insert(struct Hash *table, const char *strkey, void *data); +struct Hash * mutt_hash_int_create(int nelem, int flags); +void mutt_hash_int_delete(struct Hash *table, unsigned int intkey, const void *data, void (*destroy)(void *)); +void * mutt_hash_int_find(const struct Hash *table, unsigned int intkey); +int mutt_hash_int_insert(struct Hash *table, unsigned int intkey, void *data); /** * struct HashWalkState - Cursor to iterate through a Hash Table @@ -82,6 +82,6 @@ struct HashWalkState struct HashElem *last; }; -struct HashElem *hash_walk(const struct Hash *table, struct HashWalkState *state); +struct HashElem *mutt_hash_walk(const struct Hash *table, struct HashWalkState *state); #endif /* _MUTT_HASH_H */ diff --git a/mutt_notmuch.c b/mutt_notmuch.c index 069c6bb90..07f4ba673 100644 --- a/mutt_notmuch.c +++ b/mutt_notmuch.c @@ -973,7 +973,7 @@ static struct Header *get_mutt_header(struct Context *ctx, notmuch_message_t *ms mid = nm2mutt_message_id(id); mutt_debug(2, "nm: neomutt id='%s'\n", mid); - h = hash_find(ctx->id_hash, mid); + h = mutt_hash_find(ctx->id_hash, mid); FREE(&mid); return h; } diff --git a/mutt_tags.c b/mutt_tags.c index fcac4d3a5..28f8bd924 100644 --- a/mutt_tags.c +++ b/mutt_tags.c @@ -144,7 +144,7 @@ char *driver_tags_get_transformed_for(char *name, struct TagHead *head) */ static void driver_tags_add(struct TagHead *head, char *new_tag) { - char *new_tag_transformed = hash_find(TagTransforms, new_tag); + char *new_tag_transformed = mutt_hash_find(TagTransforms, new_tag); struct TagNode *np = safe_calloc(1, sizeof(struct TagNode)); np->name = safe_strdup(new_tag); diff --git a/mx.c b/mx.c index 7b6e82a31..4dfbcbf0c 100644 --- a/mx.c +++ b/mx.c @@ -536,10 +536,10 @@ void mx_fastclose_mailbox(struct Context *ctx) ctx->mx_ops->close(ctx); if (ctx->subj_hash) - hash_destroy(&ctx->subj_hash, NULL); + mutt_hash_destroy(&ctx->subj_hash, NULL); if (ctx->id_hash) - hash_destroy(&ctx->id_hash, NULL); - hash_destroy(&ctx->label_hash, NULL); + mutt_hash_destroy(&ctx->id_hash, NULL); + mutt_hash_destroy(&ctx->label_hash, NULL); mutt_clear_threads(ctx); for (int i = 0; i < ctx->msgcount; i++) mutt_free_header(&ctx->hdrs[i]); @@ -966,9 +966,9 @@ void mx_update_tables(struct Context *ctx, bool committing) ctx->hdrs[i]->content->hdr_offset); /* remove message from the hash tables */ if (ctx->subj_hash && ctx->hdrs[i]->env->real_subj) - hash_delete(ctx->subj_hash, ctx->hdrs[i]->env->real_subj, ctx->hdrs[i], NULL); + mutt_hash_delete(ctx->subj_hash, ctx->hdrs[i]->env->real_subj, ctx->hdrs[i], NULL); if (ctx->id_hash && ctx->hdrs[i]->env->message_id) - hash_delete(ctx->id_hash, ctx->hdrs[i]->env->message_id, ctx->hdrs[i], NULL); + mutt_hash_delete(ctx->id_hash, ctx->hdrs[i]->env->message_id, ctx->hdrs[i], NULL); mutt_label_hash_remove(ctx, ctx->hdrs[i]); /* The path mx_check_mailbox() -> imap_check_mailbox() -> * imap_expunge_mailbox() -> mx_update_tables() @@ -1317,7 +1317,7 @@ void mx_update_context(struct Context *ctx, int new_messages) if (!ctx->id_hash) ctx->id_hash = mutt_make_id_hash(ctx); - h2 = hash_find(ctx->id_hash, h->env->supersedes); + h2 = mutt_hash_find(ctx->id_hash, h->env->supersedes); if (h2) { h2->superseded = true; @@ -1328,9 +1328,9 @@ void mx_update_context(struct Context *ctx, int new_messages) /* add this message to the hash tables */ if (ctx->id_hash && h->env->message_id) - hash_insert(ctx->id_hash, h->env->message_id, h); + mutt_hash_insert(ctx->id_hash, h->env->message_id, h); if (ctx->subj_hash && h->env->real_subj) - hash_insert(ctx->subj_hash, h->env->real_subj, h); + mutt_hash_insert(ctx->subj_hash, h->env->real_subj, h); mutt_label_hash_add(ctx, h); if (option(OPT_SCORE)) diff --git a/newsrc.c b/newsrc.c index 1a7313892..8193e4a2c 100644 --- a/newsrc.c +++ b/newsrc.c @@ -60,7 +60,7 @@ struct BodyCache; */ static struct NntpData *nntp_data_find(struct NntpServer *nserv, const char *group) { - struct NntpData *nntp_data = hash_find(nserv->groups_hash, group); + struct NntpData *nntp_data = mutt_hash_find(nserv->groups_hash, group); if (!nntp_data) { @@ -71,7 +71,7 @@ static struct NntpData *nntp_data_find(struct NntpServer *nserv, const char *gro strfcpy(nntp_data->group, group, len); nntp_data->nserv = nserv; nntp_data->deleted = true; - hash_insert(nserv->groups_hash, nntp_data->group, nntp_data); + mutt_hash_insert(nserv->groups_hash, nntp_data->group, nntp_data); /* add NntpData to list */ if (nserv->groups_num >= nserv->groups_max) @@ -833,7 +833,7 @@ void nntp_clear_cache(struct NntpServer *nserv) if (!S_ISDIR(sb.st_mode)) continue; - nntp_data = hash_find(nserv->groups_hash, group); + nntp_data = mutt_hash_find(nserv->groups_hash, group); if (!nntp_data) { nntp_data = &nntp_tmp; @@ -1008,7 +1008,7 @@ struct NntpServer *nntp_select_server(char *server, bool leave_lock) /* new news server */ nserv = safe_calloc(1, sizeof(struct NntpServer)); nserv->conn = conn; - nserv->groups_hash = hash_create(1009, 0); + nserv->groups_hash = mutt_hash_create(1009, 0); nserv->groups_max = 16; nserv->groups_list = safe_malloc(nserv->groups_max * sizeof(nntp_data)); @@ -1069,7 +1069,7 @@ struct NntpServer *nntp_select_server(char *server, bool leave_lock) if (strlen(group) < 8 || (strcmp(p, ".hcache") != 0)) continue; *p = '\0'; - nntp_data = hash_find(nserv->groups_hash, group); + nntp_data = mutt_hash_find(nserv->groups_hash, group); if (!nntp_data) continue; @@ -1111,7 +1111,7 @@ struct NntpServer *nntp_select_server(char *server, bool leave_lock) if (rc < 0) { - hash_destroy(&nserv->groups_hash, nntp_data_free); + mutt_hash_destroy(&nserv->groups_hash, nntp_data_free); FREE(&nserv->groups_list); FREE(&nserv->newsrc_file); FREE(&nserv->authenticators); @@ -1138,7 +1138,7 @@ void nntp_article_status(struct Context *ctx, struct Header *hdr, char *group, a struct NntpData *nntp_data = ctx->data; if (group) - nntp_data = hash_find(nntp_data->nserv->groups_hash, group); + nntp_data = mutt_hash_find(nntp_data->nserv->groups_hash, group); if (!nntp_data) return; @@ -1196,7 +1196,7 @@ struct NntpData *mutt_newsgroup_unsubscribe(struct NntpServer *nserv, char *grou if (!nserv || !nserv->groups_hash || !group || !*group) return NULL; - nntp_data = hash_find(nserv->groups_hash, group); + nntp_data = mutt_hash_find(nserv->groups_hash, group); if (!nntp_data) return NULL; @@ -1219,7 +1219,7 @@ struct NntpData *mutt_newsgroup_catchup(struct NntpServer *nserv, char *group) if (!nserv || !nserv->groups_hash || !group || !*group) return NULL; - nntp_data = hash_find(nserv->groups_hash, group); + nntp_data = mutt_hash_find(nserv->groups_hash, group); if (!nntp_data) return NULL; @@ -1249,7 +1249,7 @@ struct NntpData *mutt_newsgroup_uncatchup(struct NntpServer *nserv, char *group) if (!nserv || !nserv->groups_hash || !group || !*group) return NULL; - nntp_data = hash_find(nserv->groups_hash, group); + nntp_data = mutt_hash_find(nserv->groups_hash, group); if (!nntp_data) return NULL; diff --git a/nntp.c b/nntp.c index da0afeba0..ea9b3d03a 100644 --- a/nntp.c +++ b/nntp.c @@ -912,7 +912,7 @@ static int fetch_description(char *line, void *data) else desc = strchr(line, '\0'); - nntp_data = hash_find(nserv->groups_hash, line); + nntp_data = mutt_hash_find(nserv->groups_hash, line); if (nntp_data && (mutt_strcmp(desc, nntp_data->desc) != 0)) { mutt_str_replace(&nntp_data->desc, desc); @@ -1469,7 +1469,7 @@ static int nntp_open_mailbox(struct Context *ctx) CurrentNewsSrv = nserv; /* find news group data structure */ - nntp_data = hash_find(nserv->groups_hash, group); + nntp_data = mutt_hash_find(nserv->groups_hash, group); if (!nntp_data) { nntp_newsrc_close(nserv); @@ -1664,17 +1664,17 @@ static int nntp_open_message(struct Context *ctx, struct Message *msg, int msgno /* replace envelope with new one * hash elements must be updated because pointers will be changed */ if (ctx->id_hash && hdr->env->message_id) - hash_delete(ctx->id_hash, hdr->env->message_id, hdr, NULL); + mutt_hash_delete(ctx->id_hash, hdr->env->message_id, hdr, NULL); if (ctx->subj_hash && hdr->env->real_subj) - hash_delete(ctx->subj_hash, hdr->env->real_subj, hdr, NULL); + mutt_hash_delete(ctx->subj_hash, hdr->env->real_subj, hdr, NULL); mutt_free_envelope(&hdr->env); hdr->env = mutt_read_rfc822_header(msg->fp, hdr, 0, 0); if (ctx->id_hash && hdr->env->message_id) - hash_insert(ctx->id_hash, hdr->env->message_id, hdr); + mutt_hash_insert(ctx->id_hash, hdr->env->message_id, hdr); if (ctx->subj_hash && hdr->env->real_subj) - hash_insert(ctx->subj_hash, hdr->env->real_subj, hdr); + mutt_hash_insert(ctx->subj_hash, hdr->env->real_subj, hdr); /* fix content length */ fseek(msg->fp, 0, SEEK_END); @@ -1995,9 +1995,9 @@ static int check_mailbox(struct Context *ctx) if (ret == MUTT_REOPENED) { if (ctx->subj_hash) - hash_destroy(&ctx->subj_hash, NULL); + mutt_hash_destroy(&ctx->subj_hash, NULL); if (ctx->id_hash) - hash_destroy(&ctx->id_hash, NULL); + mutt_hash_destroy(&ctx->id_hash, NULL); mutt_clear_threads(ctx); ctx->vcount = 0; @@ -2136,7 +2136,7 @@ static int nntp_close_mailbox(struct Context *ctx) if (!nntp_data->nserv || !nntp_data->nserv->groups_hash || !nntp_data->group) return 0; - nntp_tmp = hash_find(nntp_data->nserv->groups_hash, nntp_data->group); + nntp_tmp = mutt_hash_find(nntp_data->nserv->groups_hash, nntp_data->group); if (nntp_tmp == NULL || nntp_tmp != nntp_data) nntp_data_free(nntp_data); return 0; @@ -2225,7 +2225,7 @@ int nntp_active_fetch(struct NntpServer *nserv, bool new) if (data && data->deleted && !data->newsrc_ent) { nntp_delete_group_cache(data); - hash_delete(nserv->groups_hash, data->group, NULL, nntp_data_free); + mutt_hash_delete(nserv->groups_hash, data->group, NULL, nntp_data_free); nserv->groups_list[i] = NULL; } } diff --git a/pop.c b/pop.c index 5d88b4a8a..e0d18a23a 100644 --- a/pop.c +++ b/pop.c @@ -662,12 +662,12 @@ static int pop_fetch_message(struct Context *ctx, struct Message *msg, int msgno /* we replace envelop, key in subj_hash has to be updated as well */ if (ctx->subj_hash && h->env->real_subj) - hash_delete(ctx->subj_hash, h->env->real_subj, h, NULL); + mutt_hash_delete(ctx->subj_hash, h->env->real_subj, h, NULL); mutt_label_hash_remove(ctx, h); mutt_free_envelope(&h->env); h->env = mutt_read_rfc822_header(msg->fp, h, 0, 0); if (ctx->subj_hash && h->env->real_subj) - hash_insert(ctx->subj_hash, h->env->real_subj, h); + mutt_hash_insert(ctx->subj_hash, h->env->real_subj, h); mutt_label_hash_add(ctx, h); h->data = uidl; diff --git a/postpone.c b/postpone.c index 16b9c9756..9e7ec75f2 100644 --- a/postpone.c +++ b/postpone.c @@ -331,7 +331,7 @@ int mutt_get_postponed(struct Context *ctx, struct Header *hdr, p = skip_email_wsp(np->data + 18); if (!ctx->id_hash) ctx->id_hash = mutt_make_id_hash(ctx); - *cur = hash_find(ctx->id_hash, p); + *cur = mutt_hash_find(ctx->id_hash, p); } if (*cur) code |= SENDREPLY; diff --git a/thread.c b/thread.c index fad10c8fe..2991928db 100644 --- a/thread.c +++ b/thread.c @@ -438,7 +438,7 @@ static struct MuttThread *find_subject(struct Context *ctx, struct MuttThread *c struct ListNode *np; STAILQ_FOREACH(np, &subjects, entries) { - for (ptr = hash_find_bucket(ctx->subj_hash, np->data); ptr; ptr = ptr->next) + for (ptr = mutt_hash_find_bucket(ctx->subj_hash, np->data); ptr; ptr = ptr->next) { tmp = ((struct Header *) ptr->data)->thread; if (tmp != cur && /* don't match the same message */ @@ -510,13 +510,13 @@ static struct Hash *make_subj_hash(struct Context *ctx) struct Header *hdr = NULL; struct Hash *hash = NULL; - hash = hash_create(ctx->msgcount * 2, MUTT_HASH_ALLOW_DUPS); + hash = mutt_hash_create(ctx->msgcount * 2, MUTT_HASH_ALLOW_DUPS); for (int i = 0; i < ctx->msgcount; i++) { hdr = ctx->hdrs[i]; if (hdr->env->real_subj) - hash_insert(hash, hdr->env->real_subj, hdr); + mutt_hash_insert(hash, hdr->env->real_subj, hdr); } return hash; @@ -602,7 +602,7 @@ void mutt_clear_threads(struct Context *ctx) ctx->tree = NULL; if (ctx->thread_hash) - hash_destroy(&ctx->thread_hash, *free); + mutt_hash_destroy(&ctx->thread_hash, *free); } static int compare_threads(const void *a, const void *b) @@ -799,7 +799,7 @@ void mutt_sort_threads(struct Context *ctx, int init) init = 1; if (init) - ctx->thread_hash = hash_create(ctx->msgcount * 2, MUTT_HASH_ALLOW_DUPS); + ctx->thread_hash = mutt_hash_create(ctx->msgcount * 2, MUTT_HASH_ALLOW_DUPS); /* we want a quick way to see if things are actually attached to the top of the * thread tree or if they're just dangling, so we attach everything to a top @@ -820,7 +820,7 @@ void mutt_sort_threads(struct Context *ctx, int init) if (!cur->thread) { if ((!init || option(OPT_DUPLICATE_THREADS)) && cur->env->message_id) - thread = hash_find(ctx->thread_hash, cur->env->message_id); + thread = mutt_hash_find(ctx->thread_hash, cur->env->message_id); else thread = NULL; @@ -869,8 +869,8 @@ void mutt_sort_threads(struct Context *ctx, int init) thread->message = cur; thread->check_subject = true; cur->thread = thread; - hash_insert(ctx->thread_hash, - cur->env->message_id ? cur->env->message_id : "", thread); + mutt_hash_insert(ctx->thread_hash, + cur->env->message_id ? cur->env->message_id : "", thread); if (new) { @@ -955,11 +955,11 @@ void mutt_sort_threads(struct Context *ctx, int init) if (!ref) break; - new = hash_find(ctx->thread_hash, ref->data); + new = mutt_hash_find(ctx->thread_hash, ref->data); if (!new) { new = safe_calloc(1, sizeof(struct MuttThread)); - hash_insert(ctx->thread_hash, ref->data, new); + mutt_hash_insert(ctx->thread_hash, ref->data, new); } else { @@ -1385,13 +1385,13 @@ struct Hash *mutt_make_id_hash(struct Context *ctx) struct Header *hdr = NULL; struct Hash *hash = NULL; - hash = hash_create(ctx->msgcount * 2, 0); + hash = mutt_hash_create(ctx->msgcount * 2, 0); for (int i = 0; i < ctx->msgcount; i++) { hdr = ctx->hdrs[i]; if (hdr->env->message_id) - hash_insert(hash, hdr->env->message_id, hdr); + mutt_hash_insert(hash, hdr->env->message_id, hdr); } return hash;