From: Michael Beck Date: Wed, 22 Dec 2004 11:06:24 +0000 (+0000) Subject: make allocation C-like X-Git-Url: http://nsz.repo.hu/git/?a=commitdiff_plain;h=0850a3224410b24400a5552feff23cf85bf443c3;p=libfirm make allocation C-like [r4718] --- diff --git a/ir/st/st.c b/ir/st/st.c index e0edbc9c3..e1204c310 100644 --- a/ir/st/st.c +++ b/ir/st/st.c @@ -119,9 +119,9 @@ static dt_t *new_dt (ir_graph *graph) res->n_blocks = n_blocks; res->graph = graph; - res->blocks = (ir_node**) calloc (n_blocks, sizeof (ir_node*)); - res->idoms = (ir_node**) calloc (n_blocks, sizeof (ir_node*)); - res->masks = (bs_t*) calloc (n_blocks, sizeof (bs_t)); + res->blocks = calloc(n_blocks, sizeof(*res->blocks)); + res->idoms = calloc(n_blocks, sizeof(*res->idoms)); + res->masks = calloc(n_blocks, sizeof(*res->masks)); assert (res && "no dt"); @@ -438,7 +438,7 @@ ir_node *get_idom (ir_graph *g, ir_node *a) */ dom_env_t *get_dom_env (ir_graph *graph, ir_node *a) { - dom_env_t *env = (dom_env_t*) calloc (1, sizeof (dom_env_t)); + dom_env_t *env = calloc(1, sizeof(*env)); env->graph = graph; env->dt = get_dominator_tree (graph); diff --git a/ir/tr/entity.c b/ir/tr/entity.c index 640fce668..aee090d62 100644 --- a/ir/tr/entity.c +++ b/ir/tr/entity.c @@ -582,11 +582,11 @@ new_compound_graph_path(type *tp, int length) { assert(is_type(tp) && is_compound_type(tp)); assert(length > 0); - res = (compound_graph_path *) calloc (1, sizeof(compound_graph_path) + (length-1) * sizeof(entity *)); + res = calloc (1, sizeof(*res) + (length-1) * sizeof(res->nodes[0])); res->kind = k_ir_compound_graph_path; res->tp = tp; res->len = length; - res ->arr_indicees = (int *) calloc(length, sizeof(int)); + res ->arr_indicees = calloc(length, sizeof(*res ->arr_indicees)); return res; } @@ -945,7 +945,7 @@ void compute_compound_ent_array_indicees(entity *ent) { /* FIXME MMB: the memcpy is very strange */ static int *resize (int *buf, int new_size) { - int *new_buf = (int *)calloc(new_size, 4); + int *new_buf = (int *)calloc(new_size, sizeof(*new_buf)); memcpy(new_buf, buf, new_size>1); free(buf); return new_buf; @@ -984,7 +984,7 @@ void sort_compound_ent_values(entity *ent) { /* estimated upper bound for size. Better: use flexible array ... */ size = ((tp_size > (n_vals * 32)) ? tp_size : (n_vals * 32)) * 4; - permutation = (int *)calloc(size, 4); + permutation = calloc(size, sizeof(*permutation)); for (i = 0; i < n_vals; ++i) { int pos = get_compound_ent_value_offset_bits(ent, i); while (pos >= size) {