made allocations C-like
authorMichael Beck <beck@ipd.info.uni-karlsruhe.de>
Wed, 22 Dec 2004 14:43:14 +0000 (14:43 +0000)
committerMichael Beck <beck@ipd.info.uni-karlsruhe.de>
Wed, 22 Dec 2004 14:43:14 +0000 (14:43 +0000)
[r4721]

13 files changed:
ir/ana/cgana.c
ir/ana/irdom.c
ir/ana/irouts.c
ir/ana2/ecg.c
ir/ana2/irmemwalk.c
ir/ana2/lset.c
ir/ana2/pto.c
ir/ana2/pto_name.c
ir/ana2/pto_util.c
ir/ana2/typalise.c
ir/tr/entity.c
ir/tr/tpop.c
ir/tr/type.c

index 2a61848..ae09efc 100644 (file)
@@ -840,7 +840,7 @@ void cgana(int *length, entity ***free_methods) {
 
   /* Convert the flexible array to an array that can be handled
      by standard C. */
-  p = (entity **)xmalloc(sizeof(*p) * ARR_LEN(free_meths));
+  p = xmalloc(sizeof(*p) * ARR_LEN(free_meths));
   memcpy(p, free_meths, ARR_LEN(free_meths) * sizeof(*p));
 
   *length       = ARR_LEN(free_meths);
index 8524285..7033f82 100644 (file)
@@ -186,8 +186,8 @@ void compute_doms(ir_graph *irg) {
   irg_block_walk(get_irg_end(current_ir_graph), count_and_init_blocks, NULL, &n_blocks);
 
   /* Memory for temporary information. */
-  tdi_list = xmalloc(n_blocks * sizeof(tmp_dom_info));
-  memset(tdi_list, 0, n_blocks * sizeof(tmp_dom_info));
+  tdi_list = xmalloc(n_blocks * sizeof(*tdi_list));
+  memset(tdi_list, 0, n_blocks * sizeof(*tdi_list));
 
   /* We need the out datastructure. */
   if (current_ir_graph->outs_state != outs_consistent)
index 6db0333..75c24a1 100644 (file)
@@ -321,7 +321,7 @@ void compute_outs(ir_graph *irg) {
   n_out_edges = count_outs(get_irg_end(irg));
 
   /* allocate memory for all out edges. */
-  irg->outs = (ir_node **) xmalloc (n_out_edges * sizeof(ir_node *));
+  irg->outs = xmalloc (n_out_edges * sizeof(*irg->outs));
 #ifdef DEBUG_libfirm
   irg->n_outs = n_out_edges;
 #endif /* defined DEBUG_libfirm */
@@ -470,7 +470,7 @@ void compute_ip_outs(void) {
   }
 
   global_count = n_out_edges = count_ip_outs();
-  out_edges = (ir_node **) xmalloc (n_out_edges * sizeof(ir_node *));
+  out_edges = xmalloc(n_out_edges * sizeof(*out_edges));
   set_irp_ip_outedges(out_edges);
   set_ip_outs();
 }
index b760843..1f9a092 100644 (file)
@@ -82,7 +82,7 @@ void set_main_ctx (ctx_info_t*);
    ==================== */
 static void append_alloc (graph_info_t *ginfo, ir_node *alloc, type *tp)
 {
-  alloc_info_t *ainfo = (alloc_info_t*) xmalloc (sizeof (alloc_info_t));
+  alloc_info_t *ainfo = xmalloc(sizeof(*ainfo));
 
   ainfo->graph = ginfo->graph;
   ainfo->alloc = alloc;
@@ -101,7 +101,7 @@ static void append_alloc (graph_info_t *ginfo, ir_node *alloc, type *tp)
 */
 static callEd_info_t *append_callEd_info (callEd_info_t *ced, ir_graph *callEd)
 {
-  callEd_info_t *nced = (callEd_info_t*) xmalloc (sizeof (sizeof (callEd_info_t)));
+  callEd_info_t *nced = xmalloc(sizeof(*nced));
 
   nced->callEd = callEd;
   nced->prev = ced;
@@ -114,7 +114,7 @@ static callEd_info_t *append_callEd_info (callEd_info_t *ced, ir_graph *callEd)
 */
 static void append_calls (graph_info_t *info, ir_node *call, lset_t *callEds)
 {
-  call_info_t *cinfo = xmalloc (sizeof(*cinfo));
+  call_info_t *cinfo = xmalloc(sizeof(*cinfo));
   ir_graph *callEd;
 
   /* setup */
@@ -347,7 +347,7 @@ static void ecg_calls_act (ir_node *node, void *env)
 */
 static void ecg_fill_graph_calls (ir_graph *graph)
 {
-  graph_info_t *ginfo = (graph_info_t*) xmalloc (sizeof (graph_info_t));
+  graph_info_t *ginfo = xmalloc(sizeof(*ginfo));
 
   /* memset (ginfo, 0x00, sizeof (graph_info_t)); */
   assert (ginfo != graph_infos_list);
@@ -389,7 +389,7 @@ static void ecg_fill_calls (void)
 */
 static ctx_info_t *new_ctx (ir_graph *graph, ir_node *call, ctx_info_t *enc)
 {
-  ctx_info_t *res = xmalloc (sizeof (ctx_info_t));
+  ctx_info_t *res = xmalloc(sizeof(*res));
 
   res->graph = graph;
   res->call = call;
@@ -442,7 +442,7 @@ static void ecg_fill_ctxs_alloc (void)
   graph_info_t *ginfo = graph_infos_list;
 
   while (NULL != ginfo) {
-    ginfo->ctxs = (ctx_info_t **) xmalloc (ginfo->n_ctxs * sizeof (ctx_info_t*));
+    ginfo->ctxs = xmalloc(ginfo->n_ctxs * sizeof(*ginfo->ctxs));
 
     /*
       fprintf (stdout, "graph of \"%s\": n_ctxs = %i\n",
@@ -514,7 +514,7 @@ static void ecg_fill_ctxs (void)
   /* Grrr, have to add this ctx manually to main.ginfo ... */
   ginfo = ecg_get_info (main_irg);
   ginfo->n_ctxs = 1;
-  ginfo->ctxs = xmalloc (1 * sizeof (ctx_info_t*));
+  ginfo->ctxs = xmalloc(1 * sizeof(*ginfo->ctxs));
   ginfo->ctxs [0] = main_ctx;
 
   ecg_fill_ctxs_write (main_irg, main_ctx);
@@ -1175,6 +1175,9 @@ void ecg_ecg (void)
 
 /*
   $Log$
+  Revision 1.14  2004/12/22 14:43:14  beck
+  made allocations C-like
+
   Revision 1.13  2004/12/21 14:21:16  beck
   removed C99 constructs
 
index d767dde..a3648f5 100644 (file)
@@ -219,7 +219,7 @@ void irg_walk_mem (ir_graph *graph,
                    void *env)
 {
   ir_node *end_block = get_irg_end_block (graph);
-  walk_mem_env_t *walk_env = (walk_mem_env_t*) xmalloc (sizeof (walk_mem_env_t));
+  walk_mem_env_t *walk_env = xmalloc(sizeof(*walk_env));
 
   assert (! get_irg_is_mem_visited (graph));
 
@@ -261,6 +261,9 @@ void irg_walk_mem (ir_graph *graph,
 
 /*
   $Log$
+  Revision 1.8  2004/12/22 14:43:14  beck
+  made allocations C-like
+
   Revision 1.7  2004/12/21 14:25:35  beck
   removed C99 constructs
   make visit counter of same type as irn visit counter
index d0c9a83..0e762d7 100644 (file)
@@ -38,7 +38,7 @@
 /* create a new lset */
 lset_t *lset_create (void)
 {
-  lset_t *lset = xmalloc (sizeof (lset_t));
+  lset_t *lset = xmalloc(sizeof(*lset));
 
   return (lset);
 }
@@ -71,7 +71,7 @@ int lset_empty (lset_t *lset)
 void lset_insert (lset_t *lset, void *data)
 {
   if (! lset_contains (lset, data)) {
-    lset_entry_t *entry = xmalloc (sizeof (lset_entry_t));
+    lset_entry_t *entry = xmalloc(sizeof(*entry));
     entry->data = data;
     entry->next = lset->first;
     lset->first = entry;
@@ -194,6 +194,9 @@ void lset_destroy (lset_t *lset)
 \f
 /*
   $Log$
+  Revision 1.3  2004/12/22 14:43:14  beck
+  made allocations C-like
+
   Revision 1.2  2004/12/02 16:17:51  beck
   fixed config.h include
 
index 707a030..a4b6555 100644 (file)
@@ -80,7 +80,7 @@ void pto_init (int lvl)
   ecg_iterate_graphs (pto_init_graph_wrapper, NULL);
 
   /* debugging only */
-  spaces = (char*) xmalloc (512 * sizeof (char));
+  spaces = xmalloc (512 * sizeof(spaces[0]));
   memset (spaces, ' ', 512);
   spaces += 511;
   *spaces = '\0';
@@ -137,6 +137,9 @@ void pto_cleanup (void)
 \f
 /*
   $Log$
+  Revision 1.16  2004/12/22 14:43:14  beck
+  made allocations C-like
+
   Revision 1.15  2004/12/21 14:26:53  beck
   removed C99 constructs
 
index 1c587c3..e77f64e 100644 (file)
@@ -622,8 +622,8 @@ void pto_name_init (void)
   assert (NULL == name_obst);
   assert (NULL == qset_obst);
 
-  name_obst = xmalloc (sizeof (struct obstack));
-  qset_obst = xmalloc (sizeof (struct obstack));
+  name_obst = xmalloc (sizeof(*name_obst));
+  qset_obst = xmalloc (sizeof(*qset_obst));
 
   obstack_init (name_obst);
   obstack_init (qset_obst);
@@ -649,6 +649,9 @@ void pto_name_cleanup (void)
 \f
 /*
   $Log$
+  Revision 1.10  2004/12/22 14:43:14  beck
+  made allocations C-like
+
   Revision 1.9  2004/12/21 15:34:09  beck
   removed C99 constructs
   make const float
index b983a2f..7b0fc91 100644 (file)
@@ -76,10 +76,9 @@ ir_node **find_irg_args (ir_graph *graph)
 {
   type *tp = get_entity_type (get_irg_entity (graph));
   const int n_args = get_method_n_params (tp);
-  ir_node **args = (ir_node**) xmalloc (sizeof (ir_node*) * (n_args+1));
+  ir_node **args = xmalloc (sizeof(*args) * (n_args+1));
   ir_node *arg = get_irg_args (graph);
-  find_irg_args_env_t *arg_env =
-    (find_irg_args_env_t*) xmalloc (sizeof (find_irg_args_env_t));
+  find_irg_args_env_t *arg_env = xmalloc(sizeof(*arg_env));
 
   arg_env->args = args;
   arg_env->arg  = arg;
@@ -151,6 +150,9 @@ int is_dummy_load_ptr (ir_node *ptr)
 \f
 /*
   $Log$
+  Revision 1.13  2004/12/22 14:43:14  beck
+  made allocations C-like
+
   Revision 1.12  2004/12/21 15:53:12  beck
   removed GNUC constructs
 
index 71053ab..02f7fe7 100644 (file)
@@ -52,7 +52,7 @@ static typalise_t *typalise_proj (ir_node*);
 */
 static typalise_t *ta_exact (type *tp)
 {
-  typalise_t *ta = (typalise_t*) xmalloc (sizeof (typalise_t));
+  typalise_t *ta = xmalloc (sizeof(*ta));
   ta->kind = type_exact;
   ta->res.type = tp;
   ta->id = ta_id ++;
@@ -64,7 +64,7 @@ static typalise_t *ta_exact (type *tp)
 
 static typalise_t *ta_types (lset_t *set)
 {
-  typalise_t *ta = (typalise_t*) xmalloc (sizeof (typalise_t));
+  typalise_t *ta = xmalloc (sizeof(*ta));
   ta->kind = type_types;
   ta->res.types = set;
   ta->id = ta_id ++;
@@ -74,7 +74,7 @@ static typalise_t *ta_types (lset_t *set)
 
 static typalise_t *ta_type (type *tp)
 {
-  typalise_t *ta = (typalise_t*) xmalloc (sizeof (typalise_t));
+  typalise_t *ta = xmalloc (sizeof(*ta));
   ta->kind = type_type;
   ta->res.type = tp;
   ta->id = ta_id ++;
@@ -706,6 +706,9 @@ typalise_t *typalise (ir_node *node)
 \f
 /*
   $Log$
+  Revision 1.5  2004/12/22 14:43:14  beck
+  made allocations C-like
+
   Revision 1.4  2004/12/21 15:50:18  beck
   removed C99 constructs
 
index aee090d..6fdbf85 100644 (file)
@@ -98,8 +98,8 @@ new_rd_entity (dbg_info *db, type *owner, ident *name, type *type)
 
   assert(!id_contains_char(name, ' ') && "entity name should not contain spaces");
 
-  res = (entity *) xmalloc (sizeof (entity));
-  memset(res, 0, sizeof(res));
+  res = xmalloc(sizeof(*res));
+  memset(res, 0, sizeof(*res));
   res->kind = k_entity;
   res->owner = owner;
   res->name = name;
@@ -196,49 +196,49 @@ static void free_entity_attrs(entity *ent) {
 
 entity *
 copy_entity_own (entity *old, type *new_owner) {
-  entity *new;
+  entity *newe;
   assert(old && old->kind == k_entity);
   assert_legal_owner_of_ent(new_owner);
 
   if (old->owner == new_owner) return old;
-  new = (entity *) xmalloc (sizeof (entity));
-  memcpy (new, old, sizeof (entity));
-  new->owner = new_owner;
+  newe = xmalloc(sizeof(*newe));
+  memcpy (newe, old, sizeof(*newe));
+  newe->owner = new_owner;
   if (is_class_type(new_owner)) {
-    new->overwrites    = NEW_ARR_F(entity *, 0);
-    new->overwrittenby = NEW_ARR_F(entity *, 0);
+    newe->overwrites    = NEW_ARR_F(entity *, 0);
+    newe->overwrittenby = NEW_ARR_F(entity *, 0);
   }
 #ifdef DEBUG_libfirm
-  new->nr = get_irp_new_node_nr();
+  newe->nr = get_irp_new_node_nr();
 #endif
 
-  insert_entity_in_owner (new);
+  insert_entity_in_owner (newe);
 
-  return new;
+  return newe;
 }
 
 entity *
 copy_entity_name (entity *old, ident *new_name) {
-  entity *new;
+  entity *newe;
   assert(old && old->kind == k_entity);
 
   if (old->name == new_name) return old;
-  new = (entity *) xmalloc (sizeof (entity));
-  memcpy (new, old, sizeof (entity));
-  new->name = new_name;
-  new->ld_name = NULL;
-  if (is_class_type(new->owner)) {
-    new->overwrites    = DUP_ARR_F(entity *, old->overwrites);
-    new->overwrittenby = DUP_ARR_F(entity *, old->overwrittenby);
+  newe = xmalloc(sizeof(*newe));
+  memcpy(newe, old, sizeof(*newe));
+  newe->name = new_name;
+  newe->ld_name = NULL;
+  if (is_class_type(newe->owner)) {
+    newe->overwrites    = DUP_ARR_F(entity *, old->overwrites);
+    newe->overwrittenby = DUP_ARR_F(entity *, old->overwrittenby);
   }
 #ifdef DEBUG_libfirm
-  new->nr = get_irp_new_node_nr();
-  new->c_name = (char *)get_id_str (new->name);
+  newe->nr = get_irp_new_node_nr();
+  newe->c_name = (char *)get_id_str (newe->name);
 #endif
 
-  insert_entity_in_owner (new);
+  insert_entity_in_owner (newe);
 
-  return new;
+  return newe;
 }
 
 
index a85f704..e013c17 100644 (file)
@@ -34,7 +34,7 @@ new_tpop (tp_opcode code, ident *name, size_t attr_size)
 {
   tp_op *res;
 
-  res = (tp_op *) xmalloc (sizeof (tp_op));
+  res = xmalloc(sizeof(*res));
   res->code = code;
   res->name = name;
   res->attr_size = attr_size;
index 2b08489..ad3a14b 100644 (file)
@@ -112,8 +112,8 @@ new_type(tp_op *type_op, ir_mode *mode, ident* name) {
   assert(!id_contains_char(name, ' ') && "type name should not contain spaces");
 
   node_size = offsetof(type, attr) +  type_op->attr_size;
-  res = (type *) xmalloc (node_size);
-  memset((void *)res, 0, node_size);
+  res = xmalloc (node_size);
+  memset(res, 0, node_size);
   add_irp_type(res);   /* Remember the new type global. */
 
   res->kind    = k_type;
@@ -1037,10 +1037,10 @@ type *new_type_method (ident *name, int n_param, int n_res) {
   res->state                        = layout_fixed;
   res->size                         = get_mode_size_bits(mode_P_mach);
   res->attr.ma.n_params             = n_param;
-  res->attr.ma.param_type           = (type **) xmalloc (sizeof (type *) * n_param);
+  res->attr.ma.param_type           = xmalloc(sizeof(*res->attr.ma.param_type) * n_param);
   res->attr.ma.value_params         = NULL;
   res->attr.ma.n_res                = n_res;
-  res->attr.ma.res_type             = (type **) xmalloc (sizeof (type *) * n_res);
+  res->attr.ma.res_type             = xmalloc(sizeof(*res->attr.ma.res_type) * n_res);
   res->attr.ma.value_ress           = NULL;
   res->attr.ma.variadicity          = variadicity_non_variadic;
   res->attr.ma.first_variadic_param = -1;
@@ -1241,8 +1241,8 @@ int (is_method_type)(const type *method) {
 type  *new_type_union (ident *name) {
   type *res;
   res = new_type(type_union, NULL, name);
-  /*res->attr.ua.unioned_type = (type **)  xmalloc (sizeof (type *)  * n_types);
-    res->attr.ua.delim_names  = (ident **) xmalloc (sizeof (ident *) * n_types); */
+  /*res->attr.ua.unioned_type = xmalloc(sizeof(*res->attr.ua.unioned_type)  * n_types);
+    res->attr.ua.delim_names  = xmalloc(sizeof(*res->attr.ua.delim_names) * n_types); */
   res->attr.ua.members = NEW_ARR_F (entity *, 0);
   return res;
 }
@@ -1343,9 +1343,9 @@ type *new_type_array         (ident *name, int n_dimensions,
 
   res = new_type(type_array, NULL, name);
   res->attr.aa.n_dimensions = n_dimensions;
-  res->attr.aa.lower_bound  = (ir_node **) xmalloc (sizeof (ir_node *) * n_dimensions);
-  res->attr.aa.upper_bound  = (ir_node **) xmalloc (sizeof (ir_node *) * n_dimensions);
-  res->attr.aa.order  = (int *) xmalloc (sizeof (int) * n_dimensions);
+  res->attr.aa.lower_bound  = xmalloc(sizeof(*res->attr.aa.lower_bound) * n_dimensions);
+  res->attr.aa.upper_bound  = xmalloc(sizeof(*res->attr.aa.upper_bound) * n_dimensions);
+  res->attr.aa.order        = xmalloc(sizeof(*res->attr.aa.order) * n_dimensions);
 
   current_ir_graph = get_const_code_irg();
   for (i = 0; i < n_dimensions; i++) {
@@ -1505,8 +1505,8 @@ type   *new_type_enumeration    (ident *name, int n_enums) {
   type *res;
   res = new_type(type_enumeration, NULL, name);
   res->attr.ea.n_enums     = n_enums;
-  res->attr.ea.enumer      = (tarval **)xmalloc(sizeof(res->attr.ea.enumer[0]) * n_enums);
-  res->attr.ea.enum_nameid = (ident  **)xmalloc(sizeof(res->attr.ea.enum_nameid[0]) * n_enums);
+  res->attr.ea.enumer      = xmalloc(sizeof(res->attr.ea.enumer[0]) * n_enums);
+  res->attr.ea.enum_nameid = xmalloc(sizeof(res->attr.ea.enum_nameid[0]) * n_enums);
   memset(res->attr.ea.enumer,      0, sizeof(res->attr.ea.enumer[0])      * n_enums);
   memset(res->attr.ea.enum_nameid, 0, sizeof(res->attr.ea.enum_nameid[0]) * n_enums);
   return res;