Commit e9ccf689 authored by Aaron Schrab's avatar Aaron Schrab

Consistently use mutt_buffer_init function

Despite the existence of the mutt_buffer_init function, most
initializations were instead done with memset.  Use the specific
function instead to make it easier if later changes are made to how the
initialization should be done.
parent be1044cd
......@@ -619,7 +619,7 @@ void mutt_enter_command (void)
return;
err.dsize = STRING;
err.data = safe_malloc(err.dsize);
memset (&token, 0, sizeof (token));
mutt_buffer_init (&token);
r = mutt_parse_rc_line (buffer, &token, &err);
FREE (&token.data);
if (err.data[0])
......
......@@ -52,8 +52,8 @@ int mutt_parse_hook (BUFFER *buf, BUFFER *s, unsigned long data, BUFFER *err)
pattern_t *pat = NULL;
char path[_POSIX_PATH_MAX];
memset (&pattern, 0, sizeof (pattern));
memset (&command, 0, sizeof (command));
mutt_buffer_init (&pattern);
mutt_buffer_init (&command);
if (*s->dptr == '!')
{
......@@ -284,7 +284,7 @@ void mutt_folder_hook (char *path)
err.dsize = STRING;
err.data = safe_malloc (err.dsize);
memset (&token, 0, sizeof (token));
mutt_buffer_init (&token);
for (; tmp; tmp = tmp->next)
{
if(!tmp->command)
......@@ -335,7 +335,7 @@ void mutt_message_hook (CONTEXT *ctx, HEADER *hdr, int type)
err.dsize = STRING;
err.data = safe_malloc (err.dsize);
memset (&token, 0, sizeof (token));
mutt_buffer_init (&token);
for (hook = Hooks; hook; hook = hook->next)
{
if(!hook->command)
......@@ -478,7 +478,7 @@ void mutt_account_hook (const char* url)
err.dsize = STRING;
err.data = safe_malloc (err.dsize);
memset (&token, 0, sizeof (token));
mutt_buffer_init (&token);
for (hook = Hooks; hook; hook = hook->next)
{
......
......@@ -777,7 +777,7 @@ static void cmd_parse_lsub (IMAP_DATA* idata, char* s)
url.user = NULL;
url_ciss_tostring (&url, buf + 11, sizeof (buf) - 10, 0);
safe_strcat (buf, sizeof (buf), "\"");
memset (&token, 0, sizeof (token));
mutt_buffer_init (&token);
err.data = errstr;
err.dsize = sizeof (errstr);
if (mutt_parse_rc_line (buf, &token, &err))
......
......@@ -1787,7 +1787,7 @@ int imap_search (CONTEXT* ctx, const pattern_t* pat)
if (!do_search (pat, 1))
return 0;
memset (&buf, 0, sizeof (buf));
mutt_buffer_init (&buf);
mutt_buffer_addstr (&buf, "UID SEARCH ");
if (imap_compile_search (pat, &buf) < 0)
{
......@@ -1827,7 +1827,7 @@ int imap_subscribe (char *path, int subscribe)
if (option (OPTIMAPCHECKSUBSCRIBED))
{
memset (&token, 0, sizeof (token));
mutt_buffer_init (&token);
err.data = errstr;
err.dsize = sizeof (errstr);
snprintf (mbox, sizeof (mbox), "%smailboxes \"%s\"",
......
......@@ -770,8 +770,8 @@ int imap_copy_messages (CONTEXT* ctx, HEADER* h, char* dest, int delete)
/* loop in case of TRYCREATE */
do
{
memset (&sync_cmd, 0, sizeof (sync_cmd));
memset (&cmd, 0, sizeof (cmd));
mutt_buffer_init (&sync_cmd);
mutt_buffer_init (&cmd);
/* Null HEADER* means copy tagged messages */
if (!h)
......
......@@ -254,7 +254,7 @@ int mutt_extract_token (BUFFER *dest, BUFFER *tok, int flags)
tok->dptr = pc + 1;
/* read line */
memset (&expn, 0, sizeof (expn));
mutt_buffer_init (&expn);
expn.data = mutt_read_line (NULL, &expn.dsize, fp, &line, 0);
safe_fclose (&fp);
mutt_wait_filter (pid);
......@@ -706,7 +706,7 @@ static int parse_spam_list (BUFFER *buf, BUFFER *s, unsigned long data, BUFFER *
{
BUFFER templ;
memset(&templ, 0, sizeof(templ));
mutt_buffer_init (&templ);
/* Insist on at least one parameter */
if (!MoreArgs(s))
......@@ -1444,7 +1444,7 @@ static int parse_my_hdr (BUFFER *buf, BUFFER *s, unsigned long data, BUFFER *err
/* replace the old value */
FREE (&tmp->data);
tmp->data = buf->data;
memset (buf, 0, sizeof (BUFFER));
mutt_buffer_init (buf);
return 0;
}
if (!tmp->next)
......@@ -1459,7 +1459,7 @@ static int parse_my_hdr (BUFFER *buf, BUFFER *s, unsigned long data, BUFFER *err
UserHeader = tmp;
}
tmp->data = buf->data;
memset (buf, 0, sizeof (BUFFER));
mutt_buffer_init (buf);
return 0;
}
......@@ -2254,7 +2254,7 @@ static int source_rc (const char *rcfile, BUFFER *err)
return (-1);
}
memset (&token, 0, sizeof (token));
mutt_buffer_init (&token);
while ((linebuf = mutt_read_line (linebuf, &buflen, f, &line, M_CONT)) != NULL)
{
conv=ConfigCharset && (*ConfigCharset) && Charset;
......@@ -2338,7 +2338,7 @@ int mutt_parse_rc_line (/* const */ char *line, BUFFER *token, BUFFER *err)
if (!line || !*line)
return 0;
memset (&expn, 0, sizeof (expn));
mutt_buffer_init (&expn);
expn.data = expn.dptr = line;
expn.dsize = mutt_strlen (line);
......@@ -2734,10 +2734,10 @@ int mutt_query_variables (LIST *queries)
char command[STRING];
BUFFER err, token;
memset (&err, 0, sizeof (err));
memset (&token, 0, sizeof (token));
mutt_buffer_init (&err);
mutt_buffer_init (&token);
err.dsize = STRING;
err.data = safe_malloc (err.dsize);
......@@ -2769,10 +2769,10 @@ int mutt_dump_variables (void)
char command[STRING];
BUFFER err, token;
memset (&err, 0, sizeof (err));
memset (&token, 0, sizeof (token));
mutt_buffer_init (&err);
mutt_buffer_init (&token);
err.dsize = STRING;
err.data = safe_malloc (err.dsize);
......@@ -2848,10 +2848,10 @@ static int mutt_execute_commands (LIST *p)
{
BUFFER err, token;
memset (&err, 0, sizeof (err));
mutt_buffer_init (&err);
err.dsize = STRING;
err.data = safe_malloc (err.dsize);
memset (&token, 0, sizeof (token));
mutt_buffer_init (&token);
for (; p; p = p->next)
{
if (mutt_parse_rc_line (p->data, &token, &err) != 0)
......@@ -2894,7 +2894,7 @@ void mutt_init (int skip_sys_rc, LIST *commands)
int i, default_rc = 0, need_pause = 0;
BUFFER err;
memset (&err, 0, sizeof (err));
mutt_buffer_init (&err);
err.dsize = STRING;
err.data = safe_malloc(err.dsize);
err.dptr = err.data;
......@@ -3020,11 +3020,11 @@ void mutt_init (int skip_sys_rc, LIST *commands)
snprintf (buffer, sizeof (buffer), "Reply-To: %s", p);
memset (&buf, 0, sizeof (buf));
mutt_buffer_init (&buf);
buf.data = buf.dptr = buffer;
buf.dsize = mutt_strlen (buffer);
memset (&token, 0, sizeof (token));
mutt_buffer_init (&token);
parse_my_hdr (&token, &buf, 0, &err);
FREE (&token.data);
}
......
......@@ -866,7 +866,7 @@ static char *parse_keymap (int *menu, BUFFER *s, int maxmenus, int *nummenus, BU
int i=0;
char *p, *q;
memset (&buf, 0, sizeof (buf));
mutt_buffer_init (&buf);
/* menu name */
mutt_extract_token (&buf, s, 0);
......
......@@ -257,7 +257,7 @@ static int eat_regexp (pattern_t *pat, BUFFER *s, BUFFER *err)
char errmsg[STRING];
int r;
memset (&buf, 0, sizeof (buf));
mutt_buffer_init (&buf);
if (mutt_extract_token (&buf, s, M_TOKEN_PATTERN | M_TOKEN_COMMENT) != 0 ||
!buf.data)
{
......@@ -575,7 +575,7 @@ static int eat_date (pattern_t *pat, BUFFER *s, BUFFER *err)
BUFFER buffer;
struct tm min, max;
memset (&buffer, 0, sizeof (buffer));
mutt_buffer_init (&buffer);
if (mutt_extract_token (&buffer, s, M_TOKEN_COMMENT | M_TOKEN_PATTERN) != 0
|| !buffer.data)
{
......@@ -779,7 +779,7 @@ pattern_t *mutt_pattern_comp (/* const */ char *s, int flags, BUFFER *err)
char *buf;
BUFFER ps;
memset (&ps, 0, sizeof (ps));
mutt_buffer_init (&ps);
ps.dptr = s;
ps.dsize = mutt_strlen (s);
......@@ -1302,7 +1302,7 @@ int mutt_pattern_func (int op, char *prompt)
simple = safe_strdup (buf);
mutt_check_simple (buf, sizeof (buf), NONULL (SimpleSearch));
memset (&err, 0, sizeof(err));
mutt_buffer_init (&err);
err.dsize = STRING;
err.data = safe_malloc(err.dsize);
if ((pat = mutt_pattern_comp (buf, M_FULL_MSG, &err)) == NULL)
......@@ -1434,7 +1434,7 @@ int mutt_search_command (int cur, int op)
if (!SearchPattern || mutt_strcmp (temp, LastSearchExpn))
{
BUFFER err;
memset(&err, 0, sizeof(err));
mutt_buffer_init (&err);
set_option (OPTSEARCHINVALID);
strfcpy (LastSearch, buf, sizeof (LastSearch));
mutt_message _("Compiling search pattern...");
......
......@@ -76,7 +76,7 @@ int mutt_parse_score (BUFFER *buf, BUFFER *s, unsigned long data, BUFFER *err)
return (-1);
}
pattern = buf->data;
memset (buf, 0, sizeof (BUFFER));
mutt_buffer_init (buf);
mutt_extract_token (buf, s, 0);
if (MoreArgs (s))
{
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment