NeoMutt  2024-12-12-14-g7b49f7
Teaching an old dog new tricks
DOXYGEN
Loading...
Searching...
No Matches
pattern_data.c
Go to the documentation of this file.
1
29#include "config.h"
30#include <stddef.h>
31#include "pattern_data.h"
32
38{
39 struct PatternData *pd = mutt_mem_calloc(1, sizeof(struct PatternData));
40
41 ARRAY_INIT(&pd->entries);
42
43 return pd;
44}
45
49void pattern_data_free(struct Menu *menu, void **ptr)
50{
51 if (!ptr || !*ptr)
52 return;
53
54 struct PatternData *pd = *ptr;
55
56 struct PatternEntry *pe = NULL;
57 ARRAY_FOREACH(pe, &pd->entries)
58 {
59 FREE(&pe->tag);
60 FREE(&pe->expr);
61 FREE(&pe->desc);
62 }
63
64 ARRAY_FREE(&pd->entries);
65 FREE(ptr);
66}
#define ARRAY_FOREACH(elem, head)
Iterate over all elements of the array.
Definition: array.h:212
#define ARRAY_FREE(head)
Release all memory.
Definition: array.h:204
#define ARRAY_INIT(head)
Initialize an array.
Definition: array.h:65
void pattern_data_free(struct Menu *menu, void **ptr)
Free Pattern Data - Implements Menu::mdata_free() -.
Definition: pattern_data.c:49
void * mutt_mem_calloc(size_t nmemb, size_t size)
Allocate zeroed memory on the heap.
Definition: memory.c:76
#define FREE(x)
Definition: memory.h:55
struct PatternData * pattern_data_new(void)
Create new Pattern Data.
Definition: pattern_data.c:37
Private Pattern Data.
Definition: lib.h:79
Data to pass to the Pattern Functions.
Definition: pattern_data.h:47
struct Menu * menu
Pattern Menu.
Definition: pattern_data.h:51
struct PatternEntryArray entries
Patterns for the Menu.
Definition: pattern_data.h:52
A line in the Pattern Completion menu.
Definition: pattern_data.h:35
const char * desc
Description of pattern.
Definition: pattern_data.h:39
const char * tag
Copied to buffer if selected.
Definition: pattern_data.h:37
const char * expr
Displayed in the menu.
Definition: pattern_data.h:38