public inbox for gdb-cvs@sourceware.org
help / color / mirror / Atom feed
* [binutils-gdb] Use cmd_list_element::doc_allocated for Python commands
@ 2019-11-26 21:28 Tom Tromey
  0 siblings, 0 replies; only message in thread
From: Tom Tromey @ 2019-11-26 21:28 UTC (permalink / raw)
  To: gdb-cvs

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=8318f3c337cf46ee6309b4a7f06f3934fc94b4bd

commit 8318f3c337cf46ee6309b4a7f06f3934fc94b4bd
Author: Tom Tromey <tom@tromey.com>
Date:   Fri Nov 15 16:41:12 2019 -0700

    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-26  Tom Tromey  <tom@tromey.com>
    
    	* python/py-cmd.c (cmdpy_destroyer): Don't free "doc".
    	(cmdpy_init): Set "doc_allocated".
    
    Change-Id: I0014edc117b051bba1f4db267687d231e7fe9b56

Diff:
---
 gdb/ChangeLog       | 5 +++++
 gdb/python/py-cmd.c | 5 ++---
 2 files changed, 7 insertions(+), 3 deletions(-)

diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 94a8bdc..821afd3 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,5 +1,10 @@
 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
 	name of worker thread.
 	* gdbsupport/common.m4 (GDB_AC_COMMON): Check for
diff --git a/gdb/python/py-cmd.c b/gdb/python/py-cmd.c
index 87d1888..e3497d6 100644
--- a/gdb/python/py-cmd.c
+++ b/gdb/python/py-cmd.c
@@ -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 ());


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2019-11-26 21:28 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-11-26 21:28 [binutils-gdb] Use cmd_list_element::doc_allocated for Python commands Tom Tromey

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).