From 83d929dce35cc0239b3785a0ba3c3943c8a0eed0 Mon Sep 17 00:00:00 2001 From: Guyzmo Date: Wed, 8 Feb 2017 19:41:00 +0100 Subject: [PATCH] Make the heap method and datatype a plain list Instead of a useless typedef, making all the stack operations work on plain LIST types. N.B.: I used *heap* when I really meant *stack*. Signed-off-by: Guyzmo --- init.c | 12 ++++++------ mutt.h | 16 ++++------------ muttlib.c | 18 ++++++------------ 3 files changed, 16 insertions(+), 30 deletions(-) diff --git a/init.c b/init.c index c591c93b8..303a96663 100644 --- a/init.c +++ b/init.c @@ -2607,10 +2607,10 @@ static int parse_set (BUFFER *tmp, BUFFER *s, unsigned long data, BUFFER *err) return (r); } -/* Heap structure +/* Stack structure * FILO designed to contain the list of config files that have been sourced * and avoid cyclic sourcing */ -static HEAP *MuttrcHeap; +static LIST *MuttrcStack; /* Use POSIX functions to convert a path to absolute, relatively to another path * Args: @@ -2676,15 +2676,15 @@ static int source_rc (const char *rcfile_path, BUFFER *err) if (rcfile[rcfilelen-1] != '|') { - if (!to_absolute_path(rcfile, mutt_front_heap(MuttrcHeap))) + if (!to_absolute_path(rcfile, mutt_front_list(MuttrcStack))) { mutt_error("Error: impossible to build path of '%s'.", rcfile_path); return (-1); } - if (!MuttrcHeap || mutt_find_heap(MuttrcHeap, rcfile) == NULL) + if (!MuttrcStack || mutt_find_list(MuttrcStack, rcfile) == NULL) { - mutt_push_heap(&MuttrcHeap, rcfile); + mutt_push_list(&MuttrcStack, rcfile); } else { @@ -2744,7 +2744,7 @@ static int source_rc (const char *rcfile_path, BUFFER *err) rc = -1; } - mutt_pop_heap(&MuttrcHeap); + mutt_pop_list(&MuttrcStack); return (rc); } diff --git a/mutt.h b/mutt.h index 92f3aa422..8b2958ecd 100644 --- a/mutt.h +++ b/mutt.h @@ -640,8 +640,6 @@ typedef struct list_t struct list_t *next; } LIST; -typedef struct list_t HEAP; - typedef struct rx_list_t { REGEXP *rx; @@ -661,11 +659,6 @@ inline LIST *mutt_new_list() return safe_calloc (1, sizeof (LIST)); } -inline HEAP *mutt_new_heap() -{ - return safe_calloc (1, sizeof (HEAP)); -} - inline RX_LIST *mutt_new_rx_list() { return safe_calloc (1, sizeof (RX_LIST)); @@ -689,11 +682,10 @@ LIST *mutt_add_list_n (LIST*, const void *, size_t); LIST *mutt_find_list (LIST *, const char *); int mutt_remove_from_rx_list (RX_LIST **l, const char *str); -/* handle heap */ -void mutt_push_heap(HEAP **head, const char *data); -int mutt_pop_heap(HEAP **head); -const char *mutt_front_heap(HEAP *head); -HEAP *mutt_find_heap(HEAP *head, const char *data); +/* handle stack */ +void mutt_push_list(LIST **head, const char *data); +int mutt_pop_list(LIST **head); +const char *mutt_front_list(LIST *head); void mutt_init (int, LIST *); diff --git a/muttlib.c b/muttlib.c index ce94e7bfe..8b315ac50 100644 --- a/muttlib.c +++ b/muttlib.c @@ -57,7 +57,6 @@ * External definitions for inline functions in mutt.h */ extern LIST *mutt_new_list(); -extern HEAP *mutt_new_heap(); extern RX_LIST *mutt_new_rx_list(); extern SPAM_LIST *mutt_new_spam_list(); extern PARAMETER *mutt_new_parameter(); @@ -295,18 +294,18 @@ LIST *mutt_find_list (LIST *l, const char *data) return NULL; } -void mutt_push_heap(HEAP **head, const char *data) +void mutt_push_list(LIST **head, const char *data) { - HEAP *tmp; - tmp = safe_malloc(sizeof(HEAP)); + LIST *tmp; + tmp = safe_malloc(sizeof(LIST)); tmp->data = safe_strdup(data); tmp->next = *head; *head = tmp; } -int mutt_pop_heap(HEAP **head) +int mutt_pop_list(LIST **head) { - HEAP *elt = *head; + LIST *elt = *head; if (!elt) return 0; *head = elt->next; @@ -315,18 +314,13 @@ int mutt_pop_heap(HEAP **head) return 1; } -const char *mutt_front_heap(HEAP *head) +const char *mutt_front_list(LIST *head) { if (!head || !head->data) return ""; return head->data; } -HEAP *mutt_find_heap(HEAP *head, const char *data) -{ - return (HEAP *) mutt_find_list((LIST *) head, data); -} - int mutt_remove_from_rx_list (RX_LIST **l, const char *str) { RX_LIST *p, *last = NULL; -- 2.40.0