NeoMutt  2023-05-17-16-g61469c
Teaching an old dog new tricks
DOXYGEN
data.c
Go to the documentation of this file.
1
29#include "config.h"
30#include "mutt/lib.h"
31#include "data.h"
32
38{
39 if (!cd || !cd->free_match_strings)
40 return;
41
42 for (int i = 0; i < cd->num_matched; i++)
43 FREE(&cd->match_list[i]);
44
45 cd->free_match_strings = false;
46}
47
53{
54 if (!ptr || !*ptr)
55 return;
56
57 struct CompletionData *cd = *ptr;
58
60
61 FREE(&cd->match_list);
62
63 FREE(ptr);
64}
65
71{
72 struct CompletionData *cd = mutt_mem_calloc(1, sizeof(struct CompletionData));
73
74 cd->match_list_len = 512;
75 cd->match_list = mutt_mem_calloc(cd->match_list_len, sizeof(char *));
76
77 return cd;
78}
79
85{
86 if (!cd)
87 return;
88
90
91 memset(cd->user_typed, 0, sizeof(cd->user_typed));
92 memset(cd->completed, 0, sizeof(cd->completed));
93 memset(cd->match_list, 0, cd->match_list_len * sizeof(char *));
94 cd->num_matched = 0;
95 cd->free_match_strings = false;
96}
struct CompletionData * completion_data_new(void)
Create new Completion Data.
Definition: data.c:70
void completion_data_free(struct CompletionData **ptr)
Free the Completion Data.
Definition: data.c:52
void completion_data_free_match_strings(struct CompletionData *cd)
Free the Completion strings.
Definition: data.c:37
void completion_data_reset(struct CompletionData *cd)
Wipe the stored Completion Data.
Definition: data.c:84
String auto-completion data.
void * mutt_mem_calloc(size_t nmemb, size_t size)
Allocate zeroed memory on the heap.
Definition: memory.c:50
#define FREE(x)
Definition: memory.h:43
Convenience wrapper for the library headers.
State data for auto-completion.
Definition: data.h:32
int match_list_len
Enough space for all of the config items.
Definition: data.h:37
bool free_match_strings
Should the strings in match_list be freed?
Definition: data.h:38
char user_typed[1024]
Initial string that starts completion.
Definition: data.h:33
char completed[256]
Completed string (command or variable)
Definition: data.h:35
int num_matched
Number of matches for completion.
Definition: data.h:34
const char ** match_list
Matching strings.
Definition: data.h:36