From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 20261 invoked by alias); 11 Sep 2017 21:43:26 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Received: (qmail 20231 invoked by uid 89); 11 Sep 2017 21:43:24 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-3.7 required=5.0 tests=AWL,BAYES_00,RCVD_IN_DNSWL_NONE,SPF_PASS autolearn=ham version=3.3.2 spammy=Hx-languages-length:1140 X-HELO: gproxy3-pub.mail.unifiedlayer.com Received: from gproxy3-pub.mail.unifiedlayer.com (HELO gproxy3-pub.mail.unifiedlayer.com) (69.89.30.42) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 11 Sep 2017 21:43:22 +0000 Received: from cmgw3 (unknown [10.0.90.84]) by gproxy3.mail.unifiedlayer.com (Postfix) with ESMTP id B901642D52 for ; Mon, 11 Sep 2017 15:36:59 -0600 (MDT) Received: from box522.bluehost.com ([74.220.219.122]) by cmgw3 with id 8Mcw1w00D2f2jeq01MczGd; Mon, 11 Sep 2017 15:36:59 -0600 X-Authority-Analysis: v=2.2 cv=K/VSJ2eI c=1 sm=1 tr=0 a=GsOEXm/OWkKvwdLVJsfwcA==:117 a=GsOEXm/OWkKvwdLVJsfwcA==:17 a=2JCJgTwv5E4A:10 a=_ZhYKdCeAAAA:8 a=M_d0NAwPw9sa2qifBAoA:9 a=uqOk3ZSnBfCTOznnrPA1:22 Received: from 75-166-76-94.hlrn.qwest.net ([75.166.76.94]:51978 helo=bapiya) by box522.bluehost.com with esmtpsa (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.87) (envelope-from ) id 1drWO0-002Cg1-CH; Mon, 11 Sep 2017 15:36:56 -0600 From: Tom Tromey To: Simon Marchi Cc: Tom Tromey , gdb-patches@sourceware.org Subject: Re: [RFA 3/3] Make extract_arg return a std::string References: <20170911003325.3765-1-tom@tromey.com> <20170911003325.3765-4-tom@tromey.com> <31794437bc5e56865f80cc72691899a4@polymtl.ca> Date: Mon, 11 Sep 2017 21:43:00 -0000 In-Reply-To: <31794437bc5e56865f80cc72691899a4@polymtl.ca> (Simon Marchi's message of "Mon, 11 Sep 2017 21:51:57 +0200") Message-ID: <8760cohq89.fsf@bapiya> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.0.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-BWhitelist: no X-Exim-ID: 1drWO0-002Cg1-CH X-Source-Sender: 75-166-76-94.hlrn.qwest.net (bapiya) [75.166.76.94]:51978 X-Source-Auth: tom+tromey.com X-Email-Count: 4 X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTIyLmJsdWVob3N0LmNvbQ== X-Local-Domain: yes X-SW-Source: 2017-09/txt/msg00315.txt.bz2 >>>>> "Simon" == Simon Marchi writes: >> Change extract_arg to return a std::string and fix up all the users. >> I think string is mildly better than unique_xmalloc_ptr, when >> possible, because it provides a more robust API. Simon> I agree, for strings we allocate dynamically ourselves, it makes sense Simon> to use std::string. For dynamically allocated strings coming from Simon> external APIs we use, then unique_xmalloc_ptr make sense, since Simon> it doesn't require doing a copy. For things that are always Simon> constant/literal strings, the const char *. That's my thinking exactly. It would be nice if string could adopt a unique_xmalloc_ptr. or we could make string-returning variants of a few functions like tilde_expand. On the callee side we could move to string_view in the future. Simon> It's a bit funny to refer to extract_arg when this function is also Simon> named extract_arg. What about: "A const-correct version of the Simon> above." ? I've made this change in patch #1. I made the other changes in this patch. Tom