Use cmd_list_element::doc_allocated for Python commands
authorTom Tromey <tom@tromey.com>
Fri, 15 Nov 2019 23:41:12 +0000 (16:41 -0700)
committerTom Tromey <tom@tromey.com>
Tue, 26 Nov 2019 21:20:29 +0000 (14:20 -0700)
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-26  Tom Tromey  <tom@tromey.com>

* python/py-cmd.c (cmdpy_destroyer): Don't free "doc".
(cmdpy_init): Set "doc_allocated".

Change-Id: I0014edc117b051bba1f4db267687d231e7fe9b56

gdb/ChangeLog
gdb/python/py-cmd.c

index 94a8bdc8dc1e24ba73ba1d86765a5451ba836872..821afd313d4c6bd6c731a1ab5b773c4e4f9c6f48 100644 (file)
@@ -1,3 +1,8 @@
+2019-11-26  Tom Tromey  <tom@tromey.com>
+
+       * python/py-cmd.c (cmdpy_destroyer): Don't free "doc".
+       (cmdpy_init): Set "doc_allocated".
+
 2019-11-26  Tom Tromey  <tom@tromey.com>
 
        * gdbsupport/thread-pool.c (thread_pool::set_thread_count): Set
index 87d1888c528c3e581f2a5cf348004a8e1cf4c348..e3497d6f928eb705cf6b7f9203b66992824af4eb 100644 (file)
@@ -98,10 +98,8 @@ cmdpy_destroyer (struct cmd_list_element *self, void *context)
   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 @@ cmdpy_init (PyObject *self, PyObject *args, PyObject *kw)
       /* 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 ());
This page took 0.037241 seconds and 4 git commands to generate.