Commit 2cb67d89 authored by Christoph Mallon's avatar Christoph Mallon
Browse files

array: Add and use NEW_ARR_FZ().

parent 57c32f8c
......@@ -53,6 +53,12 @@
#define NEW_ARR_F(type, nelts) \
((type *)ir_new_arr_f((nelts), sizeof(type) * (nelts)))
/**
* Create a flexible array and null its contents.
*/
#define NEW_ARR_FZ(type, nelts) \
((type*)memset(NEW_ARR_F(type, (nelts)), 0, sizeof(type) * (nelts)))
/**
* Creates a new flexible array with the same number of elements as a
* given one.
......
......@@ -363,7 +363,6 @@ static void collect_liveness_nodes(ir_node *irn, void *data)
void be_liveness_compute_sets(be_lv_t *lv)
{
ir_node **nodes;
int i;
int n;
......@@ -375,8 +374,7 @@ void be_liveness_compute_sets(be_lv_t *lv)
obstack_init(&lv->obst);
n = get_irg_last_idx(lv->irg);
nodes = NEW_ARR_F(ir_node *, n);
memset(nodes, 0, sizeof(nodes[0]) * n);
ir_node **const nodes = NEW_ARR_FZ(ir_node*, n);
/* inserting the variables sorted by their ID is probably
* more efficient since the binary sorted set insertion
......
......@@ -515,12 +515,11 @@ static trace_env_t *trace_init(ir_graph *irg)
int nn = get_irg_last_idx(irg);
env->curr_time = 0;
env->sched_info = NEW_ARR_F(trace_irn_t, nn);
env->sched_info = NEW_ARR_FZ(trace_irn_t, nn);
env->liveness = be_get_irg_liveness(irg);
FIRM_DBG_REGISTER(env->dbg, "firm.be.sched.trace");
be_assure_live_chk(irg);
memset(env->sched_info, 0, nn * sizeof(*(env->sched_info)));
return env;
}
......
......@@ -85,8 +85,7 @@ static ir_graph *alloc_graph(void)
res->kind = k_ir_graph;
/* initialize the idx->node map. */
res->idx_irn_map = NEW_ARR_F(ir_node *, INITIAL_IDX_IRN_MAP_SIZE);
memset(res->idx_irn_map, 0, INITIAL_IDX_IRN_MAP_SIZE * sizeof(res->idx_irn_map[0]));
res->idx_irn_map = NEW_ARR_FZ(ir_node*, INITIAL_IDX_IRN_MAP_SIZE);
obstack_init(&res->obst);
......
......@@ -43,8 +43,7 @@ typedef struct ir_nodemap ir_nodemap;
static inline void ir_nodemap_init(ir_nodemap *nodemap, const ir_graph *irg)
{
unsigned max_idx = get_irg_last_idx(irg) + 32;
nodemap->data = NEW_ARR_F(void*, max_idx);
memset(nodemap->data, 0, max_idx * sizeof(nodemap->data[0]));
nodemap->data = NEW_ARR_FZ(void*, max_idx);
}
/**
......
......@@ -2967,8 +2967,7 @@ static void lower_irg(ir_graph *irg)
n_idx = get_irg_last_idx(irg);
n_idx = n_idx + (n_idx >> 2); /* add 25% */
env->n_entries = n_idx;
env->entries = NEW_ARR_F(lower64_entry_t*, n_idx);
memset(env->entries, 0, sizeof(env->entries[0]) * n_idx);
env->entries = NEW_ARR_FZ(lower64_entry_t*, n_idx);
env->irg = irg;
env->flags = 0;
......
......@@ -1201,8 +1201,7 @@ void shape_blocks(ir_graph *irg)
env.opcode2id_map = new_set(cmp_opcode, iro_Last * 4);
n = get_irg_last_idx(irg);
env.live_outs = NEW_ARR_F(ir_node *, n);
memset(env.live_outs, 0, sizeof(*env.live_outs) * n);
env.live_outs = NEW_ARR_FZ(ir_node*, n);
env.all_blocks = NULL;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment