From: Richard Russon Date: Sat, 31 Aug 2019 14:19:12 +0000 (+0100) Subject: unify new/free() functions 3 X-Git-Tag: 2019-10-25~63^2~1 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=0e6a15a09b326ebff1be2ae24a1bc3f48607cd4f;p=neomutt unify new/free() functions 3 'Free' functions: - Name ends in `_free()` - Take a `**ptr` - Creates a native pointer - Sets pointer to `NULL` Functions changed: - compress_info_free() - crypt_key_free() - key_free() - lookup_free() - maildir_entry_free() - maildir_free() - menu_free() - mhs_sequences_free() - mix_type2_list_free() - mutt_actx_entries_free() - mutt_attachmatch_free() - mutt_colors_free() - mutt_color_free() - mutt_color_list_free() - mutt_keys_free() - mutt_opts_free() - myvar_free() - parameter_free() - pgp_key_free() - pgp_uid_free() - recipient_set_free() - smime_key_free() 'New' functions: - Name ends in `_new()` - Must be a 'new' function if there's a 'free' function Functions changed: - lookup_new() - maildir_entry_new() - myvar_new() --- diff --git a/autocrypt/autocrypt_acct_menu.c b/autocrypt/autocrypt_acct_menu.c index 8b9ed4371..cb3ba2655 100644 --- a/autocrypt/autocrypt_acct_menu.c +++ b/autocrypt/autocrypt_acct_menu.c @@ -194,7 +194,7 @@ static struct Menu *create_menu(void) entries[i].num = i + 1; /* note: we are transfering the account pointer to the entries * array, and freeing the accounts array below. the account - * will be freed in free_menu(). */ + * will be freed in menu_free(). */ entries[i].account = accounts[i]; entries[i].addr = mutt_addr_new(); @@ -209,10 +209,10 @@ static struct Menu *create_menu(void) } /** - * free_menu - Free the Autocrypt account Menu + * menu_free - Free the Autocrypt account Menu * @param menu Menu to free */ -static void free_menu(struct Menu **menu) +static void menu_free(struct Menu **menu) { struct AccountEntry *entries = (struct AccountEntry *) (*menu)->data; @@ -287,7 +287,7 @@ void mutt_autocrypt_account_menu(void) case OP_AUTOCRYPT_CREATE_ACCT: if (!mutt_autocrypt_account_init(false)) { - free_menu(&menu); + menu_free(&menu); menu = create_menu(); } break; @@ -305,7 +305,7 @@ void mutt_autocrypt_account_menu(void) if (!mutt_autocrypt_db_account_delete(entry->account)) { - free_menu(&menu); + menu_free(&menu); menu = create_menu(); } } @@ -331,5 +331,5 @@ void mutt_autocrypt_account_menu(void) } } - free_menu(&menu); + menu_free(&menu); } diff --git a/color.c b/color.c index 57d4d54d9..b54178c96 100644 --- a/color.c +++ b/color.c @@ -196,7 +196,7 @@ static void color_line_free(struct ColorLine **ptr, bool free_colors) #ifdef HAVE_COLOR if (free_colors && (cl->fg != COLOR_UNSET) && (cl->bg != COLOR_UNSET)) - mutt_free_color(cl->fg, cl->bg); + mutt_color_free(cl->fg, cl->bg); #endif regfree(&cl->regex); @@ -409,13 +409,13 @@ int mutt_combine_color(uint32_t fg_attr, uint32_t bg_attr) } /** - * mutt_free_color - Free a colour + * mutt_color_free - Free a colour * @param fg Foreground colour ID * @param bg Background colour ID * * If there are no more users, the resource will be freed. */ -void mutt_free_color(uint32_t fg, uint32_t bg) +void mutt_color_free(uint32_t fg, uint32_t bg) { struct ColorList *q = NULL; @@ -788,7 +788,7 @@ static enum CommandResult add_pattern(struct ColorLineList *top, const char *s, { if ((tmp->fg != fg) || (tmp->bg != bg)) { - mutt_free_color(tmp->fg, tmp->bg); + mutt_color_free(tmp->fg, tmp->bg); tmp->fg = fg; tmp->bg = bg; attr |= mutt_alloc_color(fg, bg); @@ -1244,10 +1244,10 @@ enum CommandResult mutt_parse_mono(struct Buffer *buf, struct Buffer *s, } /** - * mutt_free_color_list - Free a list of colours + * mutt_color_list_free - Free a list of colours * @param list ColorLine List */ -static void mutt_free_color_list(struct ColorLineList *list) +static void mutt_color_list_free(struct ColorLineList *list) { struct ColorLine *np = NULL, *tmp = NULL; STAILQ_FOREACH_SAFE(np, list, entries, tmp) @@ -1258,19 +1258,19 @@ static void mutt_free_color_list(struct ColorLineList *list) } /** - * mutt_free_colors - Free all the colours (on shutdown) + * mutt_colors_free - Free all the colours (on shutdown) */ -void mutt_free_colors(void) +void mutt_colors_free(void) { - mutt_free_color_list(&ColorAttachList); - mutt_free_color_list(&ColorBodyList); - mutt_free_color_list(&ColorHdrList); - mutt_free_color_list(&ColorIndexAuthorList); - mutt_free_color_list(&ColorIndexFlagsList); - mutt_free_color_list(&ColorIndexList); - mutt_free_color_list(&ColorIndexSubjectList); - mutt_free_color_list(&ColorIndexTagList); - mutt_free_color_list(&ColorStatusList); + mutt_color_list_free(&ColorAttachList); + mutt_color_list_free(&ColorBodyList); + mutt_color_list_free(&ColorHdrList); + mutt_color_list_free(&ColorIndexAuthorList); + mutt_color_list_free(&ColorIndexFlagsList); + mutt_color_list_free(&ColorIndexList); + mutt_color_list_free(&ColorIndexSubjectList); + mutt_color_list_free(&ColorIndexTagList); + mutt_color_list_free(&ColorStatusList); struct ColorList *cl = ColorList; struct ColorList *next = NULL; diff --git a/color.h b/color.h index 12a66a926..85c08b293 100644 --- a/color.h +++ b/color.h @@ -31,8 +31,8 @@ struct Buffer; void ci_start_color(void); int mutt_alloc_color(uint32_t fg, uint32_t bg); int mutt_combine_color(uint32_t fg_attr, uint32_t bg_attr); -void mutt_free_color(uint32_t fg, uint32_t bg); -void mutt_free_colors(void); +void mutt_color_free(uint32_t fg, uint32_t bg); +void mutt_colors_free(void); enum CommandResult mutt_parse_color(struct Buffer *buf, struct Buffer *s, unsigned long data, struct Buffer *err); enum CommandResult mutt_parse_mono(struct Buffer *buf, struct Buffer *s, unsigned long data, struct Buffer *err); enum CommandResult mutt_parse_uncolor(struct Buffer *buf, struct Buffer *s, unsigned long data, struct Buffer *err); diff --git a/compose.c b/compose.c index c8b15dcde..71adf89fc 100644 --- a/compose.c +++ b/compose.c @@ -1259,7 +1259,7 @@ int mutt_compose_menu(struct Email *e, char *fcc, size_t fcclen, struct Email *e /* attachments may have been added */ if (actx->idxlen && actx->idx[actx->idxlen - 1]->content->next) { - mutt_actx_free_entries(actx); + mutt_actx_entries_free(actx); mutt_update_compose_menu(actx, menu, true); } diff --git a/compress.c b/compress.c index d4566997a..6a28c2685 100644 --- a/compress.c +++ b/compress.c @@ -230,10 +230,10 @@ static struct CompressInfo *set_compress_info(struct Mailbox *m) } /** - * free_compress_info - Frees the compress info members and structure + * compress_info_free - Frees the compress info members and structure * @param m Mailbox to free compress_info for */ -static void free_compress_info(struct Mailbox *m) +static void compress_info_free(struct Mailbox *m) { if (!m || !m->compress_info) return; @@ -500,7 +500,7 @@ static int comp_mbox_open(struct Mailbox *m) cmo_fail: /* remove the partial uncompressed file */ remove(mailbox_path(m)); - free_compress_info(m); + compress_info_free(m); return -1; } @@ -579,7 +579,7 @@ cmoa_fail2: remove(mailbox_path(m)); cmoa_fail1: /* Free the compress_info to prevent close from trying to recompress */ - free_compress_info(m); + compress_info_free(m); return -1; } @@ -697,7 +697,7 @@ static int comp_mbox_close(struct Mailbox *m) const struct MxOps *ops = ci->child_ops; if (!ops) { - free_compress_info(m); + compress_info_free(m); return -1; } @@ -745,7 +745,7 @@ static int comp_mbox_close(struct Mailbox *m) } } - free_compress_info(m); + compress_info_free(m); return 0; } diff --git a/email/attach.c b/email/attach.c index 4c4c8df9f..b4cc1f053 100644 --- a/email/attach.c +++ b/email/attach.c @@ -97,10 +97,10 @@ void mutt_actx_add_body(struct AttachCtx *actx, struct Body *new_body) } /** - * mutt_actx_free_entries - Free entries in an Attachment Context + * mutt_actx_entries_free - Free entries in an Attachment Context * @param actx Attachment context */ -void mutt_actx_free_entries(struct AttachCtx *actx) +void mutt_actx_entries_free(struct AttachCtx *actx) { if (!actx) return; @@ -144,7 +144,7 @@ void mutt_actx_free(struct AttachCtx **ptr) struct AttachCtx *actx = *ptr; - mutt_actx_free_entries(actx); + mutt_actx_entries_free(actx); FREE(&actx->idx); FREE(&actx->v2r); FREE(&actx->fp_idx); diff --git a/email/attach.h b/email/attach.h index 0c38c37db..3316059fd 100644 --- a/email/attach.h +++ b/email/attach.h @@ -71,7 +71,7 @@ void mutt_actx_add_attach (struct AttachCtx *actx, struct AttachPt void mutt_actx_add_body (struct AttachCtx *actx, struct Body *new_body); void mutt_actx_add_fp (struct AttachCtx *actx, FILE *fp_new); void mutt_actx_free (struct AttachCtx **ptr); -void mutt_actx_free_entries(struct AttachCtx *actx); +void mutt_actx_entries_free(struct AttachCtx *actx); struct AttachCtx *mutt_actx_new (void); #endif /* MUTT_EMAIL_ATTACH_H */ diff --git a/email/rfc2231.c b/email/rfc2231.c index b571f9b62..aa6419d3b 100644 --- a/email/rfc2231.c +++ b/email/rfc2231.c @@ -164,10 +164,10 @@ static void list_insert(struct Rfc2231Parameter **list, struct Rfc2231Parameter } /** - * free_parameter - Free an Rfc2231Parameter + * parameter_free - Free an Rfc2231Parameter * @param[out] p Rfc2231Parameter to free */ -static void free_parameter(struct Rfc2231Parameter **p) +static void parameter_free(struct Rfc2231Parameter **p) { if (!p || !*p) return; @@ -213,7 +213,7 @@ static void join_continuations(struct ParameterList *pl, struct Rfc2231Parameter l += vl; struct Rfc2231Parameter *q = par->next; - free_parameter(&par); + parameter_free(&par); par = q; if (par) valp = par->value; diff --git a/init.c b/init.c index 6e15fa76c..b6f70ee79 100644 --- a/init.c +++ b/init.c @@ -2281,18 +2281,20 @@ static enum CommandResult parse_unalternates(struct Buffer *buf, struct Buffer * /** * mutt_attachmatch_free - Free an AttachMatch - Implements ::list_free_t + * @param ptr AttachMatch to free * * @note We don't free minor because it is either a pointer into major, * or a static string. */ -void mutt_attachmatch_free(struct AttachMatch **am) +void mutt_attachmatch_free(struct AttachMatch **ptr) { - if (!am || !*am) + if (!ptr || !*ptr) return; - regfree(&(*am)->minor_regex); - FREE(&(*am)->major); - FREE(am); + struct AttachMatch *am = *ptr; + regfree(&am->minor_regex); + FREE(&am->major); + FREE(ptr); } /** @@ -2879,9 +2881,9 @@ int mutt_extract_token(struct Buffer *dest, struct Buffer *tok, TokenFlags flags } /** - * mutt_free_opts - clean up before quitting + * mutt_opts_free - clean up before quitting */ -void mutt_free_opts(void) +void mutt_opts_free(void) { mutt_list_free(&MuttrcStack); @@ -2923,7 +2925,7 @@ void mutt_free_opts(void) mutt_list_free_type(&InlineAllow, (list_free_t) mutt_attachmatch_free); mutt_list_free_type(&InlineExclude, (list_free_t) mutt_attachmatch_free); - mutt_free_colors(); + mutt_colors_free(); FREE(&CurrentFolder); FREE(&HomeDir); @@ -2937,7 +2939,7 @@ void mutt_free_opts(void) mutt_delete_hooks(MUTT_HOOK_NO_FLAGS); mutt_hist_free(); - mutt_free_keys(); + mutt_keys_free(); mutt_regexlist_free(&NoSpamList); } diff --git a/keymap.c b/keymap.c index 72fcfa5b1..a0f348614 100644 --- a/keymap.c +++ b/keymap.c @@ -1592,9 +1592,9 @@ void mutt_what_key(void) } /** - * mutt_free_keys - Free the key maps + * mutt_keys_free - Free the key maps */ -void mutt_free_keys(void) +void mutt_keys_free(void) { struct Keymap *map = NULL; struct Keymap *next = NULL; diff --git a/keymap.h b/keymap.h index fd59f74d6..138f9216a 100644 --- a/keymap.h +++ b/keymap.h @@ -135,7 +135,7 @@ extern const struct Binding OpMix[]; extern const struct Binding OpAutocryptAcct[]; #endif -void mutt_free_keys(void); +void mutt_keys_free(void); enum CommandResult mutt_parse_bind(struct Buffer *buf, struct Buffer *s, unsigned long data, struct Buffer *err); enum CommandResult mutt_parse_exec(struct Buffer *buf, struct Buffer *s, unsigned long data, struct Buffer *err); diff --git a/maildir/maildir_private.h b/maildir/maildir_private.h index c00dbc335..7e41ac94b 100644 --- a/maildir/maildir_private.h +++ b/maildir/maildir_private.h @@ -100,7 +100,7 @@ int mh_mkstemp (struct Mailbox *m, FILE **fp, ch int mh_read_dir (struct Mailbox *m, const char *subdir); int mh_read_sequences (struct MhSequences *mhs, const char *path); MhSeqFlags mhs_check (struct MhSequences *mhs, int i); -void mhs_free_sequences (struct MhSequences *mhs); +void mhs_sequences_free (struct MhSequences *mhs); MhSeqFlags mhs_set (struct MhSequences *mhs, int i, MhSeqFlags f); mode_t mh_umask (struct Mailbox *m); void mh_update_maildir (struct Maildir *md, struct MhSequences *mhs); diff --git a/maildir/mh.c b/maildir/mh.c index d04351170..10d4a9b8a 100644 --- a/maildir/mh.c +++ b/maildir/mh.c @@ -73,10 +73,10 @@ static void mhs_alloc(struct MhSequences *mhs, int i) } /** - * mhs_free_sequences - Free some sequences + * mhs_sequences_free - Free some sequences * @param mhs Sequences to free */ -void mhs_free_sequences(struct MhSequences *mhs) +void mhs_sequences_free(struct MhSequences *mhs) { FREE(&mhs->flags); } @@ -252,7 +252,7 @@ void mh_update_sequences(struct Mailbox *m) if (replied) mhs_write_one_sequence(fp_new, &mhs, MH_SEQ_REPLIED, NONULL(C_MhSeqReplied)); - mhs_free_sequences(&mhs); + mhs_sequences_free(&mhs); /* try to commit the changes - no guarantee here */ mutt_file_fclose(&fp_new); @@ -335,7 +335,7 @@ int mh_read_sequences(struct MhSequences *mhs, const char *path) { if (mh_read_token(t, &first, &last) < 0) { - mhs_free_sequences(mhs); + mhs_sequences_free(mhs); rc = -1; goto out; } @@ -466,7 +466,7 @@ static int mh_mbox_check_stats(struct Mailbox *m, int flags) } } - mhs_free_sequences(&mhs); + mhs_sequences_free(&mhs); dirp = opendir(mailbox_path(m)); if (dirp) @@ -666,7 +666,7 @@ int mh_mbox_check(struct Mailbox *m, int *index_hint) if (mh_read_sequences(&mhs, mailbox_path(m)) < 0) return -1; mh_update_maildir(md, &mhs); - mhs_free_sequences(&mhs); + mhs_sequences_free(&mhs); /* check for modifications and adjust flags */ fnames = mutt_hash_new(count, MUTT_HASH_NO_FLAGS); diff --git a/maildir/shared.c b/maildir/shared.c index 2676943c7..3f8c27350 100644 --- a/maildir/shared.c +++ b/maildir/shared.c @@ -254,26 +254,35 @@ static void mh_sequences_add_one(struct Mailbox *m, int n, bool unseen, bool fla } /** - * maildir_free_entry - Free a Maildir object - * @param[out] md Maildir to free + * maildir_entry_new - Create a new Maildir entry + * @retval ptr New Maildir entry */ -static void maildir_free_entry(struct Maildir **md) +static struct Maildir *maildir_entry_new(void) { - if (!md || !*md) + return mutt_mem_calloc(1, sizeof(struct Maildir)); +} + +/** + * maildir_entry_free - Free a Maildir object + * @param[out] ptr Maildir to free + */ +static void maildir_entry_free(struct Maildir **ptr) +{ + if (!ptr || !*ptr) return; - FREE(&(*md)->canon_fname); - if ((*md)->email) - email_free(&(*md)->email); + struct Maildir *md = *ptr; + FREE(&md->canon_fname); + email_free(&md->email); - FREE(md); + FREE(ptr); } /** - * maildir_free_maildir - Free a Maildir list + * maildir_free - Free a Maildir list * @param[out] md Maildir list to free */ -static void maildir_free_maildir(struct Maildir **md) +static void maildir_free(struct Maildir **md) { if (!md || !*md) return; @@ -283,7 +292,7 @@ static void maildir_free_maildir(struct Maildir **md) for (p = *md; p; p = q) { q = p->next; - maildir_free_entry(&p); + maildir_entry_free(&p); } } @@ -385,7 +394,7 @@ int maildir_parse_dir(struct Mailbox *m, struct Maildir ***last, else e->path = mutt_str_strdup(de->d_name); - entry = mutt_mem_calloc(1, sizeof(struct Maildir)); + entry = maildir_entry_new(); entry->email = e; entry->inode = de->d_ino; **last = entry; @@ -455,7 +464,7 @@ int maildir_move_to_mailbox(struct Mailbox *m, struct Maildir **ptr) if (m->msg_count > oldmsgcount) num = m->msg_count - oldmsgcount; - maildir_free_maildir(ptr); + maildir_free(ptr); return num; } @@ -839,11 +848,11 @@ int mh_read_dir(struct Mailbox *m, const char *subdir) { if (mh_read_sequences(&mhs, mailbox_path(m)) < 0) { - maildir_free_maildir(&md); + maildir_free(&md); return -1; } mh_update_maildir(md, &mhs); - mhs_free_sequences(&mhs); + mhs_sequences_free(&mhs); } maildir_move_to_mailbox(m, &md); diff --git a/main.c b/main.c index 2ab5a4835..22a58044b 100644 --- a/main.c +++ b/main.c @@ -1277,8 +1277,8 @@ main_exit: mutt_buffer_pool_free(); mutt_envlist_free(); mutt_browser_cleanup(); - mutt_free_opts(); - mutt_free_keys(); + mutt_opts_free(); + mutt_keys_free(); neomutt_free(&NeoMutt); cs_free(&Config); return rc; diff --git a/mutt.h b/mutt.h index 63431d0db..b765775a5 100644 --- a/mutt.h +++ b/mutt.h @@ -141,7 +141,7 @@ struct AttachMatch char *mutt_compile_help(char *buf, size_t buflen, enum MenuType menu, const struct Mapping *items); int mutt_extract_token(struct Buffer *dest, struct Buffer *tok, TokenFlags flags); -void mutt_free_opts(void); +void mutt_opts_free(void); enum QuadOption query_quadoption(enum QuadOption opt, const char *prompt); int mutt_label_complete(char *buf, size_t buflen, int numtabs); int mutt_command_complete(char *buf, size_t buflen, int pos, int numtabs); diff --git a/mutt/charset.c b/mutt/charset.c index f6e89385e..900aea320 100644 --- a/mutt/charset.c +++ b/mutt/charset.c @@ -79,6 +79,35 @@ TAILQ_HEAD(LookupList, Lookup); static struct LookupList Lookups = TAILQ_HEAD_INITIALIZER(Lookups); +/** + * lookup_new - Create a new Lookup + * @retval ptr New Lookup + */ +struct Lookup *lookup_new(void) +{ + return mutt_mem_calloc(1, sizeof(struct Lookup)); +} + +/** + * lookup_free - Free a Lookup + * @param ptr Lookup to free + */ +void lookup_free(struct Lookup **ptr) +{ + if (!ptr || !*ptr) + return; + + struct Lookup *l = *ptr; + FREE(&l->replacement); + FREE(&l->regex.pattern); + if (l->regex.regex) + regfree(l->regex.regex); + FREE(&l->regex.regex); + FREE(&l->regex); + + FREE(ptr); +} + // clang-format off /** * PreferredMimeNames - Lookup table of preferred charsets @@ -462,7 +491,7 @@ bool mutt_ch_lookup_add(enum LookupType type, const char *pat, return false; } - struct Lookup *l = mutt_mem_calloc(1, sizeof(struct Lookup)); + struct Lookup *l = lookup_new(); l->type = type; l->replacement = mutt_str_strdup(replace); l->regex.pattern = mutt_str_strdup(pat); @@ -487,13 +516,7 @@ void mutt_ch_lookup_remove(void) TAILQ_FOREACH_SAFE(l, &Lookups, entries, tmp) { TAILQ_REMOVE(&Lookups, l, entries); - FREE(&l->replacement); - FREE(&l->regex.pattern); - if (l->regex.regex) - regfree(l->regex.regex); - FREE(&l->regex.regex); - FREE(&l->regex); - FREE(&l); + lookup_free(&l); } } diff --git a/myvar.c b/myvar.c index d38ba5a8d..b2c1957f3 100644 --- a/myvar.c +++ b/myvar.c @@ -33,6 +33,37 @@ struct MyVarList MyVars = TAILQ_HEAD_INITIALIZER(MyVars); +/** + * myvar_new - Create a new MyVar + * @param name Variable name + * @param value Variable value + * @retval ptr New MyVar + * + * @note The name and value will be copied. + */ +static struct MyVar *myvar_new(const char *name, const char *value) +{ + struct MyVar *myv = mutt_mem_calloc(1, sizeof(struct MyVar)); + myv->name = mutt_str_strdup(name); + myv->value = mutt_str_strdup(value); + return myv; +} + +/** + * myvar_free - Free a MyVar + * @param ptr MyVar to free + */ +void myvar_free(struct MyVar **ptr) +{ + if (!ptr || !*ptr) + return; + + struct MyVar *myv = *ptr; + FREE(&myv->name); + FREE(&myv->value); + FREE(ptr); +} + /** * myvar_get - Get the value of a "my_" variable * @param var Variable name @@ -70,9 +101,7 @@ void myvar_set(const char *var, const char *val) } } - myv = mutt_mem_calloc(1, sizeof(struct MyVar)); - myv->name = mutt_str_strdup(var); - myv->value = mutt_str_strdup(val); + myv = myvar_new(var, val); TAILQ_INSERT_TAIL(&MyVars, myv, entries); } @@ -89,9 +118,7 @@ void myvar_del(const char *var) if (mutt_str_strcmp(myv->name, var) == 0) { TAILQ_REMOVE(&MyVars, myv, entries); - FREE(&myv->name); - FREE(&myv->value); - FREE(&myv); + myvar_free(&myv); return; } } diff --git a/ncrypt/crypt_gpgme.c b/ncrypt/crypt_gpgme.c index 97e3b4405..4bf238bfa 100644 --- a/ncrypt/crypt_gpgme.c +++ b/ncrypt/crypt_gpgme.c @@ -633,10 +633,10 @@ static struct CryptKeyInfo *crypt_copy_key(struct CryptKeyInfo *key) } /** - * crypt_free_key - Release all the keys in a list + * crypt_key_free - Release all the keys in a list * @param[out] keylist List of keys */ -static void crypt_free_key(struct CryptKeyInfo **keylist) +static void crypt_key_free(struct CryptKeyInfo **keylist) { if (!keylist) return; @@ -1067,10 +1067,10 @@ static void create_recipient_string(const char *keylist, struct Buffer *recpstri #else /** - * free_recipient_set - Free a set of recipients + * recipient_set_free - Free a set of recipients * @param p_rset Set of GPGME keys */ -static void free_recipient_set(gpgme_key_t **p_rset) +static void recipient_set_free(gpgme_key_t **p_rset) { gpgme_key_t *rset = NULL; @@ -1138,7 +1138,7 @@ static gpgme_key_t *create_recipient_set(const char *keylist, bool use_smime) { mutt_error(_("error adding recipient '%s': %s"), buf, gpgme_strerror(err)); rset[rset_n] = NULL; - free_recipient_set(&rset); + recipient_set_free(&rset); gpgme_release(context); return NULL; } @@ -1324,7 +1324,7 @@ cleanup: #if (GPGME_VERSION_NUMBER >= 0x010b00) /* gpgme >= 1.11.0 */ mutt_buffer_pool_release(&recpstring); #else - free_recipient_set(&rset); + recipient_set_free(&rset); #endif gpgme_release(ctx); gpgme_data_release(ciphertext); @@ -4984,7 +4984,7 @@ static struct CryptKeyInfo *crypt_getkeybyaddr(struct Address *a, } } - crypt_free_key(&keys); + crypt_key_free(&keys); if (matches) { @@ -5009,7 +5009,7 @@ static struct CryptKeyInfo *crypt_getkeybyaddr(struct Address *a, k = crypt_select_key(matches, a, NULL, app, forced_valid); } - crypt_free_key(&matches); + crypt_key_free(&matches); } else k = NULL; @@ -5075,12 +5075,12 @@ static struct CryptKeyInfo *crypt_getkeybystr(const char *p, KeyFlags abilities, } FREE(&pfcopy); - crypt_free_key(&keys); + crypt_key_free(&keys); if (matches) { k = crypt_select_key(matches, NULL, p, app, forced_valid); - crypt_free_key(&matches); + crypt_key_free(&matches); return k; } @@ -5272,7 +5272,7 @@ static char *find_keys(struct AddressList *addrlist, unsigned int app, bool oppe key_selected = true; - crypt_free_key(&k_info); + crypt_key_free(&k_info); mutt_addrlist_clear(&hookal); if (crypt_hook) @@ -5386,8 +5386,8 @@ int mutt_gpgme_select_secret_key(struct Buffer *keyid) rc = 0; cleanup: - crypt_free_key(&choice); - crypt_free_key(&results); + crypt_key_free(&choice); + crypt_key_free(&results); gpgme_release(ctx); return rc; } @@ -5446,7 +5446,7 @@ struct Body *pgp_gpgme_make_key_attachment(void) att->length = sb.st_size; bail: - crypt_free_key(&key); + crypt_key_free(&key); gpgme_data_release(keydata); gpgme_release(context); @@ -5614,7 +5614,7 @@ static int gpgme_send_menu(struct Email *e, int is_smime) char input_signas[128]; snprintf(input_signas, sizeof(input_signas), "0x%s", crypt_fpr_or_lkeyid(p)); mutt_str_replace(is_smime ? &C_SmimeDefaultKey : &C_PgpSignAs, input_signas); - crypt_free_key(&p); + crypt_key_free(&p); e->security |= SEC_SIGN; } diff --git a/ncrypt/pgp.c b/ncrypt/pgp.c index 0019d21ec..265cb2c83 100644 --- a/ncrypt/pgp.c +++ b/ncrypt/pgp.c @@ -1511,7 +1511,7 @@ char *pgp_class_find_keys(struct AddressList *addrlist, bool oppenc_mode) key_selected = true; - pgp_free_key(&k_info); + pgp_key_free(&k_info); mutt_addrlist_clear(&hookal); if (crypt_hook) @@ -1963,7 +1963,7 @@ int pgp_class_send_menu(struct Email *e) char input_signas[128]; snprintf(input_signas, sizeof(input_signas), "0x%s", pgp_fpr_or_lkeyid(p)); mutt_str_replace(&C_PgpSignAs, input_signas); - pgp_free_key(&p); + pgp_key_free(&p); e->security |= SEC_SIGN; diff --git a/ncrypt/pgpkey.c b/ncrypt/pgpkey.c index 7cd6b74f7..e9518821a 100644 --- a/ncrypt/pgpkey.c +++ b/ncrypt/pgpkey.c @@ -886,7 +886,7 @@ struct Body *pgp_class_make_key_attachment(void) return NULL; snprintf(tmp, sizeof(tmp), "0x%s", pgp_fpr_or_lkeyid(pgp_principal_key(key))); - pgp_free_key(&key); + pgp_key_free(&key); mutt_mktemp(tempf, sizeof(tempf)); @@ -1070,7 +1070,7 @@ struct PgpKeyInfo *pgp_getkeybyaddr(struct Address *a, KeyFlags abilities, } } - pgp_free_key(&keys); + pgp_key_free(&keys); if (matches) { @@ -1104,7 +1104,7 @@ struct PgpKeyInfo *pgp_getkeybyaddr(struct Address *a, KeyFlags abilities, pgp_remove_key(&matches, k); } - pgp_free_key(&matches); + pgp_key_free(&matches); return k; } @@ -1187,14 +1187,14 @@ struct PgpKeyInfo *pgp_getkeybystr(const char *cp, KeyFlags abilities, enum PgpR } } - pgp_free_key(&keys); + pgp_key_free(&keys); if (matches) { k = pgp_select_key(matches, NULL, p); if (k) pgp_remove_key(&matches, k); - pgp_free_key(&matches); + pgp_key_free(&matches); } else { diff --git a/ncrypt/pgplib.c b/ncrypt/pgplib.c index 1049d5654..a90f5b96c 100644 --- a/ncrypt/pgplib.c +++ b/ncrypt/pgplib.c @@ -112,10 +112,10 @@ short pgp_get_abilities(unsigned char type) } /** - * pgp_free_uid - Free a PGP UID + * pgp_uid_free - Free a PGP UID * @param[out] upp PGP UID to free */ -static void pgp_free_uid(struct PgpUid **upp) +static void pgp_uid_free(struct PgpUid **upp) { struct PgpUid *up = NULL, *q = NULL; @@ -156,17 +156,17 @@ struct PgpUid *pgp_copy_uids(struct PgpUid *up, struct PgpKeyInfo *parent) } /** - * free_key - Free a PGP Key info + * key_free - Free a PGP Key info * @param[out] kpp PGP Key info to free */ -static void free_key(struct PgpKeyInfo **kpp) +static void key_free(struct PgpKeyInfo **kpp) { if (!kpp || !*kpp) return; struct PgpKeyInfo *kp = *kpp; - pgp_free_uid(&kp->address); + pgp_uid_free(&kp->address); FREE(&kp->keyid); FREE(&kp->fingerprint); FREE(kpp); @@ -207,10 +207,10 @@ struct PgpKeyInfo *pgp_remove_key(struct PgpKeyInfo **klist, struct PgpKeyInfo * } /** - * pgp_free_key - Free a PGP key info + * pgp_key_free - Free a PGP key info * @param[out] kpp PGP key info to free */ -void pgp_free_key(struct PgpKeyInfo **kpp) +void pgp_key_free(struct PgpKeyInfo **kpp) { if (!kpp || !*kpp) return; @@ -232,11 +232,11 @@ void pgp_free_key(struct PgpKeyInfo **kpp) for (q = p->next; q && q->parent == p; q = r) { r = q->next; - free_key(&q); + key_free(&q); } - free_key(&p->parent); - free_key(&p); + key_free(&p->parent); + key_free(&p); } *kpp = NULL; diff --git a/ncrypt/pgplib.h b/ncrypt/pgplib.h index b55d7108f..d575e77ad 100644 --- a/ncrypt/pgplib.h +++ b/ncrypt/pgplib.h @@ -65,7 +65,7 @@ bool pgp_canencrypt(unsigned char type); bool pgp_cansign(unsigned char type); short pgp_get_abilities(unsigned char type); -void pgp_free_key(struct PgpKeyInfo **kpp); +void pgp_key_free(struct PgpKeyInfo **kpp); struct PgpKeyInfo *pgp_remove_key(struct PgpKeyInfo **klist, struct PgpKeyInfo *key); diff --git a/ncrypt/smime.c b/ncrypt/smime.c index 596dcdaab..882c19bd7 100644 --- a/ncrypt/smime.c +++ b/ncrypt/smime.c @@ -107,10 +107,10 @@ static char SmimeCertToUse[PATH_MAX]; static char fp_smime_intermediateToUse[PATH_MAX]; /** - * smime_free_key - Free a list of SMIME keys + * smime_key_free - Free a list of SMIME keys * @param[out] keylist List of keys to free */ -static void smime_free_key(struct SmimeKey **keylist) +static void smime_key_free(struct SmimeKey **keylist) { if (!keylist) return; @@ -684,7 +684,7 @@ static struct SmimeKey *smime_parse_key(char *buf) * but anything less than that is an error. */ if (field < 3) { - smime_free_key(&key); + smime_key_free(&key); return NULL; } @@ -763,7 +763,7 @@ static struct SmimeKey *smime_get_key_by_hash(char *hash, bool only_public_key) } } - smime_free_key(&results); + smime_key_free(&results); return match; } @@ -820,7 +820,7 @@ static struct SmimeKey *smime_get_key_by_addr(char *mailbox, KeyFlags abilities, } } - smime_free_key(&results); + smime_key_free(&results); if (matches) { @@ -842,7 +842,7 @@ static struct SmimeKey *smime_get_key_by_addr(char *mailbox, KeyFlags abilities, return_key = smime_copy_key(smime_select_key(matches, mailbox)); } - smime_free_key(&matches); + smime_key_free(&matches); } return return_key; @@ -883,12 +883,12 @@ static struct SmimeKey *smime_get_key_by_str(char *str, KeyFlags abilities, bool } } - smime_free_key(&results); + smime_key_free(&results); if (matches) { return_key = smime_copy_key(smime_select_key(matches, str)); - smime_free_key(&matches); + smime_key_free(&matches); } return return_key; @@ -953,7 +953,7 @@ static void getkeys(char *mailbox) if (*SmimeKeyToUse && (mutt_str_strcasecmp(k, SmimeKeyToUse + mutt_str_strlen(C_SmimeKeys) + 1) == 0)) { - smime_free_key(&key); + smime_key_free(&key); return; } else @@ -967,7 +967,7 @@ static void getkeys(char *mailbox) if (mutt_str_strcasecmp(k, C_SmimeDefaultKey) != 0) smime_class_void_passphrase(); - smime_free_key(&key); + smime_key_free(&key); return; } @@ -1063,7 +1063,7 @@ char *smime_class_find_keys(struct AddressList *al, bool oppenc_mode) sprintf(keylist + keylist_used, "%s%s", keylist_used ? " " : "", keyid); keylist_used = mutt_str_strlen(keylist); - smime_free_key(&key); + smime_key_free(&key); } return keylist; } @@ -1742,7 +1742,7 @@ struct Body *smime_class_sign_message(struct Body *a) snprintf(fp_smime_intermediateToUse, sizeof(fp_smime_intermediateToUse), "%s/%s", NONULL(C_SmimeCertificates), intermediates); - smime_free_key(&signas_key); + smime_key_free(&signas_key); pid = smime_invoke_sign(&fp_smime_in, NULL, &fp_smime_err, -1, fileno(fp_smime_out), -1, filetosign); @@ -2363,7 +2363,7 @@ int smime_class_send_menu(struct Email *e) if (key) { mutt_str_replace(&C_SmimeSignAs, key->hash); - smime_free_key(&key); + smime_key_free(&key); e->security |= SEC_SIGN; diff --git a/pager.c b/pager.c index 53bf717c4..0b6b492cd 100644 --- a/pager.c +++ b/pager.c @@ -1278,7 +1278,7 @@ static int grok_ansi(unsigned char *buf, int pos, struct AnsiAttr *a) { #ifdef HAVE_COLOR if (a->pair != -1) - mutt_free_color(a->fg, a->bg); + mutt_color_free(a->fg, a->bg); #endif a->attr = ANSI_OFF; a->pair = -1; @@ -1309,7 +1309,7 @@ static int grok_ansi(unsigned char *buf, int pos, struct AnsiAttr *a) { #ifdef HAVE_COLOR if (a->pair != -1) - mutt_free_color(a->fg, a->bg); + mutt_color_free(a->fg, a->bg); #endif a->attr = ANSI_OFF; a->pair = -1; @@ -1319,7 +1319,7 @@ static int grok_ansi(unsigned char *buf, int pos, struct AnsiAttr *a) { #ifdef HAVE_COLOR if (a->pair != -1) - mutt_free_color(a->fg, a->bg); + mutt_color_free(a->fg, a->bg); #endif a->pair = -1; a->attr |= ANSI_COLOR; @@ -1330,7 +1330,7 @@ static int grok_ansi(unsigned char *buf, int pos, struct AnsiAttr *a) { #ifdef HAVE_COLOR if (a->pair != -1) - mutt_free_color(a->fg, a->bg); + mutt_color_free(a->fg, a->bg); #endif a->pair = -1; a->attr |= ANSI_COLOR; diff --git a/recvattach.c b/recvattach.c index 1c4924e9c..9650a2c98 100644 --- a/recvattach.c +++ b/recvattach.c @@ -1120,7 +1120,7 @@ static void recvattach_edit_content_type(struct AttachCtx *actx, /* Editing the content type can rewrite the body structure. */ for (int i = 0; i < actx->idxlen; i++) actx->idx[i]->content = NULL; - mutt_actx_free_entries(actx); + mutt_actx_entries_free(actx); mutt_update_recvattach_menu(actx, menu, true); } diff --git a/remailer.c b/remailer.c index eb4d8f12c..323060100 100644 --- a/remailer.c +++ b/remailer.c @@ -249,10 +249,10 @@ static struct Remailer **mix_type2_list(size_t *l) } /** - * mix_free_type2_list - Free a Remailer List + * mix_type2_list_free - Free a Remailer List * @param[out] ttlp Remailer List to free */ -static void mix_free_type2_list(struct Remailer ***ttlp) +static void mix_type2_list_free(struct Remailer ***ttlp) { struct Remailer **type2_list = *ttlp; @@ -766,7 +766,7 @@ void mix_make_chain(struct ListHead *chainhead) } } - mix_free_type2_list(&type2_list); + mix_type2_list_free(&type2_list); FREE(&coords); FREE(&chain); } diff --git a/test/Makefile.autosetup b/test/Makefile.autosetup index b42af1d8a..15eff087a 100644 --- a/test/Makefile.autosetup +++ b/test/Makefile.autosetup @@ -24,7 +24,7 @@ ADDRESS_OBJS = test/address/mutt_addr_cat.o \ test/address/mutt_addrlist_write.o ATTACH_OBJS = test/attach/mutt_actx_add_fp.o \ - test/attach/mutt_actx_free_entries.o \ + test/attach/mutt_actx_entries_free.o \ test/attach/mutt_actx_free.o \ test/attach/mutt_actx_add_body.o \ test/attach/mutt_actx_add_attach.o diff --git a/test/attach/mutt_actx_free_entries.c b/test/attach/mutt_actx_entries_free.c similarity index 79% rename from test/attach/mutt_actx_free_entries.c rename to test/attach/mutt_actx_entries_free.c index 68c372a30..23f792cbb 100644 --- a/test/attach/mutt_actx_free_entries.c +++ b/test/attach/mutt_actx_entries_free.c @@ -1,6 +1,6 @@ /** * @file - * Test code for mutt_actx_free_entries() + * Test code for mutt_actx_entries_free() * * @authors * Copyright (C) 2019 Richard Russon @@ -27,12 +27,12 @@ #include "address/lib.h" #include "email/lib.h" -void test_mutt_actx_free_entries(void) +void test_mutt_actx_entries_free(void) { - // void mutt_actx_free_entries(struct AttachCtx *actx); + // void mutt_actx_entries_free(struct AttachCtx *actx); { - mutt_actx_free_entries(NULL); - TEST_CHECK_(1, "mutt_actx_free_entries(NULL)"); + mutt_actx_entries_free(NULL); + TEST_CHECK_(1, "mutt_actx_entries_free(NULL)"); } } diff --git a/test/main.c b/test/main.c index eebf2ec89..ce2d9e54c 100644 --- a/test/main.c +++ b/test/main.c @@ -55,7 +55,7 @@ NEOMUTT_TEST_ITEM(test_mutt_actx_add_body) \ NEOMUTT_TEST_ITEM(test_mutt_actx_add_fp) \ NEOMUTT_TEST_ITEM(test_mutt_actx_free) \ - NEOMUTT_TEST_ITEM(test_mutt_actx_free_entries) \ + NEOMUTT_TEST_ITEM(test_mutt_actx_entries_free) \ NEOMUTT_TEST_ITEM(test_mutt_b64_buffer_decode) \ NEOMUTT_TEST_ITEM(test_mutt_b64_buffer_encode) \ NEOMUTT_TEST_ITEM(test_mutt_b64_decode) \