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]

[PATCH] Use XNEW/XCNEW/XNEWVEC in ipa-struct-reorg.c


Hi!

While writing the patch I've just sent, I've noticed ipa-struct-reorg.c
doesn't use libiberty.h allocation macros.  This patch fixes it,
bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk?

2010-02-19  Jakub Jelinek  <jakub@redhat.com>

	* ipa-struct-reorg.c (make_field_acc_node, gen_cluster, peel_field):
	Use XCNEW instead of xcalloc.
	(add_access_to_acc_sites, create_new_var_node, add_alloc_site): Use
	XNEW instead of xmalloc.
	(get_fields): Use XNEWVEC instead of xmalloc.

--- gcc/ipa-struct-reorg.c.jj	2010-02-19 15:37:13.000000000 +0100
+++ gcc/ipa-struct-reorg.c	2010-02-19 16:03:46.000000000 +0100
@@ -447,9 +447,7 @@ decompose_access (tree str_decl, struct 
 static inline struct field_access_site *
 make_field_acc_node (void)
 {
-  int size = sizeof (struct field_access_site);
-
-  return (struct field_access_site *) xcalloc (1, size);
+  return XCNEW (struct field_access_site);
 }
 
 /* This function returns the structure field access, defined by STMT,
@@ -495,7 +493,7 @@ add_access_to_acc_sites (gimple stmt, tr
      {
        void **slot;
 
-       acc = (struct access_site *) xmalloc (sizeof (struct access_site));
+       acc = XNEW (struct access_site);
        acc->stmt = stmt;
        if (!is_gimple_debug (stmt))
 	 acc->vars = VEC_alloc (tree, heap, 10);
@@ -2000,7 +1998,7 @@ create_new_var_node (tree var, d_str str
 {
   new_var node;
 
-  node = (new_var) xmalloc (sizeof (struct new_var_data));
+  node = XNEW (struct new_var_data);
   node->orig_var = var;
   node->new_vars = VEC_alloc (tree, heap, VEC_length (tree, str->new_types));
   return node;
@@ -2341,8 +2339,7 @@ get_fields (tree struct_decl, int num_fi
   tree t = TYPE_FIELDS (struct_decl);
   int idx = 0;
 
-  list =
-    (struct field_entry *) xmalloc (num_fields * sizeof (struct field_entry));
+  list = XNEWVEC (struct field_entry, num_fields);
 
   for (idx = 0 ; t; t = TREE_CHAIN (t), idx++)
     if (TREE_CODE (t) == FIELD_DECL)
@@ -3038,8 +3035,7 @@ add_alloc_site (tree fn_decl, gimple stm
     {
       void **slot;
 
-      fallocs = (fallocs_t)
-	xmalloc (sizeof (struct func_alloc_sites));
+      fallocs = XNEW (struct func_alloc_sites);
       fallocs->func = fn_decl;
       fallocs->allocs = VEC_alloc (alloc_site_t, heap, 1);
       slot = htab_find_slot_with_hash (alloc_sites, fn_decl,
@@ -3194,10 +3190,8 @@ collect_accesses_in_bb (basic_block bb)
 static void
 gen_cluster (sbitmap fields, d_str str)
 {
-  struct field_cluster *crr_cluster = NULL;
+  struct field_cluster *crr_cluster = XCNEW (struct field_cluster);
 
-  crr_cluster =
-    (struct field_cluster *) xcalloc (1, sizeof (struct field_cluster));
   crr_cluster->sibling = str->struct_clustering;
   str->struct_clustering = crr_cluster;
   crr_cluster->fields_in_cluster = fields;
@@ -3208,10 +3202,8 @@ gen_cluster (sbitmap fields, d_str str)
 static void
 peel_field (int i, d_str ds)
 {
-  struct field_cluster *crr_cluster = NULL;
+  struct field_cluster *crr_cluster = XCNEW (struct field_cluster);
 
-  crr_cluster =
-    (struct field_cluster *) xcalloc (1, sizeof (struct field_cluster));
   crr_cluster->sibling = ds->struct_clustering;
   ds->struct_clustering = crr_cluster;
   crr_cluster->fields_in_cluster =

	Jakub


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