From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 4912 invoked by alias); 1 Mar 2013 18:56:11 -0000 Received: (qmail 4900 invoked by uid 22791); 1 Mar 2013 18:56:10 -0000 X-SWARE-Spam-Status: No, hits=-8.0 required=5.0 tests=AWL,BAYES_00,KHOP_RCVD_UNTRUST,KHOP_SPAMHAUS_DROP,KHOP_THREADED,RCVD_IN_DNSWL_HI,RCVD_IN_HOSTKARMA_W,RP_MATCHES_RCVD,SPF_HELO_PASS X-Spam-Check-By: sourceware.org Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Fri, 01 Mar 2013 18:55:58 +0000 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id r21ItuVP024567 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Fri, 1 Mar 2013 13:55:57 -0500 Received: from [127.0.0.1] (ovpn01.gateway.prod.ext.ams2.redhat.com [10.39.146.11]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id r21Itt5J017505; Fri, 1 Mar 2013 13:55:55 -0500 Message-ID: <5130F9BB.6020002@redhat.com> Date: Fri, 01 Mar 2013 18:56:00 -0000 From: Pedro Alves User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130110 Thunderbird/17.0.2 MIME-Version: 1.0 To: Eli Zaretskii CC: Keith Seitz , gdb-patches@sourceware.org Subject: Re: [RFA] Constify find_condition_and_thread References: <5130F0FD.2040203@redhat.com> <83ppzjufp5.fsf@gnu.org> In-Reply-To: <83ppzjufp5.fsf@gnu.org> Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit 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 X-SW-Source: 2013-03/txt/msg00037.txt.bz2 On 03/01/2013 06:40 PM, Eli Zaretskii wrote: >> Date: Fri, 01 Mar 2013 10:18:37 -0800 >> From: Keith Seitz >> >> - expr = parse_exp_1 (&tok, pc, block_for_pc (pc), 0); >> + orig = copy = xstrdup (tok); >> + cleanup = make_cleanup (xfree, orig); >> + expr = parse_exp_1 (©, pc, block_for_pc (pc), 0); >> xfree (expr); >> + tok += copy - orig; >> + do_cleanups (cleanup); > > If we really need this kind of dance, just to avoid explicit casts to > 'char *', there should be a comment explaining why we do this. Yeah. I think casting the const out would be okay, and better than forcing a xstrdup. (run time cost, and extra complication for not that much gain over cast). An alternative would be to perhaps make the interface of parse_exp_1 similar to strtol -- split input and output pointers, with the explicit guarantee that the output pointer points somewhere within the input string. Is it really that messy? There doesn't seem to be many parse_exp_1 callers. -- Pedro Alves