Re: [PATCH v3 19/19] Remove the vector return result from the completion API.

Doug Evans
2015-08-23T18:03:07Z

Keith Seitz <keiths@redhat.com> writes:
> Differences in this revision:
>
> 1. Updated new TUI completion functions.
>
> ---
>
> This patch completes the redesign of the completion and completion-
> limiting API. Since the completer's internal data is now responsible
> for tracking all completions and the result of the completion operation
> no longer uses vectors (except for the final list given to readline),
> we can remove the vectors from the API entirely.
>
> gdb/ChangeLog
>
> * command.h (completer_ftype): Change return type from
> VEC (char_ptr) * to void. Update all users of this definition.
> * completer.h (add_completion): Remove vector argument.
> All users updated.
> * symtab.c (free_completion_list): Remove.
> (do_free_completion_list): Remove.
> (return_val): Remove global.

Hi.
Just a couple of nits.

> diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c
> index 5df08be..5effb48 100644
> --- a/gdb/ada-lang.c
> +++ b/gdb/ada-lang.c
> @@ -6199,8 +6199,7 @@ symbol_completion_match (const char *sym_name,
> encoded). */
>
> static enum add_completion_status
> -symbol_completion_add (VEC(char_ptr) **sv,
> - struct completer_data *cdata,
> +symbol_completion_add (struct completer_data *cdata,
> const char *sym_name,
> const char *text, int text_len,
> const char *orig_text, const char *word,
> @@ -6213,14 +6212,13 @@ symbol_completion_add (VEC(char_ptr) **sv,
>
> /* We found a match, so add the appropriate completion to the given
> string vector. */
> - return add_completion (cdata, sv, match, orig_text, word);
> + return add_completion (cdata, match, orig_text, word);
> }
>
> /* An object of this type is passed as the user_data argument to the
> expand_symtabs_matching method. */
> struct add_partial_datum
> {
> - VEC(char_ptr) **completions;
> const char *text;
> int text_len;
> const char *text0;
> @@ -6243,7 +6241,7 @@ ada_complete_symbol_matcher (const char *name, void *user_data)
> /* Return a list of possible symbol names completing TEXT0. WORD is
> the entire command on which completion is made. */
>
> -static VEC (char_ptr) *
> +static void
> ada_make_symbol_completion_list (struct completer_data *cdata,
> const char *text0, const char *word,
> enum type_code code)
> @@ -6252,7 +6250,6 @@ ada_make_symbol_completion_list (struct completer_data *cdata,
> int text_len;
> int wild_match_p;
> int encoded_p;
> - VEC(char_ptr) *completions = VEC_alloc (char_ptr, 128);
> struct symbol *sym;
> struct compunit_symtab *s;
> struct minimal_symbol *msymbol;
> @@ -6293,7 +6290,6 @@ ada_make_symbol_completion_list (struct completer_data *cdata,
> {
> struct add_partial_datum data;
>
> - data.completions = &completions;
> data.text = text;
> data.text_len = text_len;
> data.text0 = text0;
> @@ -6312,14 +6308,13 @@ ada_make_symbol_completion_list (struct completer_data *cdata,
> ALL_MSYMBOLS (objfile, msymbol)
> {
> QUIT;
> - status = symbol_completion_add (&completions, cdata,
> - MSYMBOL_LINKAGE_NAME (msymbol),
> - text, text_len, text0, word,
> - wild_match_p, encoded_p);
> + status = symbol_completion_add (cdata, MSYMBOL_LINKAGE_NAME (msymbol),
> + text, text_len, text0, word,
> + wild_match_p, encoded_p);
> if (status == ADD_COMPLETION_MAX_REACHED)
> {
> do_cleanups (old_chain);
> - return completions;
> + return;
> }
> }
>
> @@ -6333,14 +6328,13 @@ ada_make_symbol_completion_list (struct completer_data *cdata,
>
> ALL_BLOCK_SYMBOLS (b, iter, sym)
> {
> - status = symbol_completion_add (&completions, cdata,
> - SYMBOL_LINKAGE_NAME (sym),
> - text, text_len, text0, word,
> - wild_match_p, encoded_p);
> + status = symbol_completion_add (cdata, SYMBOL_LINKAGE_NAME (sym),
> + text, text_len, text0, word,
> + wild_match_p, encoded_p);
> if (status == ADD_COMPLETION_MAX_REACHED)
> {
> do_cleanups (old_chain);
> - return completions;
> + return;
> }
> }
> }
> @@ -6354,14 +6348,13 @@ ada_make_symbol_completion_list (struct completer_data *cdata,
> b = BLOCKVECTOR_BLOCK (COMPUNIT_BLOCKVECTOR (s), GLOBAL_BLOCK);
> ALL_BLOCK_SYMBOLS (b, iter, sym)
> {
> - status = symbol_completion_add (&completions, cdata,
> - SYMBOL_LINKAGE_NAME (sym),
> - text, text_len, text0, word,
> - wild_match_p, encoded_p);
> + status = symbol_completion_add (cdata,SYMBOL_LINKAGE_NAME (sym),
> + text, text_len, text0, word,
> + wild_match_p, encoded_p);
> if (status == ADD_COMPLETION_MAX_REACHED)
> {
> do_cleanups (old_chain);
> - return completions;
> + return;
> }
> }
> }
> @@ -6375,20 +6368,18 @@ ada_make_symbol_completion_list (struct completer_data *cdata,
> continue;
> ALL_BLOCK_SYMBOLS (b, iter, sym)
> {
> - status = symbol_completion_add (&completions, cdata,
> - SYMBOL_LINKAGE_NAME (sym),
> - text, text_len, text0, word,
> - wild_match_p, encoded_p);
> + status = symbol_completion_add (cdata, SYMBOL_LINKAGE_NAME (sym),
> + text, text_len, text0, word,
> + wild_match_p, encoded_p);
> if (status == ADD_COMPLETION_MAX_REACHED)
> {
> do_cleanups (old_chain);
> - return completions;
> + return;
> }
> }
> }
>
> do_cleanups (old_chain);
> - return completions;
> }
>
> /* Field Access */
> diff --git a/gdb/break-catch-syscall.c b/gdb/break-catch-syscall.c
> index 4677132..a542826 100644
> --- a/gdb/break-catch-syscall.c
> +++ b/gdb/break-catch-syscall.c
> @@ -591,17 +591,17 @@ catching_syscall_number (int syscall_number)
> }
>
> /* Complete syscall names. Used by "catch syscall". */
> -static VEC (char_ptr) *
> +static void
> catch_syscall_completer (struct completer_data *cdata,
> struct cmd_list_element *cmd,
> const char *text, const char *word)
> {
> const char **list = get_syscall_names (get_current_arch ());
> - VEC (char_ptr) *retlist
> - = (list == NULL) ? NULL : complete_on_enum (cdata, list, word, word);
> +
> + if (list != NULL)
> + complete_on_enum (cdata, list, word, word);
>
> xfree (list);
> - return retlist;
> }
>
> static void
> diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c
> index 24243c4..08901ae 100644
> --- a/gdb/breakpoint.c
> +++ b/gdb/breakpoint.c
> @@ -1032,7 +1032,7 @@ set_breakpoint_condition (struct breakpoint *b, const char *exp,
>
> /* Completion for the "condition" command. */
>
> -static VEC (char_ptr) *
> +static void
> condition_completer (struct completer_data *cdata,
> struct cmd_list_element *cmd,
> const char *text, const char *word)
> @@ -1045,14 +1045,13 @@ condition_completer (struct completer_data *cdata,
> {
> int len;
> struct breakpoint *b;
> - VEC (char_ptr) *result = NULL;
>
> if (text[0] == '$')
> {
> /* We don't support completion of history indices. */
> - if (isdigit (text[1]))
> - return NULL;
> - return complete_internalvar (cdata, &text[1]);
> + if (!isdigit (text[1]))
> + complete_internalvar (cdata, &text[1]);
> + return;
> }
>
> /* We're completing the breakpoint number. */
> @@ -1066,18 +1065,18 @@ condition_completer (struct completer_data *cdata,
>
> if (strncmp (number, text, len) == 0)
> {
> - if (add_completion (cdata, &result, number, NULL, NULL)
> + if (add_completion (cdata, number, NULL, NULL)
> == ADD_COMPLETION_MAX_REACHED)
> break;
> }
> }
>
> - return result;
> + return;
> }
>
> /* We're completing the expression part. */
> text = skip_spaces_const (space);
> - return expression_completer (cdata, cmd, text, word);
> + expression_completer (cdata, cmd, text, word);
> }
>
> /* condition N EXP -- set break condition of breakpoint N to EXP. */
> diff --git a/gdb/cli/cli-decode.c b/gdb/cli/cli-decode.c
> index 9691fd1..9e7bf80 100644
> --- a/gdb/cli/cli-decode.c
> +++ b/gdb/cli/cli-decode.c
> @@ -647,7 +647,7 @@ add_setshow_optional_filename_cmd (const char *name, enum command_class theclass
> /* Completes on literal "unlimited". Used by integer commands that
> support a special "unlimited" value. */
>
> -static VEC (char_ptr) *
> +static void
> integer_unlimited_completer (struct completer_data *cdata,
> struct cmd_list_element *ignore,
> const char *text, const char *word)
> @@ -658,7 +658,7 @@ integer_unlimited_completer (struct completer_data *cdata,
> NULL,
> };
>
> - return complete_on_enum (cdata, keywords, text, word);
> + complete_on_enum (cdata, keywords, text, word);
> }
>
> /* Add element named NAME to both the set and show command LISTs (the
> @@ -1757,22 +1757,21 @@ lookup_cmd_composition (const char *text,
>
> /* Helper function for SYMBOL_COMPLETION_FUNCTION. */
>
> -/* Return a vector of char pointers which point to the different
> - possible completions in LIST of TEXT.
> +/* Add completions to CDATA for the different possible completions
> + in LIST of TEXT.
>
> WORD points in the same buffer as TEXT, and completions should be
> returned relative to this position. For example, suppose TEXT is
> "foo" and we want to complete to "foobar". If WORD is "oo", return
> "oobar"; if WORD is "baz/foo", return "baz/foobar". */
>
> -VEC (char_ptr) *
> +void
> complete_on_cmdlist (struct completer_data *cdata,
> struct cmd_list_element *list,
> const char *text, const char *word,
> int ignore_help_classes)
> {
> struct cmd_list_element *ptr;
> - VEC (char_ptr) *matchlist = NULL;
> int textlen = strlen (text);
> int pass;
> int saw_deprecated_match = 0;
> @@ -1798,35 +1797,32 @@ complete_on_cmdlist (struct completer_data *cdata,
> }
> }
>
> - if (add_completion (cdata, &matchlist, ptr->name, text, word)
> + if (add_completion (cdata, ptr->name, text, word)
> == ADD_COMPLETION_MAX_REACHED)
> - return matchlist;
> + return;
> }
> /* If we saw no matching deprecated commands in the first pass,
> just bail out. */
> if (!saw_deprecated_match)
> break;
> }
> -
> - return matchlist;
> }
>
> /* Helper function for SYMBOL_COMPLETION_FUNCTION. */
>
> -/* Return a vector of char pointers which point to the different
> - possible completions in CMD of TEXT.
> +/* Add completions to CDATA for the different possible completions in
> + CMD of TEXT.
>
> WORD points in the same buffer as TEXT, and completions should be
> returned relative to this position. For example, suppose TEXT is "foo"
> and we want to complete to "foobar". If WORD is "oo", return
> "oobar"; if WORD is "baz/foo", return "baz/foobar". */
>
> -VEC (char_ptr) *
> +void
> complete_on_enum (struct completer_data *cdata,
> const char *const *enumlist,
> const char *text, const char *word)
> {
> - VEC (char_ptr) *matchlist = NULL;
> int textlen = strlen (text);
> int i;
> const char *name;
> @@ -1834,12 +1830,10 @@ complete_on_enum (struct completer_data *cdata,
> for (i = 0; (name = enumlist[i]) != NULL; i++)
> if (strncmp (name, text, textlen) == 0)
> {
> - if (add_completion (cdata, &matchlist, name, text, word)
> + if (add_completion (cdata, name, text, word)
> == ADD_COMPLETION_MAX_REACHED)
> break;
> }
> -
> - return matchlist;
> }
>
>
> diff --git a/gdb/command.h b/gdb/command.h
> index b2aeb30..82872c0 100644
> --- a/gdb/command.h
> +++ b/gdb/command.h
> @@ -158,9 +158,9 @@ typedef void cmd_sfunc_ftype (char *args, int from_tty,
> extern void set_cmd_sfunc (struct cmd_list_element *cmd,
> cmd_sfunc_ftype *sfunc);
>
> -typedef VEC (char_ptr) *completer_ftype (struct completer_data *,
> - struct cmd_list_element *,
> - const char *, const char *);
> +typedef void completer_ftype (struct completer_data *,
> + struct cmd_list_element *,
> + const char *, const char *);
>
> typedef void completer_ftype_void (struct cmd_list_element *,
> const char *, const char *);
> @@ -228,13 +228,13 @@ extern struct cmd_list_element *add_info (const char *,
> extern struct cmd_list_element *add_info_alias (const char *, const char *,
> int);
>
> -extern VEC (char_ptr) *complete_on_cmdlist (struct completer_data *,
> - struct cmd_list_element *,
> - const char *, const char *, int);
> +extern void complete_on_cmdlist (struct completer_data *,
> + struct cmd_list_element *,
> + const char *, const char *, int);
>
> -extern VEC (char_ptr) *complete_on_enum (struct completer_data *,
> - const char *const *enumlist,
> - const char *, const char *);
> +extern void complete_on_enum (struct completer_data *,
> + const char *const *enumlist,
> + const char *, const char *);
>
> /* Functions that implement commands about CLI commands. */
>
> diff --git a/gdb/completer.c b/gdb/completer.c
> index 6faed31..2ca7d2d 100644
> --- a/gdb/completer.c
> +++ b/gdb/completer.c
> @@ -144,22 +144,23 @@ readline_line_completion_function (const char *text, int matches)
>
> /* This can be used for functions which don't want to complete on
> symbols but don't want to complete on anything else either. */
> -VEC (char_ptr) *
> +
> +void
> noop_completer (struct completer_data *cdata,
> struct cmd_list_element *ignore,
> const char *text, const char *prefix)
> {
> - return NULL;
> + /* Nothing. */
> }
>
> /* Complete on filenames. */
> -VEC (char_ptr) *
> +
> +void
> filename_completer (struct completer_data *cdata,
> struct cmd_list_element *ignore,
> const char *text, const char *word)
> {
> int subsequent_name;
> - VEC (char_ptr) *return_val = NULL;
>
> subsequent_name = 0;
> while (1)
> @@ -182,7 +183,7 @@ filename_completer (struct completer_data *cdata,
> continue;
> }
>
> - if (add_completion (cdata, &return_val, p, text, word)
> + if (add_completion (cdata, p, text, word)
> == ADD_COMPLETION_MAX_REACHED)
> break;
> }
> @@ -194,7 +195,6 @@ filename_completer (struct completer_data *cdata,
> with respect to inserting quotes. */
> rl_completer_word_break_characters = "";
> #endif
> - return return_val;
> }
>
> /* A hashtable traversal function to remove leading file name
> @@ -220,14 +220,12 @@ remove_leading_fn_component (void **slot, void *calldata)
> This is intended to be used in commands that set breakpoints
> etc. */
>
> -VEC (char_ptr) *
> +void
> location_completer (struct completer_data *cdata,
> struct cmd_list_element *ignore,
> const char *text, const char *word)
> {
> int n_syms, n_files, ix;
> - VEC (char_ptr) *fn_list = NULL;
> - VEC (char_ptr) *list = NULL;
> const char *p;
> int quote_found = 0;
> int quoted = *text == '\'' || *text == '"';
> @@ -298,15 +296,15 @@ location_completer (struct completer_data *cdata,
> symbols as well as on files. */
> if (colon)
> {
> - list = make_file_symbol_completion_list (cdata, symbol_start, word,
> - file_to_match);
> + make_file_symbol_completion_list (cdata, symbol_start, word,
> + file_to_match);
> n_syms = get_completion_count (cdata);
> n_files = 0;
> xfree (file_to_match);
> }
> else
> {
> - list = make_symbol_completion_list (cdata, symbol_start, word);
> + make_symbol_completion_list (cdata, symbol_start, word);
> n_syms = get_completion_count (cdata);
> n_files = 0;
> /* If text includes characters which cannot appear in a file
> @@ -314,27 +312,11 @@ location_completer (struct completer_data *cdata,
> if (strcspn (text,
> gdb_completer_file_name_break_characters) == text_len)
> {
> - fn_list = make_source_files_completion_list (cdata, text, text);
> + make_source_files_completion_list (cdata, text, text);
> n_files = get_completion_count (cdata) - n_syms;
> }
> }
>
> - /* Catenate fn_list[] onto the end of list[]. */
> - if (!n_syms)
> - {
> - VEC_free (char_ptr, list); /* Paranoia. */
> - list = fn_list;
> - fn_list = NULL;
> - }
> - else
> - {
> - char *fn;
> -
> - for (ix = 0; VEC_iterate (char_ptr, fn_list, ix, fn); ++ix)
> - VEC_safe_push (char_ptr, list, fn);
> - VEC_free (char_ptr, fn_list);
> - }
> -
> if (n_syms && n_files)
> {
> /* Nothing. */
> @@ -365,18 +347,15 @@ location_completer (struct completer_data *cdata,
> {
> /* No completions at all. As the final resort, try completing
> on the entire text as a symbol. */
> - list = make_symbol_completion_list (cdata, orig_text, word);
> + make_symbol_completion_list (cdata, orig_text, word);
> }
> -
> - return list;
> }
>
> /* Helper for expression_completer which recursively adds field and
> method names from TYPE, a struct or union type, to the array
> OUTPUT. */

====
Function comment needs updating.

> static void
> -add_struct_fields (struct completer_data *cdata,
> - struct type *type, VEC (char_ptr) **output,
> +add_struct_fields (struct completer_data *cdata, struct type *type,
> char *fieldname, int namelen)
> {
> int i;
> @@ -388,7 +367,7 @@ add_struct_fields (struct completer_data *cdata,
> {
> if (i < TYPE_N_BASECLASSES (type))
> add_struct_fields (cdata, TYPE_BASECLASS (type, i),
> - output, fieldname, namelen);
> + fieldname, namelen);
> else if (TYPE_FIELD_NAME (type, i))
> {
> if (TYPE_FIELD_NAME (type, i)[0] != '\0')
> @@ -396,7 +375,7 @@ add_struct_fields (struct completer_data *cdata,
> if (! strncmp (TYPE_FIELD_NAME (type, i),
> fieldname, namelen))
> {
> - if (add_completion (cdata, output, TYPE_FIELD_NAME (type, i),
> + if (add_completion (cdata, TYPE_FIELD_NAME (type, i),
> NULL, NULL)
> == ADD_COMPLETION_MAX_REACHED)
> return;
> @@ -406,7 +385,7 @@ add_struct_fields (struct completer_data *cdata,
> {
> /* Recurse into anonymous unions. */
> add_struct_fields (cdata, TYPE_FIELD_TYPE (type, i),
> - output, fieldname, namelen);
> + fieldname, namelen);
> }
> }
> }
> @@ -425,7 +404,7 @@ add_struct_fields (struct completer_data *cdata,
> /* Omit constructors from the completion list. */
> if (!type_name || strcmp (type_name, name))
> {
> - if (add_completion (cdata, output, name, NULL, NULL)
> + if (add_completion (cdata, name, NULL, NULL)
> == ADD_COMPLETION_MAX_REACHED)
> return;
> }
> @@ -436,7 +415,8 @@ add_struct_fields (struct completer_data *cdata,
> /* Complete on expressions. Often this means completing on symbol
> names, but some language parsers also have support for completing
> field names. */
> -VEC (char_ptr) *
> +
> +void
> expression_completer (struct completer_data *cdata,
> struct cmd_list_element *ignore,
> const char *text, const char *word)
> @@ -455,7 +435,7 @@ expression_completer (struct completer_data *cdata,
> }
> CATCH (except, RETURN_MASK_ERROR)
> {
> - return NULL;
> + return;
> }
> END_CATCH
>
> @@ -474,22 +454,19 @@ expression_completer (struct completer_data *cdata,
> || TYPE_CODE (type) == TYPE_CODE_STRUCT)
> {
> int flen = strlen (fieldname);
> - VEC (char_ptr) *result = NULL;
>
> - add_struct_fields (cdata, type, &result, fieldname, flen);
> + add_struct_fields (cdata, type, fieldname, flen);
> xfree (fieldname);
> - return result;
> + return;
> }
> }
> else if (fieldname && code != TYPE_CODE_UNDEF)
> {
> - VEC (char_ptr) *result;
> struct cleanup *cleanup = make_cleanup (xfree, fieldname);
>
> - result
> - = make_symbol_completion_type (cdata, fieldname, fieldname, code);
> + make_symbol_completion_type (cdata, fieldname, fieldname, code);
> do_cleanups (cleanup);
> - return result;
> + return;
> }
> xfree (fieldname);
>
> @@ -501,7 +478,7 @@ expression_completer (struct completer_data *cdata,
> ;
>
> /* Not ideal but it is what we used to do before... */
> - return location_completer (cdata, ignore, p, word);
> + location_completer (cdata, ignore, p, word);
> }
>
> /* See definition in completer.h. */
> @@ -578,12 +555,11 @@ complete_line_internal_reason;
> once sub-command completions are exhausted, we simply return NULL.
> */
>
> -static VEC (char_ptr) *
> +static void
> complete_line_internal (struct completer_data *cdata,
> const char *text, const char *line_buffer, int point,
> complete_line_internal_reason reason)
> {
> - VEC (char_ptr) *list = NULL;
> char *tmp_command;
> const char *p;
> int ignore_help_classes;
> @@ -638,7 +614,7 @@ complete_line_internal (struct completer_data *cdata,
> {
> /* It is an unrecognized command. So there are no
> possible completions. */
> - list = NULL;
> + return;
> }
> else if (c == CMD_LIST_AMBIGUOUS)
> {
> @@ -656,7 +632,7 @@ complete_line_internal (struct completer_data *cdata,
> example, "info t " or "info t foo" does not complete
> to anything, because "info t" can be "info target" or
> "info terminal". */
> - list = NULL;
> + return;
> }
> else
> {
> @@ -665,14 +641,14 @@ complete_line_internal (struct completer_data *cdata,
> if (result_list)
> {
> if (reason != handle_brkchars)
> - list = complete_on_cmdlist (cdata, *result_list->prefixlist,
> - p, word, ignore_help_classes);
> + complete_on_cmdlist (cdata, *result_list->prefixlist,
> + p, word, ignore_help_classes);
> }
> else
> {
> if (reason != handle_brkchars)
> - list = complete_on_cmdlist (cdata, cmdlist, p, word,
> - ignore_help_classes);
> + complete_on_cmdlist (cdata, cmdlist, p, word,
> + ignore_help_classes);
> }
> /* Ensure that readline does the right thing with respect to
> inserting quotes. */
> @@ -698,8 +674,8 @@ complete_line_internal (struct completer_data *cdata,
> /* It is a prefix command; what comes after it is
> a subcommand (e.g. "info "). */
> if (reason != handle_brkchars)
> - list = complete_on_cmdlist (cdata, *c->prefixlist, p,
> - word, ignore_help_classes);
> + complete_on_cmdlist (cdata, *c->prefixlist, p,
> + word, ignore_help_classes);
>
> /* Ensure that readline does the right thing
> with respect to inserting quotes. */
> @@ -707,11 +683,11 @@ complete_line_internal (struct completer_data *cdata,
> gdb_completer_command_word_break_characters;
> }
> else if (reason == handle_help)
> - list = NULL;
> + return;
> else if (c->enums)
> {
> if (reason != handle_brkchars)
> - list = complete_on_enum (cdata, c->enums, p, word);
> + complete_on_enum (cdata, c->enums, p, word);
> rl_completer_word_break_characters =
> gdb_completer_command_word_break_characters;
> }
> @@ -751,7 +727,7 @@ complete_line_internal (struct completer_data *cdata,
> && c->completer_handle_brkchars != NULL)
> (*c->completer_handle_brkchars) (c, p, word);
> if (reason != handle_brkchars && c->completer != NULL)
> - list = (*c->completer) (cdata, c, p, word);
> + (*c->completer) (cdata, c, p, word);
> }
> }
> else
> @@ -773,8 +749,8 @@ complete_line_internal (struct completer_data *cdata,
> }
>
> if (reason != handle_brkchars)
> - list = complete_on_cmdlist (cdata, result_list, q, word,
> - ignore_help_classes);
> + complete_on_cmdlist (cdata, result_list, q, word,
> + ignore_help_classes);
>
> /* Ensure that readline does the right thing
> with respect to inserting quotes. */
> @@ -783,7 +759,7 @@ complete_line_internal (struct completer_data *cdata,
> }
> }
> else if (reason == handle_help)
> - list = NULL;
> + return;
> else
> {
> /* There is non-whitespace beyond the command. */
> @@ -792,12 +768,12 @@ complete_line_internal (struct completer_data *cdata,
> {
> /* It is an unrecognized subcommand of a prefix command,
> e.g. "info adsfkdj". */
> - list = NULL;
> + return;
> }
> else if (c->enums)
> {
> if (reason != handle_brkchars)
> - list = complete_on_enum (cdata, c->enums, p, word);
> + complete_on_enum (cdata, c->enums, p, word);
> }
> else
> {
> @@ -827,12 +803,10 @@ complete_line_internal (struct completer_data *cdata,
> && c->completer_handle_brkchars != NULL)
> (*c->completer_handle_brkchars) (c, p, word);
> if (reason != handle_brkchars && c->completer != NULL)
> - list = (*c->completer) (cdata, c, p, word);
> + (*c->completer) (cdata, c, p, word);
> }
> }
> }
> -
> - return list;
> }
>
> /* Allocate a new completer data structure. */
> @@ -986,8 +960,8 @@ get_maximum_completions (void)
> /* See completer.h. */
>
> enum add_completion_status
> -add_completion (struct completer_data *cdata, VEC (char_ptr) **result,
> - const char *match, const char *text, const char *word)
> +add_completion (struct completer_data *cdata, const char *match,
> + const char *text, const char *word)
> {
> enum maybe_add_completion_enum add_status;
> char *alloc = completer_strdup (match, text, word);
> @@ -996,10 +970,8 @@ add_completion (struct completer_data *cdata, VEC (char_ptr) **result,
> switch (add_status)
> {
> case MAYBE_ADD_COMPLETION_OK:
> - VEC_safe_push (char_ptr, *result, alloc);
> break;
> case MAYBE_ADD_COMPLETION_OK_MAX_REACHED:
> - VEC_safe_push (char_ptr, *result, alloc);
> return ADD_COMPLETION_MAX_REACHED;
> case MAYBE_ADD_COMPLETION_MAX_REACHED:
> xfree (alloc);
> @@ -1054,23 +1026,23 @@ complete_line (const char *text, const char *line_buffer, int point)
> }
>
> /* Complete on command names. Used by "help". */
> -VEC (char_ptr) *
> +
> +void
> command_completer (struct completer_data *cdata,
> struct cmd_list_element *ignore,
> const char *text, const char *word)
> {
> - return complete_line_internal (cdata, word, text,
> - strlen (text), handle_help);
> + complete_line_internal (cdata, word, text,
> + strlen (text), handle_help);
> }
>
> /* Complete on signals. */
>
> -VEC (char_ptr) *
> +void
> signal_completer (struct completer_data *cdata,
> struct cmd_list_element *ignore,
> const char *text, const char *word)
> {
> - VEC (char_ptr) *return_val = NULL;
> size_t len = strlen (word);
> int signum;
> const char *signame;
> @@ -1089,13 +1061,11 @@ signal_completer (struct completer_data *cdata,
>
> if (strncasecmp (signame, word, len) == 0)
> {
> - if (add_completion (cdata, &return_val, signame, NULL, NULL)
> + if (add_completion (cdata, signame, NULL, NULL)
> == ADD_COMPLETION_MAX_REACHED)
> break;
> }
> }
> -
> - return return_val;
> }
>
> /* Bit-flags for selecting what the register and/or register-group
> @@ -1110,13 +1080,12 @@ enum reg_completer_targets
> /* Complete register names and/or reggroup names based on the value passed
> in TARGETS. At least one bit in TARGETS must be set. */
>
> -static VEC (char_ptr) *
> +static void
> reg_or_group_completer_1 (struct completer_data *cdata,
> struct cmd_list_element *ignore,
> const char *text, const char *word,
> enum reg_completer_targets targets)
> {
> - VEC (char_ptr) *result = NULL;
> size_t len = strlen (word);
> struct gdbarch *gdbarch;
> const char *name;
> @@ -1124,6 +1093,8 @@ reg_or_group_completer_1 (struct completer_data *cdata,
> gdb_assert ((targets & (complete_register_names
> | complete_reggroup_names)) != 0);
> gdbarch = get_current_arch ();
> + if (!target_has_registers)
> + return;

====
This change probably belongs in a separate patchset.
I could be missing something though.

>
> if ((targets & complete_register_names) != 0)
> {
> @@ -1135,9 +1106,9 @@ reg_or_group_completer_1 (struct completer_data *cdata,
> {
> if (*name != '\0' && strncmp (word, name, len) == 0)
> {
> - if (add_completion (cdata, &result, name, NULL, NULL)
> + if (add_completion (cdata, name, NULL, NULL)
> == ADD_COMPLETION_MAX_REACHED)
> - return result;
> + return;
> }
> }
> }
> @@ -1153,37 +1124,35 @@ reg_or_group_completer_1 (struct completer_data *cdata,
> name = reggroup_name (group);
> if (strncmp (word, name, len) == 0)
> {
> - if (add_completion (cdata, &result, name, NULL, NULL)
> + if (add_completion (cdata, name, NULL, NULL)
> == ADD_COMPLETION_MAX_REACHED)
> - return result;
> + return;
> }
> }
> }
> -
> - return result;
> }
>
> /* Perform completion on register and reggroup names. */
>
> -VEC (char_ptr) *
> +void
> reg_or_group_completer (struct completer_data *cdata,
> struct cmd_list_element *ignore,
> const char *text, const char *word)
> {
> - return reg_or_group_completer_1 (cdata, ignore, text, word,
> - (complete_register_names
> - | complete_reggroup_names));
> + reg_or_group_completer_1 (cdata, ignore, text, word,
> + (complete_register_names
> + | complete_reggroup_names));
> }
>
> /* Perform completion on reggroup names. */
>
> -VEC (char_ptr) *
> +void
> reggroup_completer (struct completer_data *cdata,
> struct cmd_list_element *ignore,
> const char *text, const char *word)
> {
> - return reg_or_group_completer_1 (cdata, ignore, text, word,
> - complete_reggroup_names);
> + reg_or_group_completer_1 (cdata, ignore, text, word,
> + complete_reggroup_names);
> }
>
> /* Get the list of chars that are considered as word breaks
> diff --git a/gdb/completer.h b/gdb/completer.h
> index 07c7d93..cfdca71 100644
> --- a/gdb/completer.h
> +++ b/gdb/completer.h
> @@ -76,37 +76,37 @@ extern VEC (char_ptr) *complete_line (const char *text,
> extern char *readline_line_completion_function (const char *text,
> int matches);
>
> -extern VEC (char_ptr) *noop_completer (struct completer_data *,
> - struct cmd_list_element *,
> - const char *, const char *);
> +extern void noop_completer (struct completer_data *,
> + struct cmd_list_element *,
> + const char *, const char *);
>
> -extern VEC (char_ptr) *filename_completer (struct completer_data *,
> - struct cmd_list_element *,
> - const char *, const char *);
> +extern void filename_completer (struct completer_data *,
> + struct cmd_list_element *,
> + const char *, const char *);
>
> -extern VEC (char_ptr) *expression_completer (struct completer_data *,
> - struct cmd_list_element *,
> - const char *, const char *);
> +extern void expression_completer (struct completer_data *,
> + struct cmd_list_element *,
> + const char *, const char *);
>
> -extern VEC (char_ptr) *location_completer (struct completer_data *,
> - struct cmd_list_element *,
> - const char *, const char *);
> +extern void location_completer (struct completer_data *,
> + struct cmd_list_element *,
> + const char *, const char *);
>
> -extern VEC (char_ptr) *command_completer (struct completer_data *,
> - struct cmd_list_element *,
> - const char *, const char *);
> +extern void command_completer (struct completer_data *,
> + struct cmd_list_element *,
> + const char *, const char *);
>
> -extern VEC (char_ptr) *signal_completer (struct completer_data *,
> - struct cmd_list_element *,
> - const char *, const char *);
> +extern void signal_completer (struct completer_data *,
> + struct cmd_list_element *,
> + const char *, const char *);
>
> -extern VEC (char_ptr) *reg_or_group_completer (struct completer_data *,
> - struct cmd_list_element *,
> - const char *, const char *);
> +extern void reg_or_group_completer (struct completer_data *,
> + struct cmd_list_element *,
> + const char *, const char *);
>
> -extern VEC (char_ptr) *reggroup_completer (struct completer_data *cdata,
> - struct cmd_list_element *,
> - const char *, const char *);
> +extern void reggroup_completer (struct completer_data *cdata,
> + struct cmd_list_element *,
> + const char *, const char *);
>
> extern char *get_gdb_completer_quote_characters (void);
>
> @@ -163,8 +163,7 @@ enum add_completion_status
> saved into the completion list. See completer_strdup for more. */
>
> extern enum add_completion_status
> - add_completion (struct completer_data *cdata,
> - VEC (char_ptr) **result, const char *match,
> + add_completion (struct completer_data *cdata, const char *match,
> const char *text, const char *word);
>
> /* Wrapper to throw MAX_COMPLETIONS_REACHED_ERROR. */
> diff --git a/gdb/corefile.c b/gdb/corefile.c
> index 41b7cb0..4e5e96a 100644
> --- a/gdb/corefile.c
> +++ b/gdb/corefile.c
> @@ -467,7 +467,7 @@ set_gnutarget_command (char *ignore, int from_tty,
>
> /* A completion function for "set gnutarget". */
>
> -static VEC (char_ptr) *
> +static void
> complete_set_gnutarget (struct completer_data *cdata,
> struct cmd_list_element *cmd,
> const char *text, const char *word)
> @@ -487,7 +487,7 @@ complete_set_gnutarget (struct completer_data *cdata,
> bfd_targets[last + 1] = NULL;
> }
>
> - return complete_on_enum (cdata, bfd_targets, text, word);
> + complete_on_enum (cdata, bfd_targets, text, word);
> }
>
> /* Set the gnutarget. */
> diff --git a/gdb/cp-abi.c b/gdb/cp-abi.c
> index 504bb20..cddc382 100644
> --- a/gdb/cp-abi.c
> +++ b/gdb/cp-abi.c
> @@ -358,7 +358,7 @@ set_cp_abi_cmd (char *args, int from_tty)
>
> /* A completion function for "set cp-abi". */
>
> -static VEC (char_ptr) *
> +static void
> cp_abi_completer (struct completer_data *cdata,
> struct cmd_list_element *ignore,
> const char *text, const char *word)
> @@ -375,7 +375,7 @@ cp_abi_completer (struct completer_data *cdata,
> cp_abi_names[i] = NULL;
> }
>
> - return complete_on_enum (cdata, cp_abi_names, text, word);
> + complete_on_enum (cdata, cp_abi_names, text, word);
> }
>
> /* Show the currently selected C++ ABI. */
> diff --git a/gdb/f-lang.c b/gdb/f-lang.c
> index 15c51d9..b5886a6 100644
> --- a/gdb/f-lang.c
> +++ b/gdb/f-lang.c
> @@ -228,13 +228,13 @@ f_word_break_characters (void)
> /* Consider the modules separator :: as a valid symbol name character
> class. */
>
> -static VEC (char_ptr) *
> +static void
> f_make_symbol_completion_list (struct completer_data *cdata,
> const char *text, const char *word,
> enum type_code code)
> {
> - return default_make_symbol_completion_list_break_on (cdata, text, word,
> - ":", code);
> + default_make_symbol_completion_list_break_on (cdata, text, word,
> + ":", code);
> }
>
> const struct language_defn f_language_defn =
> diff --git a/gdb/guile/scm-cmd.c b/gdb/guile/scm-cmd.c
> index 1544c2b..8816346 100644
> --- a/gdb/guile/scm-cmd.c
> +++ b/gdb/guile/scm-cmd.c
> @@ -348,8 +348,7 @@ cmdscm_bad_completion_result (const char *msg, SCM completion)
> The result is a boolean indicating success. */
>
> static int
> -cmdscm_add_completion (SCM completion, struct completer_data *cdata,
> - VEC (char_ptr) **result)
> +cmdscm_add_completion (SCM completion, struct completer_data *cdata)
> {
> char *item;
> SCM except_scm;
> @@ -371,14 +370,14 @@ cmdscm_add_completion (SCM completion, struct completer_data *cdata,
> return 0;
> }
>
> - (void) add_completion (cdata, result, item, NULL, NULL);
> + (void) add_completion (cdata, item, NULL, NULL);
> xfree (item);
> return 1;
> }
>
> /* Called by gdb for command completion. */
>
> -static VEC (char_ptr) *
> +static void
> cmdscm_completer (struct completer_data *cdata,
> struct cmd_list_element *command,
> const char *text, const char *word)
> @@ -386,7 +385,6 @@ cmdscm_completer (struct completer_data *cdata,
> command_smob *c_smob/*obj*/ = (command_smob *) get_cmd_context (command);
> SCM completer_result_scm;
> SCM text_scm, word_scm, result_scm;
> - VEC (char_ptr) *result = NULL;
>
> gdb_assert (c_smob != NULL);
> gdb_assert (gdbscm_is_procedure (c_smob->complete));
> @@ -408,7 +406,7 @@ cmdscm_completer (struct completer_data *cdata,
> {
> /* Inform the user, but otherwise ignore. */
> gdbscm_print_gdb_exception (SCM_BOOL_F, completer_result_scm);
> - goto done;
> + return;
> }
>
> if (gdbscm_is_true (scm_list_p (completer_result_scm)))
> @@ -419,11 +417,8 @@ cmdscm_completer (struct completer_data *cdata,
> {
> SCM next = scm_car (list);
>
> - if (!cmdscm_add_completion (next, cdata, &result))
> - {
> - VEC_free (char_ptr, result);
> - goto done;
> - }
> + if (!cmdscm_add_completion (next, cdata))
> + return;
>
> list = scm_cdr (list);
> }
> @@ -439,15 +434,11 @@ cmdscm_completer (struct completer_data *cdata,
> {
> /* Inform the user, but otherwise ignore the entire result. */
> gdbscm_print_gdb_exception (SCM_BOOL_F, completer_result_scm);
> - VEC_free (char_ptr, result);
> - goto done;
> + return;
> }
>
> - if (!cmdscm_add_completion (next, cdata, &result))
> - {
> - VEC_free (char_ptr, result);
> - goto done;
> - }
> + if (!cmdscm_add_completion (next, cdata))
> + return;
>
> next = itscm_safe_call_next_x (iter, NULL);
> }
> @@ -458,9 +449,6 @@ cmdscm_completer (struct completer_data *cdata,
> cmdscm_bad_completion_result (_("Bad completer result: "),
> completer_result_scm);
> }
> -
> - done:
> - return result;
> }
>
> /* Helper for gdbscm_make_command which locates the command list to use and
> diff --git a/gdb/infrun.c b/gdb/infrun.c
> index d858b28..343f9da 100644
> --- a/gdb/infrun.c
> +++ b/gdb/infrun.c
> @@ -7065,12 +7065,11 @@ Are you sure you want to change it? "),
>
> /* Complete the "handle" command. */
>
> -static VEC (char_ptr) *
> +static void
> handle_completer (struct completer_data *cdata,
> struct cmd_list_element *ignore,
> const char *text, const char *word)
> {
> - VEC (char_ptr) *vec_signals, *vec_keywords, *return_val;
> static const char * const keywords[] =
> {
> "all",
> @@ -7085,13 +7084,8 @@ handle_completer (struct completer_data *cdata,
> NULL,
> };
>
> - vec_signals = signal_completer (cdata, ignore, text, word);
> - vec_keywords = complete_on_enum (cdata, keywords, word, word);
> -
> - return_val = VEC_merge (char_ptr, vec_signals, vec_keywords);
> - VEC_free (char_ptr, vec_signals);
> - VEC_free (char_ptr, vec_keywords);
> - return return_val;
> + signal_completer (cdata, ignore, text, word);
> + complete_on_enum (cdata, keywords, word, word);
> }
>
> enum gdb_signal
> diff --git a/gdb/interps.c b/gdb/interps.c
> index 9e993c8..19cb716 100644
> --- a/gdb/interps.c
> +++ b/gdb/interps.c
> @@ -434,13 +434,12 @@ interpreter_exec_cmd (char *args, int from_tty)
> }
>
> /* List the possible interpreters which could complete the given text. */
> -static VEC (char_ptr) *
> +static void
> interpreter_completer (struct completer_data *cdata,
> struct cmd_list_element *ignore,
> const char *text, const char *word)
> {
> int textlen;
> - VEC (char_ptr) *matches = NULL;
> struct interp *interp;
>
> textlen = strlen (text);
> @@ -448,13 +447,11 @@ interpreter_completer (struct completer_data *cdata,
> {
> if (strncmp (interp->name, text, textlen) == 0)
> {
> - if (add_completion (cdata, &matches, interp->name, text, word)
> + if (add_completion (cdata, interp->name, text, word)
> == ADD_COMPLETION_MAX_REACHED)
> break;
> }
> }
> -
> - return matches;
> }
>
> struct interp *
> diff --git a/gdb/language.h b/gdb/language.h
> index 954b4a8..24fb1e8 100644
> --- a/gdb/language.h
> +++ b/gdb/language.h
> @@ -302,7 +302,7 @@ struct language_defn
> completion is being made. If CODE is TYPE_CODE_UNDEF, then all
> symbols should be examined; otherwise, only STRUCT_DOMAIN
> symbols whose type has a code of CODE should be matched. */
> - VEC (char_ptr) *
> + void
> (*la_make_symbol_completion_list) (struct completer_data *,
> const char *text,
> const char *word,
> diff --git a/gdb/python/py-cmd.c b/gdb/python/py-cmd.c
> index cf76bd1..7a57349 100644
> --- a/gdb/python/py-cmd.c
> +++ b/gdb/python/py-cmd.c
> @@ -330,13 +330,12 @@ cmdpy_completer_handle_brkchars (struct cmd_list_element *command,
>
> /* Called by gdb for command completion. */
>
> -static VEC (char_ptr) *
> +static void
> cmdpy_completer (struct completer_data *cdata,
> struct cmd_list_element *command,
> const char *text, const char *word)
> {
> PyObject *resultobj = NULL;
> - VEC (char_ptr) *result = NULL;
> struct cleanup *cleanup;
>
> cleanup = ensure_python_env (get_current_arch (), current_language);
> @@ -351,7 +350,6 @@ cmdpy_completer (struct completer_data *cdata,
> if (resultobj == NULL)
> goto done;
>
> - result = NULL;
> if (PyInt_Check (resultobj))
> {
> /* User code may also return one of the completion constants,
> @@ -364,7 +362,7 @@ cmdpy_completer (struct completer_data *cdata,
> PyErr_Clear ();
> }
> else if (value >= 0 && value < (long) N_COMPLETERS)
> - result = completers[value].completer (cdata, command, text, word);
> + completers[value].completer (cdata, command, text, word);
> }
> else
> {
> @@ -393,7 +391,7 @@ cmdpy_completer (struct completer_data *cdata,
> continue;
> }
>
> - if (add_completion (cdata, &result, item, NULL, NULL)
> + if (add_completion (cdata, item, NULL, NULL)
> == ADD_COMPLETION_MAX_REACHED)
> {
> xfree (item);
> @@ -414,8 +412,6 @@ cmdpy_completer (struct completer_data *cdata,
>
> Py_XDECREF (resultobj);
> do_cleanups (cleanup);
> -
> - return result;
> }
>
> /* Helper for cmdpy_init which locates the command list to use and
> diff --git a/gdb/remote-sim.c b/gdb/remote-sim.c
> index c29d3c5..862683b 100644
> --- a/gdb/remote-sim.c
> +++ b/gdb/remote-sim.c
> @@ -1223,7 +1223,7 @@ simulator_command (char *args, int from_tty)
> registers_changed ();
> }
>
> -static VEC (char_ptr) *
> +static void
> sim_command_completer (struct completer_data *cdata,
> struct cmd_list_element *ignore, const char *text,
> const char *word)
> @@ -1235,22 +1235,20 @@ sim_command_completer (struct completer_data *cdata,
>
> sim_data = inferior_data (current_inferior (), sim_inferior_data_key);
> if (sim_data == NULL || sim_data->gdbsim_desc == NULL)
> - return NULL;
> + return;
>
> tmp = sim_complete_command (sim_data->gdbsim_desc, text, word);
> if (tmp == NULL)
> - return NULL;
> + return;
>
> /* Transform the array into a VEC, and then free the array. */
> for (i = 0; tmp[i] != NULL; i++)
> {
> - if (add_completion (cdata, &result, tmp[i], NULL, NULL)
> + if (add_completion (cdata, tmp[i], NULL, NULL)
> == ADD_COMPLETION_MAX_REACHED)
> break;
> }
> xfree (tmp);
> -
> - return result;
> }
>
> /* Check to see if a thread is still alive. */
> diff --git a/gdb/symtab.c b/gdb/symtab.c
> index e24de89..18b7619 100644
> --- a/gdb/symtab.c
> +++ b/gdb/symtab.c
> @@ -5011,31 +5011,8 @@ compare_symbol_name (const char *name, const char *sym_text, int sym_text_len)
> return 1;
> }
>
> -/* Free any memory associated with a completion list. */
> -
> -static void
> -free_completion_list (VEC (char_ptr) **list_ptr)
> -{
> - int i;
> - char *p;
> -
> - for (i = 0; VEC_iterate (char_ptr, *list_ptr, i, p); ++i)
> - xfree (p);
> - VEC_free (char_ptr, *list_ptr);
> -}
> -
> -/* Callback for make_cleanup. */
> -
> -static void
> -do_free_completion_list (void *list)
> -{
> - free_completion_list (list);
> -}
> -
> /* Helper routine for make_symbol_completion_list. */
>
> -static VEC (char_ptr) *return_val;
> -
> #define COMPLETION_LIST_ADD_SYMBOL(cdata, symbol, sym_text, len, \
> text, word) \
> completion_list_add_name \
> @@ -5063,7 +5040,7 @@ completion_list_add_name (struct completer_data *cdata,
> /* We have a match for a completion, so add SYMNAME to the current list
> of matches. */
>
> - if (add_completion (cdata, &return_val, symname, sym_text, word)
> + if (add_completion (cdata, symname, sym_text, word)
> == ADD_COMPLETION_MAX_REACHED)
> throw_max_completions_reached_error ();
> }
> @@ -5499,18 +5476,13 @@ default_make_symbol_completion_list_break_on_1 (struct completer_data *cdata,
> }
> }
>
> -VEC (char_ptr) *
> +void
> default_make_symbol_completion_list_break_on (struct completer_data *cdata,
> const char *text,
> const char *word,
> const char *break_on,
> enum type_code code)
> {
> - struct cleanup *back_to;
> -
> - return_val = NULL;
> - back_to = make_cleanup (do_free_completion_list, &return_val);
> -
> TRY
> {
> default_make_symbol_completion_list_break_on_1 (cdata, text, word,
> @@ -5522,61 +5494,56 @@ default_make_symbol_completion_list_break_on (struct completer_data *cdata,
> throw_exception (except);
> }
> END_CATCH
> -
> - discard_cleanups (back_to);
> - return return_val;
> }
>
> -VEC (char_ptr) *
> +void
> default_make_symbol_completion_list (struct completer_data *cdata,
> const char *text, const char *word,
> enum type_code code)
> {
> - return default_make_symbol_completion_list_break_on (cdata, text, word, "",
> - code);
> + default_make_symbol_completion_list_break_on (cdata, text, word, "", code);
> }
>
> /* Return a vector of all symbols (regardless of class) which begin by
> matching TEXT. If the answer is no symbols, then the return value
> is NULL. */
>
> -VEC (char_ptr) *
> +void
> make_symbol_completion_list (struct completer_data *cdata,
> const char *text, const char *word)
> {
> - return current_language->la_make_symbol_completion_list (cdata, text, word,
> - TYPE_CODE_UNDEF);
> + current_language->la_make_symbol_completion_list (cdata, text, word,
> + TYPE_CODE_UNDEF);
> }
>
> /* Like make_symbol_completion_list, but only return STRUCT_DOMAIN
> symbols whose type code is CODE. */
>
> -VEC (char_ptr) *
> +void
> make_symbol_completion_type (struct completer_data *cdata, const char *text,
> const char *word, enum type_code code)
> {
> gdb_assert (code == TYPE_CODE_UNION
> || code == TYPE_CODE_STRUCT
> || code == TYPE_CODE_ENUM);
> - return current_language->la_make_symbol_completion_list (cdata, text, word,
> - code);
> + current_language->la_make_symbol_completion_list (cdata, text, word, code);
> }
>
> /* Like make_symbol_completion_list, but suitable for use as a
> completion function. */
>
> -VEC (char_ptr) *
> +void
> make_symbol_completion_list_fn (struct completer_data *cdata,
> struct cmd_list_element *ignore,
> const char *text, const char *word)
> {
> - return make_symbol_completion_list (cdata, text, word);
> + make_symbol_completion_list (cdata, text, word);
> }
>
> /* Like make_symbol_completion_list, but returns a list of symbols
> defined in a source file FILE. */
>
> -VEC (char_ptr) *
> +void
> make_file_symbol_completion_list (struct completer_data *cdata,
> const char *text, const char *word,
> const char *srcfile)
> @@ -5624,7 +5591,7 @@ make_file_symbol_completion_list (struct completer_data *cdata,
> /* A double-quoted string is never a symbol, nor does it make sense
> to complete it any other way. */
> {
> - return NULL;
> + return;
> }
> else
> {
> @@ -5635,8 +5602,6 @@ make_file_symbol_completion_list (struct completer_data *cdata,
>
> sym_text_len = strlen (sym_text);
>
> - return_val = NULL;
> -
> /* Find the symtab for SRCFILE (this loads it if it was not yet read
> in). */
> s = lookup_symtab (srcfile);
> @@ -5652,7 +5617,7 @@ make_file_symbol_completion_list (struct completer_data *cdata,
>
> /* If we have no symtab for that file, return an empty list. */
> if (s == NULL)
> - return (return_val);
> + return;
>
> /* Go through this symtab and check the externs and statics for
> symbols which match. */
> @@ -5670,8 +5635,6 @@ make_file_symbol_completion_list (struct completer_data *cdata,
> COMPLETION_LIST_ADD_SYMBOL (cdata, sym, sym_text, sym_text_len,
> text, word);
> }
> -
> - return (return_val);
> }
>
> /* A helper function for make_source_files_completion_list. It adds
> @@ -5680,10 +5643,9 @@ make_file_symbol_completion_list (struct completer_data *cdata,
>
> static void
> add_filename_to_list (struct completer_data *cdata, const char *fname,
> - const char *text, const char *word,
> - VEC (char_ptr) **list)
> + const char *text, const char *word)
> {
> - (void) add_completion (cdata, list, fname, text, word);
> + (void) add_completion (cdata, fname, text, word);
> }
>
> static int
> @@ -5711,7 +5673,6 @@ struct add_partial_filename_data
> const char *text;
> const char *word;
> int text_len;
> - VEC (char_ptr) **list;
>
> /* Completion data used by the completer function. */
> struct completer_data *completer_data;
> @@ -5733,7 +5694,7 @@ maybe_add_partial_symtab_filename (const char *filename, const char *fullname,
> /* This file matches for a completion; add it to the
> current list of matches. */
> add_filename_to_list (data->completer_data, filename, data->text,
> - data->word, data->list);
> + data->word);
> }
> else
> {
> @@ -5744,17 +5705,15 @@ maybe_add_partial_symtab_filename (const char *filename, const char *fullname,
> && filename_ncmp (base_name, data->text, data->text_len) == 0)
> {
> add_filename_to_list (data->completer_data, base_name, data->text,
> - data->word, data->list);
> + data->word);
> }
> }
> }
>
> -/* Return a vector of all source files whose names begin with matching
> - TEXT. The file names are looked up in the symbol tables of this
> - program. If the answer is no matchess, then the return value is
> - NULL. */
> +/* Add all source files whose names begin with matching TEXT to CDATA.
> + The file names are looked up in the symbol tables of this program. */
>
> -VEC (char_ptr) *
> +void
> make_source_files_completion_list (struct completer_data *cdata,
> const char *text, const char *word)
> {
> @@ -5762,16 +5721,13 @@ make_source_files_completion_list (struct completer_data *cdata,
> struct symtab *s;
> struct objfile *objfile;
> size_t text_len = strlen (text);
> - VEC (char_ptr) *list = NULL;
> const char *base_name;
> struct add_partial_filename_data datum;
> struct filename_seen_cache *filename_seen_cache;
> - struct cleanup *back_to, *cache_cleanup;
> + struct cleanup *cache_cleanup;
>
> if (!have_full_symbols () && !have_partial_symbols ())
> - return list;
> -
> - back_to = make_cleanup (do_free_completion_list, &list);
> + return;
>
> filename_seen_cache = create_filename_seen_cache ();
> cache_cleanup = make_cleanup (delete_filename_seen_cache,
> @@ -5786,7 +5742,7 @@ make_source_files_completion_list (struct completer_data *cdata,
> {
> /* This file matches for a completion; add it to the current
> list of matches. */
> - add_filename_to_list (cdata, s->filename, text, word, &list);
> + add_filename_to_list (cdata, s->filename, text, word);
> }
> else
> {
> @@ -5798,7 +5754,7 @@ make_source_files_completion_list (struct completer_data *cdata,
> if (base_name != s->filename
> && !filename_seen (filename_seen_cache, base_name, 1)
> && filename_ncmp (base_name, text, text_len) == 0)
> - add_filename_to_list (cdata, base_name, text, word, &list);
> + add_filename_to_list (cdata, base_name, text, word);
> }
> }
>
> @@ -5806,15 +5762,11 @@ make_source_files_completion_list (struct completer_data *cdata,
> datum.text = text;
> datum.word = word;
> datum.text_len = text_len;
> - datum.list = &list;
> datum.completer_data = cdata;
> map_symbol_filenames (maybe_add_partial_symtab_filename, &datum,
> 0 /*need_fullname*/);
>
> do_cleanups (cache_cleanup);
> - discard_cleanups (back_to);
> -
> - return list;
> }
> \f
> /* Track MAIN */
> diff --git a/gdb/symtab.h b/gdb/symtab.h
> index 018852c..755e1d5 100644
> --- a/gdb/symtab.h
> +++ b/gdb/symtab.h
> @@ -1454,30 +1454,31 @@ extern void forget_cached_source_info (void);
>
> extern void select_source_symtab (struct symtab *);
>
> -extern VEC (char_ptr) *default_make_symbol_completion_list_break_on
> +extern void default_make_symbol_completion_list_break_on
> (struct completer_data *cdata, const char *text, const char *word,
> const char *break_on, enum type_code code);
> -extern VEC (char_ptr) *
> +
> +extern void
> default_make_symbol_completion_list (struct completer_data *,
> const char *, const char *,
> enum type_code);
> -extern VEC (char_ptr) *
> +extern void
> make_symbol_completion_list (struct completer_data *, const char *,
> const char *);
> -extern VEC (char_ptr) *
> +extern void
> make_symbol_completion_type (struct completer_data *,
> const char *, const char *,
> enum type_code);
> -extern VEC (char_ptr) *
> +extern void
> make_symbol_completion_list_fn (struct completer_data *,
> struct cmd_list_element *,
> const char *, const char *);
>
> -extern VEC (char_ptr) *
> +extern void
> make_file_symbol_completion_list (struct completer_data *,
> const char *, const char *, const char *);
>
> -extern VEC (char_ptr) *
> +extern void
> make_source_files_completion_list (struct completer_data *, const char *,
> const char *);
>
> diff --git a/gdb/tui/tui-layout.c b/gdb/tui/tui-layout.c
> index 8d420894..c4c9cda 100644
> --- a/gdb/tui/tui-layout.c
> +++ b/gdb/tui/tui-layout.c
> @@ -353,7 +353,7 @@ tui_default_win_viewport_height (enum tui_win_type type,
> /* Complete possible layout names. TEXT is the complete text entered so
> far, WORD is the word currently being completed. */
>
> -static VEC (char_ptr) *
> +static void
> layout_completer (struct completer_data *cdata,
> struct cmd_list_element *ignore,
> const char *text, const char *word)
> @@ -361,7 +361,7 @@ layout_completer (struct completer_data *cdata,
> static const char *layout_names [] =
> { "src", "asm", "split", "regs", "next", "prev", NULL };
>
> - return complete_on_enum (cdata, layout_names, text, word);
> + complete_on_enum (cdata, layout_names, text, word);
> }
>
> /* Function to initialize gdb commands, for tui window layout
> diff --git a/gdb/tui/tui-regs.c b/gdb/tui/tui-regs.c
> index 17efd9f..bef01e5 100644
> --- a/gdb/tui/tui-regs.c
> +++ b/gdb/tui/tui-regs.c
> @@ -668,29 +668,26 @@ tui_reg_command (char *args, int from_tty)
> /* Complete names of register groups, and add the special "prev" and "next"
> names. */
>
> -static VEC (char_ptr) *
> +static void
> tui_reggroup_completer (struct completer_data *cdata,
> struct cmd_list_element *ignore,
> const char *text, const char *word)
> {
> - VEC (char_ptr) *result = NULL;
> static const char *extra[] = { "next", "prev", NULL };
> size_t len = strlen (word);
> const char **tmp;
>
> - result = reggroup_completer (cdata, ignore, text, word);
> + reggroup_completer (cdata, ignore, text, word);
>
> for (tmp = extra; *tmp != NULL; ++tmp)
> {
> if (strncmp (word, *tmp, len) == 0)
> {
> - if (add_completion (cdata, &result, *tmp, NULL, NULL)
> + if (add_completion (cdata, *tmp, NULL, NULL)
> == ADD_COMPLETION_MAX_REACHED)
> break;
> }
> }
> -
> - return result;
> }
>
> /* Provide a prototype to silence -Wmissing-prototypes. */
> diff --git a/gdb/tui/tui-win.c b/gdb/tui/tui-win.c
> index 8e7fbd1..4690af1 100644
> --- a/gdb/tui/tui-win.c
> +++ b/gdb/tui/tui-win.c
> @@ -359,13 +359,12 @@ tui_set_var_cmd (char *null_args, int from_tty, struct cmd_list_element *c)
> window names 'next' and 'prev' will also be considered as possible
> completions of the window name. */
>
> -static VEC (char_ptr) *
> +static void
> window_name_completer (int include_next_prev_p,
> struct completer_data *cdata,
> const char *text, const char *word)
> {
> VEC (const_char_ptr) *completion_name_vec = NULL;
> - VEC (char_ptr) *matches_vec;
> int win_type;
>
> for (win_type = SRC_WIN; win_type < MAX_MAJOR_WINDOWS; win_type++)
> @@ -399,32 +398,29 @@ window_name_completer (int include_next_prev_p,
> }
>
> VEC_safe_push (const_char_ptr, completion_name_vec, NULL);
> - matches_vec
> - = complete_on_enum (cdata,
> - VEC_address (const_char_ptr, completion_name_vec),
> - text, word);
> + complete_on_enum (cdata,
> + VEC_address (const_char_ptr, completion_name_vec),
> + text, word);
>
> VEC_free (const_char_ptr, completion_name_vec);
> -
> - return matches_vec;
> }
>
> /* Complete possible window names to focus on. TEXT is the complete text
> entered so far, WORD is the word currently being completed. */
>
> -static VEC (char_ptr) *
> +static void
> focus_completer (struct completer_data *cdata,
> struct cmd_list_element *ignore,
> const char *text, const char *word)
> {
> - return window_name_completer (1, cdata, text, word);
> + window_name_completer (1, cdata, text, word);
> }
>
> /* Complete possible window names for winheight command. TEXT is the
> complete text entered so far, WORD is the word currently being
> completed. */
>
> -static VEC (char_ptr) *
> +static void
> winheight_completer (struct completer_data *cdata,
> struct cmd_list_element *ignore,
> const char *text, const char *word)
> @@ -432,9 +428,9 @@ winheight_completer (struct completer_data *cdata,
> /* The first word is the window name. That we can complete. Subsequent
> words can't be completed. */
> if (word != text)
> - return NULL;
> + return;
>
> - return window_name_completer (0, cdata, text, word);
> + window_name_completer (0, cdata, text, word);
> }
>
> /* Function to initialize gdb commands, for tui window
> diff --git a/gdb/value.c b/gdb/value.c
> index 22d392a..b3d4f04 100644
> --- a/gdb/value.c
> +++ b/gdb/value.c
> @@ -2062,10 +2062,9 @@ lookup_only_internalvar (const char *name)
> Returns a vector of newly allocated strings, or NULL if no matches
> were found. */
>
> -VEC (char_ptr) *
> +void
> complete_internalvar (struct completer_data *cdata, const char *name)
> {
> - VEC (char_ptr) *result = NULL;
> struct internalvar *var;
> int len;
>
> @@ -2074,12 +2073,10 @@ complete_internalvar (struct completer_data *cdata, const char *name)
> for (var = internalvars; var; var = var->next)
> if (strncmp (var->name, name, len) == 0)
> {
> - if (add_completion (cdata, &result, var->name, NULL, NULL)
> + if (add_completion (cdata, var->name, NULL, NULL)
> == ADD_COMPLETION_MAX_REACHED)
> break;
> }
> -
> - return result;
> }
>
> /* Create an internal variable with name NAME and with a void value.
> diff --git a/gdb/value.h b/gdb/value.h
> index 03df1b7..58c5c26 100644
> --- a/gdb/value.h
> +++ b/gdb/value.h
> @@ -876,8 +876,8 @@ extern struct internalvar *lookup_only_internalvar (const char *name);
>
> extern struct internalvar *create_internalvar (const char *name);
>
> -extern VEC (char_ptr) *complete_internalvar (struct completer_data *cdata,
> - const char *name);
> +extern void complete_internalvar (struct completer_data *cdata,
> + const char *name);
>
> /* An internalvar can be dynamically computed by supplying a vector of
> function pointers to perform various operations. */