Skip to content

Commit

Permalink
Convert parse_path_(un)list to use buffer pool for path
Browse files Browse the repository at this point in the history
Don't use the buf parameter to avoid stretching it out, as it's used
for the entire rc parsing, and typically just holds command names.

Co-authored-by: Richard Russon <[email protected]>
  • Loading branch information
kevin8t8 and flatcap committed Oct 8, 2019
1 parent c7b94de commit 85c55cf
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions init.c
Original file line number Diff line number Diff line change
Expand Up @@ -1453,15 +1453,15 @@ static enum CommandResult parse_my_hdr(struct Buffer *buf, struct Buffer *s,
static enum CommandResult parse_path_list(struct Buffer *buf, struct Buffer *s,
unsigned long data, struct Buffer *err)
{
char path[PATH_MAX];
struct Buffer *path = mutt_buffer_pool_get();

do
{
mutt_extract_token(buf, s, MUTT_TOKEN_NO_FLAGS);
mutt_str_strfcpy(path, buf->data, sizeof(path));
mutt_expand_path(path, sizeof(path));
add_to_stailq((struct ListHead *) data, path);
mutt_extract_token(path, s, MUTT_TOKEN_NO_FLAGS);
mutt_buffer_expand_path(path);
add_to_stailq((struct ListHead *) data, mutt_b2s(path));
} while (MoreArgs(s));
mutt_buffer_pool_release(&path);

return MUTT_CMD_SUCCESS;
}
Expand All @@ -1474,21 +1474,21 @@ static enum CommandResult parse_path_list(struct Buffer *buf, struct Buffer *s,
static enum CommandResult parse_path_unlist(struct Buffer *buf, struct Buffer *s,
unsigned long data, struct Buffer *err)
{
char path[PATH_MAX];
struct Buffer *path = mutt_buffer_pool_get();

do
{
mutt_extract_token(buf, s, MUTT_TOKEN_NO_FLAGS);
mutt_extract_token(path, s, MUTT_TOKEN_NO_FLAGS);
/* Check for deletion of entire list */
if (mutt_str_strcmp(buf->data, "*") == 0)
if (mutt_str_strcmp(mutt_b2s(path), "*") == 0)
{
mutt_list_free((struct ListHead *) data);
break;
}
mutt_str_strfcpy(path, buf->data, sizeof(path));
mutt_expand_path(path, sizeof(path));
remove_from_stailq((struct ListHead *) data, path);
mutt_buffer_expand_path(path);
remove_from_stailq((struct ListHead *) data, mutt_b2s(path));
} while (MoreArgs(s));
mutt_buffer_pool_release(&path);

return MUTT_CMD_SUCCESS;
}
Expand Down

0 comments on commit 85c55cf

Please sign in to comment.