struct Envelope *mime_headers = e->content->mime_headers;
if (!mime_headers)
mime_headers = e->content->mime_headers = mutt_env_new();
- mutt_free_autocrypthdr(&mime_headers->autocrypt_gossip);
+ mutt_autocrypthdr_free(&mime_headers->autocrypt_gossip);
struct AddressList recips = TAILQ_HEAD_INITIALIZER(recips);
if (keydata)
{
- struct AutocryptHeader *gossip = mutt_new_autocrypthdr();
+ struct AutocryptHeader *gossip = mutt_autocrypthdr_new();
gossip->addr = mutt_str_strdup(peer->email_addr);
gossip->keydata = mutt_str_strdup(keydata);
gossip->next = mime_headers->autocrypt_gossip;
if (keydata)
{
- struct AutocryptHeader *gossip = mutt_new_autocrypthdr();
+ struct AutocryptHeader *gossip = mutt_autocrypthdr_new();
gossip->addr = mutt_str_strdup(addr);
gossip->keydata = mutt_str_strdup(keydata);
gossip->next = mime_headers->autocrypt_gossip;
/**
* mutt_autocrypt_db_account_free - Free an AutocryptAccount
- * @param account Account to free
+ * @param ptr Account to free
*/
-void mutt_autocrypt_db_account_free(struct AutocryptAccount **account)
+void mutt_autocrypt_db_account_free(struct AutocryptAccount **ptr)
{
- if (!account || !*account)
+ if (!ptr || !*ptr)
return;
- FREE(&(*account)->email_addr);
- FREE(&(*account)->keyid);
- FREE(&(*account)->keydata);
- FREE(account);
+
+ struct AutocryptAccount *ac = *ptr;
+ FREE(&ac->email_addr);
+ FREE(&ac->keyid);
+ FREE(&ac->keydata);
+ FREE(ptr);
}
/**
/**
* mutt_autocrypt_db_peer_free - Free an AutocryptPeer
- * @param peer AutocryptPeer to free
+ * @param ptr AutocryptPeer to free
*/
-void mutt_autocrypt_db_peer_free(struct AutocryptPeer **peer)
+void mutt_autocrypt_db_peer_free(struct AutocryptPeer **ptr)
{
- if (!peer || !*peer)
+ if (!ptr || !*ptr)
return;
- FREE(&(*peer)->email_addr);
- FREE(&(*peer)->keyid);
- FREE(&(*peer)->keydata);
- FREE(&(*peer)->gossip_keyid);
- FREE(&(*peer)->gossip_keydata);
- FREE(peer);
+
+ struct AutocryptPeer *peer = *ptr;
+ FREE(&peer->email_addr);
+ FREE(&peer->keyid);
+ FREE(&peer->keydata);
+ FREE(&peer->gossip_keyid);
+ FREE(&peer->gossip_keydata);
+ FREE(ptr);
}
/**
/**
* mutt_autocrypt_db_peer_history_free - Free an AutocryptPeerHistory
- * @param peerhist AutocryptPeerHistory to free
+ * @param ptr AutocryptPeerHistory to free
*/
-void mutt_autocrypt_db_peer_history_free(struct AutocryptPeerHistory **peerhist)
+void mutt_autocrypt_db_peer_history_free(struct AutocryptPeerHistory **ptr)
{
- if (!peerhist || !*peerhist)
+ if (!ptr || !*ptr)
return;
- FREE(&(*peerhist)->peer_email_addr);
- FREE(&(*peerhist)->email_msgid);
- FREE(&(*peerhist)->keydata);
- FREE(peerhist);
+
+ struct AutocryptPeerHistory *ph = *ptr;
+ FREE(&ph->peer_email_addr);
+ FREE(&ph->email_msgid);
+ FREE(&ph->keydata);
+ FREE(ptr);
}
/**
/**
* mutt_autocrypt_db_gossip_history_free - Free an AutocryptGossipHistory
- * @param gossip_hist AutocryptGossipHistory to free
+ * @param ptr AutocryptGossipHistory to free
*/
-void mutt_autocrypt_db_gossip_history_free(struct AutocryptGossipHistory **gossip_hist)
+void mutt_autocrypt_db_gossip_history_free(struct AutocryptGossipHistory **ptr)
{
- if (!gossip_hist || !*gossip_hist)
+ if (!ptr || !*ptr)
return;
- FREE(&(*gossip_hist)->peer_email_addr);
- FREE(&(*gossip_hist)->sender_email_addr);
- FREE(&(*gossip_hist)->email_msgid);
- FREE(&(*gossip_hist)->gossip_keydata);
- FREE(gossip_hist);
+
+ struct AutocryptGossipHistory *gh = *ptr;
+ FREE(&gh->peer_email_addr);
+ FREE(&gh->sender_email_addr);
+ FREE(&gh->email_msgid);
+ FREE(&gh->gossip_keydata);
+ FREE(ptr);
}
/**
void mutt_autocrypt_scan_mailboxes(void);
int mutt_autocrypt_db_account_delete(struct AutocryptAccount *acct);
-void mutt_autocrypt_db_account_free(struct AutocryptAccount **account);
+void mutt_autocrypt_db_account_free(struct AutocryptAccount **ptr);
int mutt_autocrypt_db_account_get(struct Address *addr, struct AutocryptAccount **account);
int mutt_autocrypt_db_account_get_all(struct AutocryptAccount ***accounts, int *num_accounts);
int mutt_autocrypt_db_account_insert(struct Address *addr, const char *keyid, const char *keydata, bool prefer_encrypt);
struct AutocryptAccount * mutt_autocrypt_db_account_new(void);
int mutt_autocrypt_db_account_update(struct AutocryptAccount *acct);
void mutt_autocrypt_db_close(void);
-void mutt_autocrypt_db_gossip_history_free(struct AutocryptGossipHistory **gossip_hist);
+void mutt_autocrypt_db_gossip_history_free(struct AutocryptGossipHistory **ptr);
int mutt_autocrypt_db_gossip_history_insert(struct Address *addr, struct AutocryptGossipHistory *gossip_hist);
struct AutocryptGossipHistory *mutt_autocrypt_db_gossip_history_new(void);
int mutt_autocrypt_db_init(bool can_create);
void mutt_autocrypt_db_normalize_addr(struct Address *a);
void mutt_autocrypt_db_normalize_addrlist(struct AddressList *al);
-void mutt_autocrypt_db_peer_free(struct AutocryptPeer **peer);
+void mutt_autocrypt_db_peer_free(struct AutocryptPeer **ptr);
int mutt_autocrypt_db_peer_get(struct Address *addr, struct AutocryptPeer **peer);
-void mutt_autocrypt_db_peer_history_free(struct AutocryptPeerHistory **peerhist);
+void mutt_autocrypt_db_peer_history_free(struct AutocryptPeerHistory **ptr);
int mutt_autocrypt_db_peer_history_insert(struct Address *addr, struct AutocryptPeerHistory *peerhist);
struct AutocryptPeerHistory * mutt_autocrypt_db_peer_history_new(void);
int mutt_autocrypt_db_peer_insert(struct Address *addr, struct AutocryptPeer *peer);
#define COLOR_QUOTE_INIT 8
/**
- * new_color_line - Create a new ColorLine
+ * color_line_new - Create a new ColorLine
* @retval ptr Newly allocated ColorLine
*/
-static struct ColorLine *new_color_line(void)
+static struct ColorLine *color_line_new(void)
{
struct ColorLine *p = mutt_mem_calloc(1, sizeof(struct ColorLine));
}
/**
- * free_color_line - Free a ColorLine
- * @param tmp ColorLine to free
+ * color_line_free - Free a ColorLine
+ * @param ptr ColorLine to free
* @param free_colors If true, free its colours too
*/
-static void free_color_line(struct ColorLine *tmp, bool free_colors)
+static void color_line_free(struct ColorLine **ptr, bool free_colors)
{
- if (!tmp)
+ if (!ptr || !*ptr)
return;
+ struct ColorLine *cl = *ptr;
+
#ifdef HAVE_COLOR
- if (free_colors && (tmp->fg != COLOR_UNSET) && (tmp->bg != COLOR_UNSET))
- mutt_free_color(tmp->fg, tmp->bg);
+ if (free_colors && (cl->fg != COLOR_UNSET) && (cl->bg != COLOR_UNSET))
+ mutt_free_color(cl->fg, cl->bg);
#endif
- /* we should really introduce a container type for regular expressions. */
- regfree(&tmp->regex);
- mutt_pattern_free(&tmp->color_pattern);
- FREE(&tmp->pattern);
- FREE(&tmp);
+ regfree(&cl->regex);
+ mutt_pattern_free(&cl->color_pattern);
+ FREE(&cl->pattern);
+ FREE(ptr);
}
/**
{
*do_cache = true;
}
- free_color_line(np, parse_uncolor);
+ color_line_free(&np, parse_uncolor);
np = tmp;
}
STAILQ_INIT(cl);
STAILQ_REMOVE_AFTER(cl, tmp, entries);
else
STAILQ_REMOVE_HEAD(cl, entries);
- free_color_line(np, parse_uncolor);
+ color_line_free(&np, parse_uncolor);
break;
}
tmp = np;
}
else
{
- tmp = new_color_line();
+ tmp = color_line_new();
if (is_index)
{
struct Buffer *buf = mutt_buffer_pool_get();
mutt_buffer_pool_release(&buf);
if (!tmp->color_pattern)
{
- free_color_line(tmp, true);
+ color_line_free(&tmp, true);
return MUTT_CMD_ERROR;
}
}
if (r != 0)
{
regerror(r, &tmp->regex, err->data, err->dsize);
- free_color_line(tmp, true);
+ color_line_free(&tmp, true);
return MUTT_CMD_ERROR;
}
}
STAILQ_FOREACH_SAFE(np, list, entries, tmp)
{
STAILQ_REMOVE(list, np, ColorLine, entries);
- free_color_line(np, true);
+ color_line_free(&np, true);
}
}
menu->redraw_data = rd;
mutt_menu_push_current(menu);
- struct AttachCtx *actx = mutt_mem_calloc(sizeof(struct AttachCtx), 1);
+ struct AttachCtx *actx = mutt_actx_new();
actx->email = e;
mutt_update_compose_menu(actx, menu, true);
actx->body_len = 0;
}
+/**
+ * mutt_actx_new - Create a new Attachment Context
+ * @retval ptr New Attachment Context
+ */
+struct AttachCtx *mutt_actx_new(void)
+{
+ return mutt_mem_calloc(1, sizeof(struct AttachCtx));
+}
+
/**
* mutt_actx_free - Free an Attachment Context
- * @param[out] pactx Attachment context
+ * @param[out] ptr Attachment context
*/
-void mutt_actx_free(struct AttachCtx **pactx)
+void mutt_actx_free(struct AttachCtx **ptr)
{
- if (!pactx || !*pactx)
+ if (!ptr || !*ptr)
return;
- struct AttachCtx *actx = *pactx;
+ struct AttachCtx *actx = *ptr;
mutt_actx_free_entries(actx);
FREE(&actx->idx);
FREE(&actx->v2r);
FREE(&actx->fp_idx);
FREE(&actx->body_idx);
- FREE(pactx);
+ FREE(ptr);
}
short body_max; ///< Size of Body array
};
-void mutt_actx_add_attach (struct AttachCtx *actx, struct AttachPtr *attach);
-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 **pactx);
-void mutt_actx_free_entries(struct AttachCtx *actx);
+void mutt_actx_add_attach (struct AttachCtx *actx, struct AttachPtr *attach);
+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);
+struct AttachCtx *mutt_actx_new (void);
#endif /* MUTT_EMAIL_ATTACH_H */
#ifdef USE_AUTOCRYPT
/**
- * mutt_free_autocrypthdr - Free an AutocryptHeader
+ * mutt_autocrypthdr_new - Create a new AutocryptHeader
+ * @retval ptr New AutocryptHeader
+ */
+void mutt_autocrypthdr_new(void)
+{
+ return mutt_mem_calloc(1, sizeof(struct AutocryptHeader));
+}
+
+/**
+ * mutt_autocrypthdr_free - Free an AutocryptHeader
* @param p AutocryptHeader to free
*/
-void mutt_free_autocrypthdr(struct AutocryptHeader **p)
+void mutt_autocrypthdr_free(struct AutocryptHeader **p)
{
if (!p)
return;
mutt_list_free(&env->userhdrs);
#ifdef USE_AUTOCRYPT
- mutt_free_autocrypthdr(&env->autocrypt);
- mutt_free_autocrypthdr(&env->autocrypt_gossip);
+ mutt_autocrypthdr_free(&env->autocrypt);
+ mutt_autocrypthdr_free(&env->autocrypt_gossip);
#endif
FREE(ptr);
void mutt_env_to_local (struct Envelope *e);
#ifdef USE_AUTOCRYPT
-#define mutt_new_autocrypthdr() mutt_mem_calloc(1, sizeof(struct AutocryptHeader))
-void mutt_free_autocrypthdr(struct AutocryptHeader **p);
+struct AutocryptHeader *mutt_autocrypthdr_new(void);
+void mutt_autocrypthdr_free(struct AutocryptHeader **p);
#endif
#endif /* MUTT_EMAIL_ENVELOPE_H */
*/
static struct AutocryptHeader *parse_autocrypt(struct AutocryptHeader *head, const char *s)
{
- struct AutocryptHeader *autocrypt = mutt_new_autocrypthdr();
+ struct AutocryptHeader *autocrypt = mutt_autocrypthdr_new();
autocrypt->next = head;
struct ParameterList pl = TAILQ_HEAD_INITIALIZER(pl);
{
mutt_autocrypt_process_autocrypt_header(e, env);
/* No sense in taking up memory after the header is processed */
- mutt_free_autocrypthdr(&env->autocrypt);
+ mutt_autocrypthdr_free(&env->autocrypt);
}
#endif
}
}
/**
- * new_parameter - Create a new Rfc2231Parameter
+ * parameter_new - Create a new Rfc2231Parameter
* @retval ptr Newly allocated Rfc2231Parameter
*/
-static struct Rfc2231Parameter *new_parameter(void)
+static struct Rfc2231Parameter *parameter_new(void)
{
return mutt_mem_calloc(1, sizeof(struct Rfc2231Parameter));
}
if (mutt_str_atoi(s, &index) != 0)
index = INT_MAX;
- conttmp = new_parameter();
+ conttmp = parameter_new();
conttmp->attribute = np->attribute;
conttmp->value = np->value;
conttmp->encoded = encoded;
return true;
}
+/**
+ * mutt_attachmatch_new - Create a new AttachMatch
+ * @retval ptr New AttachMatch
+ */
+static struct AttachMatch *mutt_attachmatch_new(void)
+{
+ return mutt_mem_calloc(1, sizeof(struct AttachMatch));
+}
+
/**
* parse_attach_list - Parse the "attachments" command
* @param buf Buffer for temporary storage
if (!buf->data || (*buf->data == '\0'))
continue;
- a = mutt_mem_malloc(sizeof(struct AttachMatch));
+ a = mutt_attachmatch_new();
/* some cheap hacks that I expect to remove */
if (mutt_str_strcasecmp(buf->data, "any") == 0)
}
/**
- * mutt_free_attachmatch - Free an AttachMatch - Implements ::list_free_t
+ * mutt_attachmatch_free - Free an AttachMatch - Implements ::list_free_t
*
* @note We don't free minor because it is either a pointer into major,
* or a static string.
*/
-void mutt_free_attachmatch(struct AttachMatch **am)
+void mutt_attachmatch_free(struct AttachMatch **am)
{
if (!am || !*am)
return;
if (op == '*')
{
- mutt_list_free_type(&AttachAllow, (list_free_t) mutt_free_attachmatch);
- mutt_list_free_type(&AttachExclude, (list_free_t) mutt_free_attachmatch);
- mutt_list_free_type(&InlineAllow, (list_free_t) mutt_free_attachmatch);
- mutt_list_free_type(&InlineExclude, (list_free_t) mutt_free_attachmatch);
+ mutt_list_free_type(&AttachAllow, (list_free_t) mutt_attachmatch_free);
+ mutt_list_free_type(&AttachExclude, (list_free_t) mutt_attachmatch_free);
+ mutt_list_free_type(&InlineAllow, (list_free_t) mutt_attachmatch_free);
+ mutt_list_free_type(&InlineExclude, (list_free_t) mutt_attachmatch_free);
attachments_clean();
return 0;
}
mutt_list_free(&UserHeader);
/* Lists of AttachMatch */
- mutt_list_free_type(&AttachAllow, (list_free_t) mutt_free_attachmatch);
- mutt_list_free_type(&AttachExclude, (list_free_t) mutt_free_attachmatch);
- mutt_list_free_type(&InlineAllow, (list_free_t) mutt_free_attachmatch);
- mutt_list_free_type(&InlineExclude, (list_free_t) mutt_free_attachmatch);
+ mutt_list_free_type(&AttachAllow, (list_free_t) mutt_attachmatch_free);
+ mutt_list_free_type(&AttachExclude, (list_free_t) mutt_attachmatch_free);
+ 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();
}
/**
- * new_hash - Create a new Hash table
+ * hash_new - Create a new Hash table
* @param nelem Number of elements it should contain
* @retval ptr New Hash table
*
* The Hash table can contain more elements than nelem, but they will be
* chained together.
*/
-static struct Hash *new_hash(size_t nelem)
+static struct Hash *hash_new(size_t nelem)
{
struct Hash *table = mutt_mem_calloc(1, sizeof(struct Hash));
if (nelem == 0)
*/
struct Hash *mutt_hash_new(size_t nelem, HashFlags flags)
{
- struct Hash *table = new_hash(nelem);
+ struct Hash *table = hash_new(nelem);
if (flags & MUTT_HASH_STRCASECMP)
{
table->gen_hash = gen_case_string_hash;
*/
struct Hash *mutt_hash_int_new(size_t nelem, HashFlags flags)
{
- struct Hash *table = new_hash(nelem);
+ struct Hash *table = hash_new(nelem);
table->gen_hash = gen_int_hash;
table->cmp_key = cmp_int_key;
if (flags & MUTT_HASH_ALLOW_DUPS)
}
/**
- * pgp_new_keyinfo - Create a new PgpKeyInfo
+ * pgp_keyinfo_new - Create a new PgpKeyInfo
* @retval ptr New PgpKeyInfo
*/
-struct PgpKeyInfo *pgp_new_keyinfo(void)
+struct PgpKeyInfo *pgp_keyinfo_new(void)
{
return mutt_mem_calloc(1, sizeof(struct PgpKeyInfo));
}
struct PgpKeyInfo *pgp_remove_key(struct PgpKeyInfo **klist, struct PgpKeyInfo *key);
-struct PgpKeyInfo *pgp_new_keyinfo(void);
+struct PgpKeyInfo *pgp_keyinfo_new(void);
#endif /* MUTT_NCRYPT_PGPLIB_H */
}
/**
- * new_class_color - Create a new quoting colour
+ * class_color_new - Create a new quoting colour
* @param[in] qc Class of quoted text
* @param[in,out] q_level Quote level
*/
-static void new_class_color(struct QClass *qc, int *q_level)
+static void class_color_new(struct QClass *qc, int *q_level)
{
qc->index = (*q_level)++;
qc->color = ColorQuote[qc->index % ColorQuoteUsed];
ptr->down = tmp;
tmp->up = ptr;
- new_class_color(tmp, q_level);
+ class_color_new(tmp, q_level);
return tmp;
}
qc->prefix = mutt_mem_calloc(1, length + 1);
strncpy(qc->prefix, qptr, length);
qc->length = length;
- new_class_color(qc, q_level);
+ class_color_new(qc, q_level);
if (*quote_list)
{
menu->help = mutt_compile_help(helpstr, sizeof(helpstr), MENU_ATTACH, AttachHelp);
mutt_menu_push_current(menu);
- struct AttachCtx *actx = mutt_mem_calloc(1, sizeof(struct AttachCtx));
+ struct AttachCtx *actx = mutt_actx_new();
actx->email = e;
actx->fp_root = msg->fp;
mutt_update_recvattach_menu(actx, menu, true);