From: Kevin McCarthy Date: Tue, 8 Oct 2019 05:07:40 +0000 (+0800) Subject: Convert parse_path_(un)list to use buffer pool for path X-Git-Tag: 2019-10-25~15^2~1 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=85c55cff0f7f1fa2c054a17125904444d3da2cea;p=neomutt Convert parse_path_(un)list to use buffer pool for path 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 --- diff --git a/init.c b/init.c index bcac0a9d8..d621d9d43 100644 --- a/init.c +++ b/init.c @@ -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; } @@ -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; }