From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 30574 invoked by alias); 23 Oct 2009 12:43:36 -0000 Received: (qmail 30564 invoked by uid 22791); 23 Oct 2009 12:43:35 -0000 X-SWARE-Spam-Status: No, hits=-2.3 required=5.0 tests=AWL,BAYES_00 X-Spam-Check-By: sourceware.org Received: from mel.act-europe.fr (HELO mel.act-europe.fr) (212.99.106.210) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Fri, 23 Oct 2009 12:43:31 +0000 Received: from localhost (localhost [127.0.0.1]) by filtered-smtp.eu.adacore.com (Postfix) with ESMTP id B6EE629000E for ; Fri, 23 Oct 2009 14:43:28 +0200 (CEST) Received: from mel.act-europe.fr ([127.0.0.1]) by localhost (smtp.eu.adacore.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id Y9MmtO9249JE for ; Fri, 23 Oct 2009 14:43:27 +0200 (CEST) Received: from ulanbator.act-europe.fr (ulanbator.act-europe.fr [10.10.1.67]) (using TLSv1 with cipher AES128-SHA (128/128 bits)) (No client certificate requested) by mel.act-europe.fr (Postfix) with ESMTP id E739F29000A for ; Fri, 23 Oct 2009 14:43:27 +0200 (CEST) From: Tristan Gingold Content-Type: text/plain; charset=us-ascii; format=flowed; delsp=yes Content-Transfer-Encoding: 7bit Subject: [RFA] little cleanup in allocate_objfile Date: Fri, 23 Oct 2009 12:43:00 -0000 Message-Id: To: gdb-patches ml Mime-Version: 1.0 (Apple Message framework v1076) 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: 2009-10/txt/msg00567.txt.bz2 Hi, did I miss the obvious ? The initial test in allocate_objfile looks unnecessary and the comment dates back to mmalloc. Tristan. 2009-10-23 Tristan Gingold * objfiles.c (allocate_objfile): Remove useless test. Move declaration of last_one to the block that uses it. =================================================================== RCS file: /cvs/src/src/gdb/objfiles.c,v retrieving revision 1.100 diff -u -r1.100 objfiles.c --- objfiles.c 22 Oct 2009 20:20:27 -0000 1.100 +++ objfiles.c 23 Oct 2009 12:41:31 -0000 @@ -194,24 +194,16 @@ struct objfile * allocate_objfile (bfd *abfd, int flags) { - struct objfile *objfile = NULL; - struct objfile *last_one = NULL; + struct objfile *objfile; - /* If we don't support mapped symbol files, didn't ask for the file to be - mapped, or failed to open the mapped file for some reason, then revert - back to an unmapped objfile. */ - - if (objfile == NULL) - { - objfile = (struct objfile *) xmalloc (sizeof (struct objfile)); - memset (objfile, 0, sizeof (struct objfile)); - objfile->psymbol_cache = bcache_xmalloc (); - objfile->macro_cache = bcache_xmalloc (); - /* We could use obstack_specify_allocation here instead, but - gdb_obstack.h specifies the alloc/dealloc functions. */ - obstack_init (&objfile->objfile_obstack); - terminate_minimal_symbol_table (objfile); - } + objfile = (struct objfile *) xmalloc (sizeof (struct objfile)); + memset (objfile, 0, sizeof (struct objfile)); + objfile->psymbol_cache = bcache_xmalloc (); + objfile->macro_cache = bcache_xmalloc (); + /* We could use obstack_specify_allocation here instead, but + gdb_obstack.h specifies the alloc/dealloc functions. */ + obstack_init (&objfile->objfile_obstack); + terminate_minimal_symbol_table (objfile); objfile_alloc_data (objfile); @@ -266,6 +258,8 @@ object_files = objfile; else { + struct objfile *last_one; + for (last_one = object_files; last_one->next; last_one = last_one->next);