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