diff options
author | Tom Tromey <tom@tromey.com> | 2019-11-15 16:56:20 -0700 |
---|---|---|
committer | Tom Tromey <tom@tromey.com> | 2019-11-26 14:20:30 -0700 |
commit | 3ea16160a66e0e3bc59842e27e41890411729a86 (patch) | |
tree | ff0b73e9b147676969cefb85ba6fe24c88374473 /gdb/cli | |
parent | 1a6d41c6433a0980f302c480b1d1db71234b49e4 (diff) | |
download | gdb-3ea16160a66e0e3bc59842e27e41890411729a86.zip gdb-3ea16160a66e0e3bc59842e27e41890411729a86.tar.gz gdb-3ea16160a66e0e3bc59842e27e41890411729a86.tar.bz2 |
Let commands free "name"
This adds a "name_allocated" field to cmd_list_element, so that
commands can own their "name" when necessary. Then, this changes a
few spots in gdb that currently free the name by hand to instead use
this facility.
gdb/ChangeLog
2019-11-26 Tom Tromey <tom@tromey.com>
* python/py-function.c (fnpy_init): Update.
* value.h (add_internal_function): Adjust declaration.
* value.c (function_destroyer): Remove.
(do_add_internal_function): Don't set destroyer or copy name.
(add_internal_function): Take unique_xmalloc_ptr<char> for name.
Set name_allocated.
* python/py-cmd.c (cmdpy_destroyer): Don't free "name".
(cmdpy_init): Set name_allocated.
* cli/cli-decode.h (struct cmd_list_element) <name_allocated>: New
member.
(~cmd_list_element): Free "name" if needed.
Change-Id: Ie1435cea5bbf4bd92056125f112917c607cbb761
Diffstat (limited to 'gdb/cli')
-rw-r--r-- | gdb/cli/cli-decode.h | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/gdb/cli/cli-decode.h b/gdb/cli/cli-decode.h index 2ec4a97..8ea4059 100644 --- a/gdb/cli/cli-decode.h +++ b/gdb/cli/cli-decode.h @@ -55,6 +55,7 @@ struct cmd_list_element deprecated_warn_user (0), malloced_replacement (0), doc_allocated (0), + name_allocated (0), hook_in (0), allow_unknown (0), abbrev_flag (0), @@ -69,6 +70,8 @@ struct cmd_list_element { if (doc && doc_allocated) xfree ((char *) doc); + if (name_allocated) + xfree ((char *) name); } DISABLE_COPY_AND_ASSIGN (cmd_list_element); @@ -109,6 +112,10 @@ struct cmd_list_element unsigned int doc_allocated : 1; + /* Set if the name field should be xfree'd. */ + + unsigned int name_allocated : 1; + /* Flag that specifies if this command is already running its hook. */ /* Prevents the possibility of hook recursion. */ unsigned int hook_in : 1; |