From patchwork Wed Feb 27 20:18:38 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 31653 Received: (qmail 114709 invoked by alias); 27 Feb 2019 20:18: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 114451 invoked by uid 89); 27 Feb 2019 20:18: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, RCVD_IN_DNSWL_NONE, SPF_HELO_PASS autolearn=ham version=3.3.2 spammy=Packet, gdb_byte X-HELO: gateway34.websitewelcome.com Received: from gateway34.websitewelcome.com (HELO gateway34.websitewelcome.com) (192.185.148.119) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 27 Feb 2019 20:18:57 +0000 Received: from cm10.websitewelcome.com (cm10.websitewelcome.com [100.42.49.4]) by gateway34.websitewelcome.com (Postfix) with ESMTP id E9A721115D67 for ; Wed, 27 Feb 2019 14:18:55 -0600 (CST) Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with SMTP id z5fLgJA1o2PzOz5fLgjimU; Wed, 27 Feb 2019 14:18:55 -0600 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=tromey.com; s=default; h=References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From: Sender:Reply-To:MIME-Version:Content-Type:Content-Transfer-Encoding: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=hqvGC6BZZl9agLKmdzo26s+U9i/LovYd5vpOWo6bnk0=; b=HfpSx1L5ahHlUqNiBBzPDAXhG2 mJPGP3xz/oqv0oaVXsKGKbHkyOm/1AmTCg+tbtrSzLM7abPE7EcL7w0nBuBoDhBGHGiQDU5kgUlx5 wL/0KOpwlMgdW4pRemzdNRX76; Received: from 75-166-85-218.hlrn.qwest.net ([75.166.85.218]:36364 helo=bapiya.Home) by box5379.bluehost.com with esmtpsa (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.91) (envelope-from ) id 1gz5fL-004Fi1-O9; Wed, 27 Feb 2019 14:18:55 -0600 From: Tom Tromey To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: [PATCH v2 11/22] Use unique_xmalloc_ptr in remote.c Date: Wed, 27 Feb 2019 13:18:38 -0700 Message-Id: <20190227201849.32210-12-tom@tromey.com> In-Reply-To: <20190227201849.32210-1-tom@tromey.com> References: <20190227201849.32210-1-tom@tromey.com> This removes a cleanup from remote.c, replacing it with unique_xmalloc_ptr. gdb/ChangeLog 2019-02-27 Tom Tromey * remote.c (remote_target::remote_parse_stop_reply): Use unique_xmalloc_ptr. --- gdb/ChangeLog | 5 +++++ gdb/remote.c | 11 +++++------ 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/gdb/remote.c b/gdb/remote.c index f80dcdaee94..5f658deefaa 100644 --- a/gdb/remote.c +++ b/gdb/remote.c @@ -7314,14 +7314,13 @@ Packet: '%s'\n"), /* Save the pathname for event reporting and for the next run command. */ - char *pathname = (char *) xmalloc (pathlen + 1); - struct cleanup *old_chain = make_cleanup (xfree, pathname); - hex2bin (p1, (gdb_byte *) pathname, pathlen); - pathname[pathlen] = '\0'; - discard_cleanups (old_chain); + gdb::unique_xmalloc_ptr pathname + ((char *) xmalloc (pathlen + 1)); + hex2bin (p1, (gdb_byte *) pathname.get (), pathlen); + pathname.get ()[pathlen] = '\0'; /* This is freed during event handling. */ - event->ws.value.execd_pathname = pathname; + event->ws.value.execd_pathname = pathname.release (); event->ws.kind = TARGET_WAITKIND_EXECD; /* Skip the registers included in this packet, since