From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 19565 invoked by alias); 22 Jun 2010 09:45:33 -0000 Received: (qmail 19556 invoked by uid 22791); 22 Jun 2010 09:45:33 -0000 X-SWARE-Spam-Status: No, hits=-2.0 required=5.0 tests=AWL,BAYES_00,TW_CP,T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from mail.codesourcery.com (HELO mail.codesourcery.com) (38.113.113.100) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Tue, 22 Jun 2010 09:45:29 +0000 Received: (qmail 14223 invoked from network); 22 Jun 2010 09:45:26 -0000 Received: from unknown (HELO orlando.localnet) (pedro@127.0.0.2) by mail.codesourcery.com with ESMTPA; 22 Jun 2010 09:45:26 -0000 From: Pedro Alves To: gdb-patches@sourceware.org Subject: Re: [RFA] c++/11734 Date: Tue, 22 Jun 2010 09:45:00 -0000 User-Agent: KMail/1.13.2 (Linux/2.6.32-22-generic; KDE/4.4.2; x86_64; ; ) Cc: Keith Seitz References: <4C20103B.1080906@redhat.com> In-Reply-To: <4C20103B.1080906@redhat.com> MIME-Version: 1.0 Content-Type: Text/Plain; charset="iso-8859-15" Content-Transfer-Encoding: 7bit Message-Id: <201006221045.23196.pedro@codesourcery.com> X-IsSubscribed: yes 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: 2010-06/txt/msg00473.txt.bz2 No comments on the idea of the patch itself, just a quick comment on something that made me stop for a second while skimming your patch: On Tuesday 22 June 2010 02:22:03, Keith Seitz wrote: > + new = alloca (strlen (name)); Note that alloca in a loop in general isn't a good idea. The stack memory added in each iteration is only released on function exit, not on each iteration, so you're prone to stack overflow given enough loops. It looks like `name' is invariant in this loop, so you could for example, move the `new' declaration out of the loop, initialized as NULL, and allocate it only once on first need. > + memcpy (new, name, paren - name); > + new[name - paren] = '\0'; -- Pedro Alves