This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [bitmap memory]: Allocation part 2


Jeffrey A Law wrote:
That patch is, err, long.  Is there any way you can break it into
distinct functional hunks to make review easier?

This 3rd part removes the heap allocation scheme by forwarding to the obstack allocation scheme. I'll post the obvious sed-generated patch if/when all these three parts are approved.

booted & tested on i686-pc-linux-gnu, ok?

nathan

--
Nathan Sidwell    ::   http://www.codesourcery.com   ::     CodeSourcery LLC
nathan@codesourcery.com    ::     http://www.planetfall.pwp.blueyonder.co.uk

2004-11-24  Nathan Sidwell  <nathan@codesourcery.com>

	* bitmap.c (bitmap_malloc_alloc, bitmap_malloc_free): Remove.
	* bitmap.h (bitmap_malloc_alloc, bitmap_malloc_free): Remove.
	(BITMAP_XMALLOC): Forward to BITMAP_OBSTACK_ALLOC.
	(BITMAP_XFREE): Forward to BITMAP_OBSTACK_FREE.

Index: bitmap.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/bitmap.c,v
retrieving revision 1.61
diff -c -3 -p -r1.61 bitmap.c
*** bitmap.c	22 Nov 2004 12:23:43 -0000	1.61
--- bitmap.c	24 Nov 2004 08:58:07 -0000
*************** bitmap_gc_alloc (void)
*** 232,251 ****
    return map;
  }
  
- /* Create a new malloced bitmap.  Elements will be allocated from the
-    default bitmap obstack.  */
- 
- bitmap
- bitmap_malloc_alloc (void)
- {
-   bitmap map;
- 
-   map = xmalloc (sizeof (bitmap_head));
-   bitmap_initialize (map, &bitmap_default_obstack);
- 
-   return map;
- }
- 
  /* Release an obstack allocated bitmap.  */
  
  void
--- 232,237 ----
*************** bitmap_obstack_free (bitmap map)
*** 256,270 ****
    map->obstack->heads = map;
  }
  
- /* Release a malloc allocated bitmap.  */
- 
- void
- bitmap_malloc_free (bitmap map)
- {
-   bitmap_clear (map);
-   free (map);
- }
- 
  
  /* Return nonzero if all bits in an element are zero.  */
  
--- 242,247 ----
Index: bitmap.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/bitmap.h,v
retrieving revision 1.50
diff -c -3 -p -r1.50 bitmap.h
*** bitmap.h	22 Nov 2004 12:23:43 -0000	1.50
--- bitmap.h	24 Nov 2004 08:58:08 -0000
*************** bitmap_initialize (bitmap head, bitmap_o
*** 145,154 ****
  
  /* Allocate and free bitmaps from obstack, malloc and gc'd memory.  */
  extern bitmap bitmap_obstack_alloc (bitmap_obstack *obstack);
- extern bitmap bitmap_malloc_alloc (void);
  extern bitmap bitmap_gc_alloc (void);
  extern void bitmap_obstack_free (bitmap);
- extern void bitmap_malloc_free (bitmap);
  
  /* A few compatibility/functions macros for compatibility with sbitmaps */
  #define dump_bitmap(file, bitmap) bitmap_print (file, bitmap, "", "\n")
--- 145,152 ----
*************** extern unsigned bitmap_first_set_bit (bi
*** 162,168 ****
  #define BITMAP_GGC_ALLOC() bitmap_gc_alloc ()
  
  /* Allocate a bitmap with xmalloc.  */
! #define BITMAP_XMALLOC() bitmap_malloc_alloc ()
  
  /* Do any cleanup needed on a bitmap when it is no longer used.  */
  #define BITMAP_OBSTACK_FREE(BITMAP)			\
--- 160,166 ----
  #define BITMAP_GGC_ALLOC() bitmap_gc_alloc ()
  
  /* Allocate a bitmap with xmalloc.  */
! #define BITMAP_XMALLOC() BITMAP_OBSTACK_ALLOC (NULL)
  
  /* Do any cleanup needed on a bitmap when it is no longer used.  */
  #define BITMAP_OBSTACK_FREE(BITMAP)			\
*************** do {						\
*** 175,188 ****
  } while (0)
  
  /* Do any cleanup needed on an xmalloced bitmap when it is no longer used.  */
! #define BITMAP_XFREE(BITMAP)			\
! do {						\
!   if (BITMAP)					\
!     {						\
!       bitmap_malloc_free (BITMAP);		\
!       (BITMAP) = 0;				\
!     }						\
! } while (0)
  
  /* Iterator for bitmaps.  */
  
--- 173,179 ----
  } while (0)
  
  /* Do any cleanup needed on an xmalloced bitmap when it is no longer used.  */
! #define BITMAP_XFREE(BITMAP) BITMAP_OBSTACK_FREE (BITMAP)
  
  /* Iterator for bitmaps.  */
  

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]