NeoMutt
2025-12-11-1009-ga75d9e
Teaching an old dog new tricks
DOXYGEN
Toggle main menu visibility
Loading...
Searching...
No Matches
data.c
Go to the documentation of this file.
1
22
28
29
#include "config.h"
30
#include <string.h>
31
#include "
mutt/lib.h
"
32
#include "
data.h
"
33
38
void
completion_data_free_match_strings
(
struct
CompletionData
*cd)
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
53
void
completion_data_free
(
struct
CompletionData
**ptr)
54
{
55
if
(!ptr || !*ptr)
56
return
;
57
58
struct
CompletionData
*cd = *ptr;
59
60
completion_data_free_match_strings
(cd);
61
62
FREE
(&cd->
match_list
);
63
64
FREE
(ptr);
65
}
66
71
struct
CompletionData
*
completion_data_new
(
void
)
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
85
void
completion_data_reset
(
struct
CompletionData
*cd)
86
{
87
if
(!cd)
88
return
;
89
90
completion_data_free_match_strings
(cd);
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
}
completion_data_new
struct CompletionData * completion_data_new(void)
Create new Completion Data.
Definition
data.c:71
completion_data_free
void completion_data_free(struct CompletionData **ptr)
Free the Completion Data.
Definition
data.c:53
completion_data_free_match_strings
void completion_data_free_match_strings(struct CompletionData *cd)
Free the Completion strings.
Definition
data.c:38
completion_data_reset
void completion_data_reset(struct CompletionData *cd)
Wipe the stored Completion Data.
Definition
data.c:85
data.h
String auto-completion data.
FREE
#define FREE(x)
Free memory and set the pointer to NULL.
Definition
memory.h:68
MUTT_MEM_CALLOC
#define MUTT_MEM_CALLOC(n, type)
Definition
memory.h:52
lib.h
Convenience wrapper for the library headers.
CompletionData
State data for auto-completion.
Definition
data.h:32
CompletionData::match_list_len
int match_list_len
Enough space for all of the config items.
Definition
data.h:37
CompletionData::free_match_strings
bool free_match_strings
Should the strings in match_list be freed?
Definition
data.h:38
CompletionData::user_typed
char user_typed[1024]
Initial string that starts completion.
Definition
data.h:33
CompletionData::completed
char completed[256]
Completed string (command or variable).
Definition
data.h:35
CompletionData::num_matched
int num_matched
Number of matches for completion.
Definition
data.h:34
CompletionData::match_list
const char ** match_list
Matching strings.
Definition
data.h:36