Let commands free "name"
authorTom Tromey <tom@tromey.com>
Fri, 15 Nov 2019 23:56:20 +0000 (16:56 -0700)
committerTom Tromey <tom@tromey.com>
Tue, 26 Nov 2019 21:20:30 +0000 (14:20 -0700)
commit3ea16160a66e0e3bc59842e27e41890411729a86
treeff0b73e9b147676969cefb85ba6fe24c88374473
parent1a6d41c6433a0980f302c480b1d1db71234b49e4
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
gdb/ChangeLog
gdb/cli/cli-decode.h
gdb/python/py-cmd.c
gdb/python/py-function.c
gdb/value.c
gdb/value.h