From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 14222 invoked by alias); 3 Mar 2010 21:49:09 -0000 Received: (qmail 14214 invoked by uid 22791); 3 Mar 2010 21:49:08 -0000 X-SWARE-Spam-Status: No, hits=-4.3 required=5.0 tests=AWL,BAYES_00,KAM_STOCKTIP,RCVD_IN_DNSWL_HI,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; Wed, 03 Mar 2010 21:49:05 +0000 Received: from int-mx02.intmail.prod.int.phx2.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id o23Ln3Ef000517 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Wed, 3 Mar 2010 16:49:03 -0500 Received: from ns3.rdu.redhat.com (ns3.rdu.redhat.com [10.11.255.199]) by int-mx02.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id o23Ln2In000818; Wed, 3 Mar 2010 16:49:02 -0500 Received: from opsy.redhat.com (ovpn01.gateway.prod.ext.phx2.redhat.com [10.5.9.1]) by ns3.rdu.redhat.com (8.13.8/8.13.8) with ESMTP id o23LmpI5024846; Wed, 3 Mar 2010 16:48:51 -0500 Received: by opsy.redhat.com (Postfix, from userid 500) id 4778F379963; Wed, 3 Mar 2010 14:48:46 -0700 (MST) From: Tom Tromey To: Sami Wagiaalla Cc: GDB Patches Subject: Re: [patch] Fix using_directive memory leak pr 11236 References: <4B8ECACA.9010504@redhat.com> Reply-To: tromey@redhat.com Date: Wed, 03 Mar 2010 21:49:00 -0000 In-Reply-To: <4B8ECACA.9010504@redhat.com> (Sami Wagiaalla's message of "Wed, 03 Mar 2010 15:47:06 -0500") Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii 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-03/txt/msg00132.txt.bz2 >>>>> "Sami" == Sami Wagiaalla writes: Sami> PR C++/11236: Sami> * cp-namespace.c (cp_add_using): Deleted. Sami> (cp_add_using_directive): Use obstack allocations. Sami> Merged the function cp_add_using into this one. Sami> Added 'struct obstack *' argument. Sami> (cp_scan_for_anonymous_namespaces): Updated. Sami> * cp-support.h: Updated. Sami> * dwarf2read.c (read_import_statement): Updated. Sami> (read_namespace): Updated. Sami> (new_symbol): Updated. Sami> * stabsread.c (define_symbol): Updated. Thanks for doing this. This general idea is fine, but I have a few comments. Sami> -cp_scan_for_anonymous_namespaces (const struct symbol *symbol) Sami> +cp_scan_for_anonymous_namespaces (const struct symbol *symbol, Sami> + struct obstack *obstack) I don't think you need a new argument here. Instead, I think you can use SYMBOL_SYMTAB (symbol)->obstack. Sami> if (strcmp (current->import_src, src) == 0 Sami> - && strcmp (current->import_dest, dest) == 0) Sami> + && strcmp (current->import_dest, dest) == 0 Sami> + && alias && strcmp (current->alias, alias) == 0) This logic is incorrect if current->alias == NULL. Sami> + new = obstack_alloc (obstack, sizeof (struct using_direct)); Sami> + memset (new, 0, sizeof (struct using_direct)); Use OBSTACK_ZALLOC here. thanks, Tom