[review,v2] Use cmd_list_element::doc_allocated for Python commands
Commit Message
Change URL: https://gnutoolchain-gerrit.osci.io/r/c/binutils-gdb/+/661
......................................................................
Use cmd_list_element::doc_allocated for Python commands
Python commands manage their "doc" string manually, but
cmd_list_element already has doc_allocated to handle this case. This
changes the Python code to use the existing facility.
gdb/ChangeLog
2019-11-15 Tom Tromey <tom@tromey.com>
* python/py-cmd.c (cmdpy_destroyer): Don't free "doc".
(cmdpy_init): Set "doc_allocated".
Change-Id: I0014edc117b051bba1f4db267687d231e7fe9b56
---
M gdb/ChangeLog
M gdb/python/py-cmd.c
2 files changed, 7 insertions(+), 3 deletions(-)
@@ -1,3 +1,8 @@
+2019-11-15 Tom Tromey <tom@tromey.com>
+
+ * python/py-cmd.c (cmdpy_destroyer): Don't free "doc".
+ (cmdpy_init): Set "doc_allocated".
+
2019-11-15 Christian Biesinger <cbiesinger@google.com>
* Makefile.in: Replace {posix,mingw}-strerror.c with safe-strerror.c.
@@ -98,10 +98,8 @@
gdbpy_ref<cmdpy_object> cmd ((cmdpy_object *) context);
cmd->command = NULL;
- /* We allocated the name, doc string, and perhaps the prefix
- name. */
+ /* We allocated the name and perhaps the prefix name. */
xfree ((char *) self->name);
- xfree ((char *) self->doc);
xfree ((char *) self->prefixname);
}
@@ -563,6 +561,7 @@
/* There appears to be no API to set this. */
cmd->func = cmdpy_function;
cmd->destroyer = cmdpy_destroyer;
+ cmd->doc_allocated = 1;
obj->command = cmd;
set_cmd_context (cmd, self_ref.release ());