Commit e07b61c6 authored by Christoph Mallon's avatar Christoph Mallon
Browse files

Good day and welcome to the FIRM XMALLOC*() macros. These macros are provided...

Good day and welcome to the FIRM XMALLOC*() macros.  These macros are provided for the type safety and convenience of the IPD research facility personnel.  The time is 15:32.  Check xmalloc.h for details.

[r22494]
parent 325f4d96
......@@ -167,7 +167,7 @@ static void insert_all_perms_walker(ir_node *bl, void *data) {
* Create a new Perm with the arguments just collected
* above in the arg_set and insert it into the schedule.
*/
in = xmalloc(n_projs * sizeof(in[0]));
in = XMALLOCN(ir_node*, n_projs);
for(pp = set_first(arg_set); pp; pp = set_next(arg_set))
in[pp->pos] = pp->arg;
......
......@@ -38,7 +38,6 @@
#include "pset.h"
#include "pmap.h"
#include "bitset.h"
#include "xmalloc.h"
#include "irprintf_t.h"
#include "irnode_t.h"
......
......@@ -818,7 +818,7 @@ static const debug_ops stabs_ops = {
/* Opens a stabs handler */
dbg_handle *be_stabs_open(void) {
stabs_handle *h = xmalloc(sizeof(*h));
stabs_handle *h = XMALLOC(stabs_handle);
h->base.ops = &stabs_ops;
h->cur_ent = NULL;
......
......@@ -408,7 +408,7 @@ void be_transform_graph(be_irg_t *birg, arch_pretrans_nodes *func, void *cg)
/* create a new obstack */
old_obst = irg->obst;
new_obst = xmalloc(sizeof(*new_obst));
new_obst = XMALLOC(struct obstack);
obstack_init(new_obst);
irg->obst = new_obst;
irg->last_node_idx = 0;
......
......@@ -376,7 +376,7 @@ void set_sched_step_walker(ir_node *block, void *data)
be_uses_t *be_begin_uses(ir_graph *irg, const be_lv_t *lv)
{
be_uses_t *env = xmalloc(sizeof(env[0]));
be_uses_t *env = XMALLOC(be_uses_t);
edges_assure(irg);
......
......@@ -545,8 +545,8 @@ static void ia32_abi_epilogue(void *self, ir_node *bl, ir_node **mem, pmap *reg_
*/
static void *ia32_abi_init(const be_abi_call_t *call, const arch_env_t *aenv, ir_graph *irg)
{
ia32_abi_env_t *env = xmalloc(sizeof(env[0]));
be_abi_call_flags_t fl = be_abi_call_get_flags(call);
ia32_abi_env_t *env = XMALLOC(ia32_abi_env_t);
be_abi_call_flags_t fl = be_abi_call_get_flags(call);
env->flags = fl.bits;
env->irg = irg;
env->aenv = aenv;
......@@ -1580,7 +1580,7 @@ static const arch_code_generator_if_t ia32_code_gen_if = {
*/
static void *ia32_cg_init(be_irg_t *birg) {
ia32_isa_t *isa = (ia32_isa_t *)birg->main_env->arch_env;
ia32_code_gen_t *cg = xcalloc(1, sizeof(*cg));
ia32_code_gen_t *cg = XMALLOCZ(ia32_code_gen_t);
cg->impl = &ia32_code_gen_if;
cg->irg = birg->irg;
......@@ -1742,7 +1742,7 @@ static arch_env_t *ia32_init(FILE *file_handle) {
set_tarval_output_modes();
isa = xmalloc(sizeof(*isa));
isa = XMALLOC(ia32_isa_t);
memcpy(isa, &ia32_isa_template, sizeof(*isa));
if(mode_fpcw == NULL) {
......@@ -1765,7 +1765,7 @@ static arch_env_t *ia32_init(FILE *file_handle) {
ia32_build_8bit_reg_map_high(isa->regs_8bit_high);
#ifndef NDEBUG
isa->name_obst = xmalloc(sizeof(*isa->name_obst));
isa->name_obst = XMALLOC(struct obstack);
obstack_init(isa->name_obst);
#endif /* NDEBUG */
......
......@@ -1044,11 +1044,11 @@ static void emit_ia32_SwitchJmp(const ir_node *node)
const ir_edge_t *edge;
/* fill the table structure */
tbl.label = xmalloc(SNPRINTF_BUF_LEN);
tbl.label = XMALLOCN(char, SNPRINTF_BUF_LEN);
tbl.label = get_unique_label(tbl.label, SNPRINTF_BUF_LEN, ".TBL_");
tbl.defProj = NULL;
tbl.num_branches = get_irn_n_edges(node) - 1;
tbl.branches = xcalloc(tbl.num_branches, sizeof(tbl.branches[0]));
tbl.branches = XMALLOCNZ(branch_t, tbl.num_branches);
tbl.min_value = INT_MAX;
tbl.max_value = INT_MIN;
......
......@@ -413,8 +413,7 @@ static void *mips_cg_init(be_irg_t *birg)
{
const arch_env_t *arch_env = be_get_birg_arch_env(birg);
mips_isa_t *isa = (mips_isa_t *) arch_env;
mips_code_gen_t *cg = xmalloc(sizeof(*cg));
memset(cg, 0, sizeof(*cg));
mips_code_gen_t *cg = XMALLOCZ(mips_code_gen_t);
cg->impl = &mips_code_gen_if;
cg->irg = be_get_birg_irg(birg);
......@@ -466,7 +465,7 @@ static arch_env_t *mips_init(FILE *file_handle) {
return NULL;
inited = 1;
isa = xcalloc(1, sizeof(isa[0]));
isa = XMALLOC(mips_isa_t);
memcpy(isa, &mips_isa_template, sizeof(isa[0]));
be_emit_init(file_handle);
......@@ -538,7 +537,7 @@ typedef struct {
static void *mips_abi_init(const be_abi_call_t *call, const arch_env_t *arch_env, ir_graph *irg)
{
mips_abi_env_t *env = xmalloc(sizeof(env[0]));
mips_abi_env_t *env = XMALLOC(mips_abi_env_t);
be_abi_call_flags_t fl = be_abi_call_get_flags(call);
env->flags = fl.bits;
env->irg = irg;
......
......@@ -554,11 +554,11 @@ void emit_mips_jump_table(const ir_node *irn)
const mips_attr_t *attr = get_mips_attr_const(irn);
/* fill the table structure */
tbl.label = xmalloc(SNPRINTF_BUF_LEN);
tbl.label = XMALLOCN(char, SNPRINTF_BUF_LEN);
tbl.label = get_unique_label(tbl.label, SNPRINTF_BUF_LEN, "JMPTBL_");
tbl.defBlock = NULL;
tbl.num_branches = get_irn_n_edges(irn);
tbl.branches = xcalloc(tbl.num_branches, sizeof(tbl.branches[0]));
tbl.branches = XMALLOCNZ(branch_t, tbl.num_branches);
tbl.min_value = INT_MAX;
tbl.max_value = INT_MIN;
......
......@@ -63,8 +63,7 @@ typedef struct {
static void *mips_scheduler_init_graph(const list_sched_selector_t *vtab, const arch_env_t *arch_env, ir_graph *irg)
{
mips_sched_env_t *sched_env = xmalloc(sizeof(sched_env[0]));
memset(sched_env, 0, sizeof(sched_env[0]));
mips_sched_env_t *sched_env = XMALLOCZ(mips_sched_env_t);
sched_env->arch_env = arch_env;
sched_env->div_set = new_pset(pset_default_ptr_cmp, 4);
......
......@@ -264,7 +264,7 @@ typedef struct
*/
static void *ppc32_abi_init(const be_abi_call_t *call, const arch_env_t *aenv, ir_graph *irg)
{
ppc32_abi_env *env = xmalloc(sizeof(ppc32_abi_env));
ppc32_abi_env *env = XMALLOC(ppc32_abi_env);
(void) aenv;
env->call = call;
......@@ -606,7 +606,7 @@ static const arch_code_generator_if_t ppc32_code_gen_if = {
*/
static void *ppc32_cg_init(be_irg_t *birg) {
ppc32_isa_t *isa = (ppc32_isa_t *)birg->main_env->arch_env;
ppc32_code_gen_t *cg = xmalloc(sizeof(*cg));
ppc32_code_gen_t *cg = XMALLOC(ppc32_code_gen_t);
cg->impl = &ppc32_code_gen_if;
cg->irg = birg->irg;
......@@ -679,7 +679,7 @@ static arch_env_t *ppc32_init(FILE *file_handle) {
if (inited)
return NULL;
isa = xmalloc(sizeof(*isa));
isa = XMALLOC(ppc32_isa_t);
memcpy(isa, &ppc32_isa_template, sizeof(*isa));
be_emit_init(file_handle);
......
......@@ -214,7 +214,7 @@ void finalize_block(ppc32_code_gen_t *cgenv)
memslot = frame_alloc_area(frame_type, get_mode_size_bytes(mode_D), 4, 0);
}
attr->convs = xmalloc(attr->conv_count * sizeof(ir_node *));
attr->convs = XMALLOCN(ir_node*, attr->conv_count);
for (i = 0, current_conv = attr->first_conv; i < attr->conv_count; i++, current_conv = current_conv->link)
{
......@@ -241,7 +241,7 @@ void finalize_block(ppc32_code_gen_t *cgenv)
void init_block(void)
{
cw_block_attr *attr = xmalloc(sizeof(cw_block_attr));
cw_block_attr *attr = XMALLOC(cw_block_attr);
attr->first_conv = NULL;
attr->convs = NULL; /* attr->convs is set in finalize_block() */
attr->conv_count = 0;
......
......@@ -56,8 +56,6 @@
# define NODE_NAME(n, m) (0 == xmlStrcmp (n->name, (const xmlChar*) #m))
# define CHECK_NAME(n, m) assert (0 == xmlStrcmp (n->name, (const xmlChar*) #m))
# define NEW(T) (T*)xmalloc(sizeof (T))
#define VERBOSE_PRINTING 0
......@@ -309,7 +307,7 @@ parseArg (xmlDocPtr doc, xmlNodePtr argelm)
typeid = getNodeTypeStr (argelm);
arg = NEW (eff_t);
arg = XMALLOC(eff_t);
arg -> kind = eff_arg;
arg -> id = new_id_from_str(id);
arg -> effect.arg.num = num;
......@@ -331,7 +329,7 @@ parseValref (xmlDocPtr doc, xmlNodePtr valelm)
ref_id = getNodeRefId (valelm);
VERBOSE_PRINT ((stdout, "val->refid = \"%s\"\n", ref_id));
valref = NEW (eff_t);
valref = XMALLOC(eff_t);
valref->kind = eff_valref;
valref-> id = new_id_from_str(ref_id);
......@@ -345,7 +343,7 @@ parseSelect (xmlDocPtr doc, xmlNodePtr selelm)
entity_t *ent;
xmlNodePtr child;
eff_t *valref = NULL;
eff_t *sel = NEW (eff_t);
eff_t *sel = XMALLOC(eff_t);
sel->kind = eff_select;
CHECK_NAME (selelm, select);
......@@ -377,7 +375,7 @@ parseLoad (xmlDocPtr doc, xmlNodePtr loadelm)
ident *id;
xmlNodePtr child;
eff_t *sel;
eff_t *load = NEW (eff_t);
eff_t *load = XMALLOC(eff_t);
load->kind = eff_load;
CHECK_NAME (loadelm, load);
......@@ -410,7 +408,7 @@ parseStore (xmlDocPtr doc, xmlNodePtr storeelm)
xmlNodePtr child;
eff_t *sel;
eff_t *valref;
eff_t *store = NEW (eff_t);
eff_t *store = XMALLOC(eff_t);
store->kind = eff_store;
CHECK_NAME (storeelm, store);
......@@ -443,7 +441,7 @@ parseAlloc (xmlDocPtr doc, xmlNodePtr allocelm)
{
ident *id;
ident *type_id;
eff_t *alloc = NEW (eff_t); /* ...! */
eff_t *alloc = XMALLOC(eff_t); /* ...! */
alloc->kind = eff_alloc;
(void) doc;
......@@ -468,7 +466,7 @@ parseCall (xmlDocPtr doc, xmlNodePtr callelm)
eff_t *sel;
xmlNodePtr arg;
int n_args;
eff_t *call = NEW (eff_t);
eff_t *call = XMALLOC(eff_t);
call->kind = eff_call;
CHECK_NAME (callelm, call);
......@@ -502,7 +500,7 @@ parseCall (xmlDocPtr doc, xmlNodePtr callelm)
free (sel);
if (0 != n_args) {
ident **args = (ident**) xmalloc(n_args * sizeof(ident*));
ident **args = XMALLOCN(ident*, n_args);
int i = 0;
while (NULL != arg) {
......@@ -526,7 +524,7 @@ parseJoin (xmlDocPtr doc, xmlNodePtr joinelm)
ident **ins;
int i;
xmlNodePtr child;
eff_t *join = NEW (eff_t);
eff_t *join = XMALLOC(eff_t);
join->kind = eff_join;
CHECK_NAME (joinelm, join);
......@@ -542,7 +540,7 @@ parseJoin (xmlDocPtr doc, xmlNodePtr joinelm)
child = child->next;
}
ins = (ident **) xmalloc (n_ins * sizeof (ident *) );
ins = XMALLOCN(ident*, n_ins);
i = 0;
child = get_valid_child(joinelm);
......@@ -564,7 +562,7 @@ static eff_t*
parseUnknown (xmlDocPtr doc, xmlNodePtr unknownelm)
{
ident *id;
eff_t *unknown = NEW (eff_t);
eff_t *unknown = XMALLOC(eff_t);
unknown->kind = eff_unknown;
(void) doc;
......@@ -580,7 +578,7 @@ static eff_t*
parseReturn (xmlDocPtr doc, xmlNodePtr retelm)
{
xmlNodePtr child;
eff_t *ret = NEW (eff_t);
eff_t *ret = XMALLOC(eff_t);
ret->kind = eff_ret;
CHECK_NAME (retelm, ret);
......@@ -605,7 +603,7 @@ parseRaise (xmlDocPtr doc, xmlNodePtr raiseelm)
const char *tp_id;
eff_t *valref;
xmlNodePtr child;
eff_t *raise = NEW (eff_t);
eff_t *raise = XMALLOC(eff_t);
raise->kind = eff_raise;
CHECK_NAME (raiseelm, raise);
......@@ -639,7 +637,7 @@ parseType (xmlDocPtr doc, xmlNodePtr typeelm)
VERBOSE_PRINT ((stdout, "type = \"%s\"\n", getNodeTypeStr (typeelm)));
(void) doc;
type = (type_t*) xmalloc (sizeof (type_t));
type = XMALLOC(type_t);
type -> type_ident = new_id_from_str(getNodeTypeStr (typeelm));
type -> id = new_id_from_str(tp_id);
......@@ -651,7 +649,7 @@ parseType (xmlDocPtr doc, xmlNodePtr typeelm)
static void
parseEntity (xmlDocPtr doc, xmlNodePtr entelm)
{
entity_t *ent = NEW (entity_t);
entity_t *ent = XMALLOC(entity_t);
(void) doc;
/* parse it */
......@@ -691,10 +689,10 @@ parseEffect (xmlDocPtr doc, xmlNodePtr effelm)
}
VERBOSE_PRINT ((stdout, "has %d effects\n", n_effs));
curr_effs = NEW (proc_t);
curr_effs = XMALLOC(proc_t);
curr_effs -> proc_ident = new_id_from_str(procname);
curr_effs -> ownerid = new_id_from_str(ownerid);
curr_effs->effs = (eff_t**) xmalloc (n_effs * sizeof (eff_t*));
curr_effs->effs = XMALLOCN(eff_t*, n_effs);
cur = effelm -> xmlChildrenNode;
while (NULL != cur) {
......@@ -791,7 +789,7 @@ int read_extern (const char *filename)
cur = cur->next;
}
module = NEW(module_t);
module = XMALLOC(module_t);
module -> id = mod_id;
module -> types = types;
module -> entities = entities;
......@@ -1313,7 +1311,7 @@ static void create_abstract_join (ir_graph *irg, proc_t *proc, eff_t *eff)
c_block = new_immBlock (); /* for the Phi after the branch(es) */
ins = (ir_node**) xmalloc (n_ins * sizeof (ir_node*));
ins = XMALLOCN(ir_node*, n_ins);
for (i = 0; i < n_ins; i ++) {
ir_node *projX = NULL;
ir_node *s_block = NULL;
......
......@@ -40,7 +40,6 @@
#include "ident_t.h"
#include "set.h"
#include "xmalloc.h"
/* for debugging only, not the real implementation */
struct _ident {
......
......@@ -69,10 +69,9 @@ typedef struct {
ir_node * except, * except_mem; /* EndExcept and Mem for exception return */
} irg_data_t;
static irg_data_t * irg_data_create(void) {
irg_data_t *data = xmalloc(sizeof(*data));
memset(data, 0, sizeof(*data)); /* init */
return data;
static irg_data_t * irg_data_create(void)
{
return XMALLOCZ(irg_data_t);
}
/** Count the number of callers of each method and mark open methods.
......
......@@ -45,7 +45,6 @@
#include "irflag_t.h"
#include "iredges_t.h"
#include "irflag_t.h"
#include "xmalloc.h"
#if USE_EXPLICIT_PHI_IN_STACK
/* A stack needed for the automatic Phi node construction in constructor
......
......@@ -696,7 +696,7 @@ static list_tuple *construct_extblock_lists(ir_graph *irg) {
ir_node **blk_list = construct_block_lists(irg);
int i;
ir_graph *rem = current_ir_graph;
list_tuple *lists = xmalloc(sizeof(*lists));
list_tuple *lists = XMALLOC(list_tuple);
current_ir_graph = irg;
......@@ -1294,7 +1294,7 @@ static void dump_node_vcgattr(FILE *F, ir_node *node, ir_node *local, int bad)
/* Adds a new node info dumper callback. */
void *dump_add_node_info_callback(dump_node_info_cb_t *cb, void *data)
{
hook_entry_t *info = xmalloc(sizeof(*info));
hook_entry_t *info = XMALLOC(hook_entry_t);
info->hook._hook_node_info = cb;
info->context = data;
......@@ -2377,7 +2377,7 @@ FILE *vcg_open(ir_graph *irg, const char * suffix1, const char *suffix2) {
if (!suffix2) suffix2 = "";
/* open file for vcg graph */
fname = xmalloc (len * 2 + strlen(suffix1) + strlen(suffix2) + 5);
fname = XMALLOCN(char, len * 2 + strlen(suffix1) + strlen(suffix2) + 5);
/* strncpy (fname, nm, len); */ /* copy the filename */
j = 0;
......@@ -2421,7 +2421,7 @@ FILE *vcg_open_name(const char *name, const char *suffix) {
if (!suffix) suffix = "";
/** open file for vcg graph */
fname = xmalloc(len * 2 + 5 + strlen(suffix));
fname = XMALLOCN(char, len * 2 + 5 + strlen(suffix));
/* strcpy (fname, name);*/ /* copy the filename */
j = 0;
for (i = 0; i < len; ++i) { /* replace '/' in the name: escape by @. */
......
......@@ -115,7 +115,7 @@ static int edge_counter;
irg_grgen_dumper_env_t *init_irg_grgen_dumper(char *file, int append)
{
irg_grgen_dumper_env_t *const grgen_dumper_env = xmalloc(sizeof(*grgen_dumper_env));
irg_grgen_dumper_env_t *const grgen_dumper_env = XMALLOC(irg_grgen_dumper_env_t);
FILE *fp;
if(append)
......
......@@ -75,7 +75,7 @@ static FILE *text_open(const char *basename, const char * suffix1, const char *s
if (!suffix3) suffix3 = ".txt";
/* open file for vcg graph */
fname = xmalloc(strlen(basename)*2 + strlen(suffix1) + strlen(suffix2) + 5); /* *2: space for escapes. */
fname = XMALLOCN(char, strlen(basename)*2 + strlen(suffix1) + strlen(suffix2) + 5); /* *2: space for escapes. */
j = 0;
for (i = 0; i < len; ++i) { /* replace '/' in the name: escape by @. */
......@@ -822,7 +822,7 @@ void dump_entity_to_file_prefix(FILE *F, ir_entity *ent, char *prefix, unsigned
max_depth = (depth > max_depth) ? depth : max_depth ;
}
L_freq = xcalloc(4 * max_depth, sizeof(L_freq[0]));
L_freq = XMALLOCNZ(int, 4 * max_depth);
S_freq = L_freq + 1*max_depth;
LA_freq = L_freq + 2*max_depth;
......@@ -955,7 +955,7 @@ void dump_entitycsv_to_file_prefix(FILE *F, ir_entity *ent, char *prefix,
max_depth = (depth > max_depth) ? depth : max_depth ;
}
L_freq = xcalloc(4 * (max_depth+1), sizeof(L_freq[0]));
L_freq = XMALLOCNZ(int, 4 * (max_depth + 1));
S_freq = L_freq + 1*max_depth;
LA_freq = L_freq + 2*max_depth;
......@@ -1060,7 +1060,7 @@ void dump_typecsv_to_file(FILE *F, ir_type *tp, dump_verbosity verbosity, const
max_depth = (depth > max_depth) ? depth : max_depth ;
}
freq = xcalloc(2 * (max_depth+1), sizeof(freq[0]));
freq = XMALLOCNZ(int, 2 * (max_depth + 1));
disp = freq + max_depth;
......@@ -1332,7 +1332,7 @@ void dump_type_to_file(FILE *F, ir_type *tp, dump_verbosity verbosity) {
max_depth = (depth > max_depth) ? depth : max_depth ;
}
freq = xcalloc(max_depth+1, sizeof(freq[0]));
freq = XMALLOCNZ(int, max_depth + 1);
for (i = 0; i < n_all; ++i) {
ir_node *all = get_type_alloc(tp, i);
......
......@@ -42,7 +42,6 @@
#include "debug.h"
#include "set.h"
#include "bitset.h"
#include "xmalloc.h"
#include "iredgeset.h"
#include "hashptr.h"
......
Markdown is supported
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