From 3ea16160a66e0e3bc59842e27e41890411729a86 Mon Sep 17 00:00:00 2001 From: Tom Tromey Date: Fri, 15 Nov 2019 16:56:20 -0700 Subject: 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 * 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 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) : New member. (~cmd_list_element): Free "name" if needed. Change-Id: Ie1435cea5bbf4bd92056125f112917c607cbb761 --- gdb/python/py-function.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'gdb/python/py-function.c') diff --git a/gdb/python/py-function.c b/gdb/python/py-function.c index 1c45887..d946105 100644 --- a/gdb/python/py-function.c +++ b/gdb/python/py-function.c @@ -127,8 +127,8 @@ fnpy_init (PyObject *self, PyObject *args, PyObject *kwds) if (! docstring) docstring.reset (xstrdup (_("This function is not documented."))); - add_internal_function (name, std::move (docstring), fnpy_call, - self_ref.release ()); + add_internal_function (make_unique_xstrdup (name), std::move (docstring), + fnpy_call, self_ref.release ()); return 0; } -- cgit v1.1