From patchwork Sun Nov 17 21:52:30 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: 35997 Received: (qmail 12103 invoked by alias); 17 Nov 2019 21:52:37 -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 12087 invoked by uid 89); 17 Nov 2019 21:52:37 -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=sk:I0014ed, sk:i0014ed 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; Sun, 17 Nov 2019 21:52:35 +0000 Received: by mx1.osci.io (Postfix, from userid 994) id 7EDCC204BF; Sun, 17 Nov 2019 16:52:33 -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 A094220373; Sun, 17 Nov 2019 16:52:31 -0500 (EST) Received: from localhost (localhost [127.0.0.1]) by gnutoolchain-gerrit.osci.io (Postfix) with ESMTP id 6002F2816F; Sun, 17 Nov 2019 16:52:31 -0500 (EST) X-Gerrit-PatchSet: 2 Date: Sun, 17 Nov 2019 16:52:30 -0500 From: "Tom Tromey (Code Review)" To: gdb-patches@sourceware.org Cc: Andrew Burgess Auto-Submitted: auto-generated X-Gerrit-MessageType: newpatchset Subject: [review v2] 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: e097a3102bb42ef0a7d10ede396d432defc0ecdf In-Reply-To: References: Reply-To: tromey@sourceware.org, andrew.burgess@embecosm.com, gdb-patches@sourceware.org MIME-Version: 1.0 Content-Disposition: inline User-Agent: Gerrit/3.0.3-79-g83ff7f88f1 Message-Id: <20191117215231.6002F2816F@gnutoolchain-gerrit.osci.io> 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, 7 insertions(+), 3 deletions(-) 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..e3497d6 100644 --- a/gdb/python/py-cmd.c +++ b/gdb/python/py-cmd.c @@ -98,10 +98,8 @@ gdbpy_ref 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 ());