NeoMutt  2023-05-17-16-g61469c
Teaching an old dog new tricks
DOXYGEN
data.c File Reference

String auto-completion data. More...

#include "config.h"
#include "mutt/lib.h"
#include "data.h"
+ Include dependency graph for data.c:

Go to the source code of this file.

Functions

void completion_data_free_match_strings (struct CompletionData *cd)
 Free the Completion strings. More...
 
void completion_data_free (struct CompletionData **ptr)
 Free the Completion Data. More...
 
struct CompletionDatacompletion_data_new (void)
 Create new Completion Data. More...
 
void completion_data_reset (struct CompletionData *cd)
 Wipe the stored Completion Data. More...
 

Detailed Description

String auto-completion data.

Authors
  • Richard Russon

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/.

Definition in file data.c.

Function Documentation

◆ completion_data_free_match_strings()

void completion_data_free_match_strings ( struct CompletionData cd)

Free the Completion strings.

Parameters
cdCompletion Data

Definition at line 37 of file data.c.

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}
#define FREE(x)
Definition: memory.h:43
bool free_match_strings
Should the strings in match_list be freed?
Definition: data.h:38
int num_matched
Number of matches for completion.
Definition: data.h:34
const char ** match_list
Matching strings.
Definition: data.h:36
+ Here is the caller graph for this function:

◆ completion_data_free()

void completion_data_free ( struct CompletionData **  ptr)

Free the Completion Data.

Parameters
ptrCompletionData to free

Definition at line 52 of file data.c.

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}
void completion_data_free_match_strings(struct CompletionData *cd)
Free the Completion strings.
Definition: data.c:37
State data for auto-completion.
Definition: data.h:32
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ completion_data_new()

struct CompletionData * completion_data_new ( void  )

Create new Completion Data.

Return values
ptrNew Completion Data

Definition at line 70 of file data.c.

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}
void * mutt_mem_calloc(size_t nmemb, size_t size)
Allocate zeroed memory on the heap.
Definition: memory.c:50
int match_list_len
Enough space for all of the config items.
Definition: data.h:37
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ completion_data_reset()

void completion_data_reset ( struct CompletionData cd)

Wipe the stored Completion Data.

Parameters
cdCompletion Data

Definition at line 84 of file data.c.

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}
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
+ Here is the call graph for this function:
+ Here is the caller graph for this function: