From patchwork Sat Nov 16 00:03:52 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Simon Marchi (Code Review)" X-Patchwork-Id: 35965 Received: (qmail 118490 invoked by alias); 16 Nov 2019 00:03:59 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 118424 invoked by uid 89); 16 Nov 2019 00:03:58 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-26.9 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3 autolearn=ham version=3.3.1 spammy= X-HELO: mx1.osci.io Received: from polly.osci.io (HELO mx1.osci.io) (8.43.85.229) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Sat, 16 Nov 2019 00:03:56 +0000 Received: by mx1.osci.io (Postfix, from userid 994) id 3E20620562; Fri, 15 Nov 2019 19:03:54 -0500 (EST) Received: from gnutoolchain-gerrit.osci.io (gnutoolchain-gerrit.osci.io [IPv6:2620:52:3:1:5054:ff:fe06:16ca]) by mx1.osci.io (Postfix) with ESMTP id 6DA6A20393 for ; Fri, 15 Nov 2019 19:03:53 -0500 (EST) Received: from localhost (localhost [127.0.0.1]) by gnutoolchain-gerrit.osci.io (Postfix) with ESMTP id C277220AF6 for ; Fri, 15 Nov 2019 19:03:52 -0500 (EST) X-Gerrit-PatchSet: 1 Date: Fri, 15 Nov 2019 19:03:52 -0500 From: "Tom Tromey (Code Review)" To: gdb-patches@sourceware.org Message-ID: Auto-Submitted: auto-generated X-Gerrit-MessageType: newchange Subject: [review] Use cmd_list_element::doc_allocated for Python commands X-Gerrit-Change-Id: I0014edc117b051bba1f4db267687d231e7fe9b56 X-Gerrit-Change-Number: 661 X-Gerrit-ChangeURL: X-Gerrit-Commit: d26a2143f11cecc5536d3aeb79d91ab9a8b09435 References: Reply-To: tromey@sourceware.org, gdb-patches@sourceware.org MIME-Version: 1.0 Content-Disposition: inline User-Agent: Gerrit/3.0.3-76-gf8b6da0ab5 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 * 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, 6 insertions(+), 1 deletion(-) diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 90a2b64..bbef23a 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,8 @@ +2019-11-15 Tom Tromey + + * python/py-cmd.c (cmdpy_destroyer): Don't free "doc". + (cmdpy_init): Set "doc_allocated". + 2019-11-15 Christian Biesinger * Makefile.in: Replace {posix,mingw}-strerror.c with safe-strerror.c. diff --git a/gdb/python/py-cmd.c b/gdb/python/py-cmd.c index 87d1888..5b9a810 100644 --- a/gdb/python/py-cmd.c +++ b/gdb/python/py-cmd.c @@ -101,7 +101,6 @@ /* We allocated the name, doc string, and perhaps the prefix name. */ xfree ((char *) self->name); - xfree ((char *) self->doc); xfree ((char *) self->prefixname); } @@ -563,6 +562,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 ());