Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* [RFA] little cleanup in allocate_objfile
@ 2009-10-23 12:43 Tristan Gingold
  2009-10-23 13:13 ` Pedro Alves
  0 siblings, 1 reply; 4+ messages in thread
From: Tristan Gingold @ 2009-10-23 12:43 UTC (permalink / raw)
  To: gdb-patches ml

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  <gingold@adacore.com>

	* 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);


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [RFA] little cleanup in allocate_objfile
  2009-10-23 12:43 [RFA] little cleanup in allocate_objfile Tristan Gingold
@ 2009-10-23 13:13 ` Pedro Alves
  2009-10-23 13:23   ` Tristan Gingold
  0 siblings, 1 reply; 4+ messages in thread
From: Pedro Alves @ 2009-10-23 13:13 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tristan Gingold

On Friday 23 October 2009 13:43:27, Tristan Gingold wrote:

> 2009-10-23  Tristan Gingold  <gingold@adacore.com>
> 
> 	* objfiles.c (allocate_objfile): Remove useless test.  Move
> 	declaration of last_one to the block that uses it.

Ok.

-- 
Pedro Alves


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [RFA] little cleanup in allocate_objfile
  2009-10-23 13:13 ` Pedro Alves
@ 2009-10-23 13:23   ` Tristan Gingold
  2009-10-23 14:37     ` Paul Pluzhnikov
  0 siblings, 1 reply; 4+ messages in thread
From: Tristan Gingold @ 2009-10-23 13:23 UTC (permalink / raw)
  To: Pedro Alves; +Cc: gdb-patches


On Oct 23, 2009, at 3:13 PM, Pedro Alves wrote:

> On Friday 23 October 2009 13:43:27, Tristan Gingold wrote:
>
>> 2009-10-23  Tristan Gingold  <gingold@adacore.com>
>>
>> 	* objfiles.c (allocate_objfile): Remove useless test.  Move
>> 	declaration of last_one to the block that uses it.
>
> Ok.

Thanks, committed.

Tristan.


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [RFA] little cleanup in allocate_objfile
  2009-10-23 13:23   ` Tristan Gingold
@ 2009-10-23 14:37     ` Paul Pluzhnikov
  0 siblings, 0 replies; 4+ messages in thread
From: Paul Pluzhnikov @ 2009-10-23 14:37 UTC (permalink / raw)
  To: Tristan Gingold; +Cc: Pedro Alves, gdb-patches

On Fri, Oct 23, 2009 at 6:23 AM, Tristan Gingold <gingold@adacore.com> wrote:

> Thanks, committed.


I've checked in the patch below under the obvious rule.

Thanks,
-- 
Paul Pluzhnikov


2009-10-23  Paul Pluzhnikov  <ppluzhnikov@google.com>

        * objfiles.c (allocate_objfile): Use xzalloc.


Index: objfiles.c
===================================================================
RCS file: /cvs/src/src/gdb/objfiles.c,v
retrieving revision 1.101
diff -u -p -u -r1.101 objfiles.c
--- objfiles.c	23 Oct 2009 13:22:46 -0000	1.101
+++ objfiles.c	23 Oct 2009 14:31:27 -0000
@@ -196,8 +196,7 @@ allocate_objfile (bfd *abfd, int flags)
 {
   struct objfile *objfile;

-  objfile = (struct objfile *) xmalloc (sizeof (struct objfile));
-  memset (objfile, 0, sizeof (struct objfile));
+  objfile = (struct objfile *) xzalloc (sizeof (struct objfile));
   objfile->psymbol_cache = bcache_xmalloc ();
   objfile->macro_cache = bcache_xmalloc ();
   /* We could use obstack_specify_allocation here instead, but


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2009-10-23 14:37 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-10-23 12:43 [RFA] little cleanup in allocate_objfile Tristan Gingold
2009-10-23 13:13 ` Pedro Alves
2009-10-23 13:23   ` Tristan Gingold
2009-10-23 14:37     ` Paul Pluzhnikov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox