From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca (simark.ca [158.69.221.121]) by sourceware.org (Postfix) with ESMTPS id 8C8ED3858D28 for ; Fri, 5 Nov 2021 19:20:32 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 8C8ED3858D28 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=simark.ca Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=simark.ca Received: from [172.16.0.95] (192-222-180-24.qc.cable.ebox.net [192.222.180.24]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPSA id 283031ECEB; Fri, 5 Nov 2021 15:20:32 -0400 (EDT) Subject: Re: [PATCH v2 01/32] Introduce make_unique_xstrndup To: Tom Tromey , gdb-patches@sourceware.org References: <20211104180907.2360627-1-tom@tromey.com> <20211104180907.2360627-2-tom@tromey.com> From: Simon Marchi Message-ID: <2a09d84d-b1c0-5bca-54f8-9d76d645fc88@simark.ca> Date: Fri, 5 Nov 2021 15:20:31 -0400 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.13.0 MIME-Version: 1.0 In-Reply-To: <20211104180907.2360627-2-tom@tromey.com> Content-Type: text/plain; charset=utf-8 Content-Language: tl Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-11.2 required=5.0 tests=BAYES_00, GIT_PATCH_0, KAM_DMARC_STATUS, NICE_REPLY_A, SPF_HELO_PASS, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 05 Nov 2021 19:20:34 -0000 On 2021-11-04 2:08 p.m., Tom Tromey wrote: > This adds a new make_unique_xstrndup function, which is the "n" > analogue of make_unique_xstrdup. This is used by later patches. > --- > gdbsupport/gdb_unique_ptr.h | 9 +++++++++ > 1 file changed, 9 insertions(+) > > diff --git a/gdbsupport/gdb_unique_ptr.h b/gdbsupport/gdb_unique_ptr.h > index df88cea9cf0..77aecb48e62 100644 > --- a/gdbsupport/gdb_unique_ptr.h > +++ b/gdbsupport/gdb_unique_ptr.h > @@ -64,4 +64,13 @@ make_unique_xstrdup (const char *str) > return gdb::unique_xmalloc_ptr (xstrdup (str)); > } > > +/* Dup the first N characters of STR and return a unique_xmalloc_ptr > + for the result. The result is always \0-terminated. */ > + > +static inline gdb::unique_xmalloc_ptr > +make_unique_xstrndup (const char *str, size_t n) > +{ > + return gdb::unique_xmalloc_ptr (xstrndup (str, n)); > +} > + > #endif /* COMMON_GDB_UNIQUE_PTR_H */ > -- > 2.31.1 > I found one spot where you could use this, in cli/cli-setshow.exp. I think that if the new function is used, this patch could be pushed right away. Simon