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
......@@ -30,7 +30,6 @@
#include "firm_config.h"
#include "firm_types.h"
#include "xmalloc.h"
#define HashSet ir_edgeset_t
#define HashSetIterator ir_edgeset_iterator_t
......
......@@ -195,7 +195,7 @@ ir_graph *new_r_ir_graph(ir_entity *ent, int n_loc) {
/*-- initialized for each graph. --*/
res->kind = k_ir_graph;
res->obst = xmalloc (sizeof(*res->obst));
res->obst = XMALLOC(struct obstack);
obstack_init(res->obst);
res->phase_state = phase_building;
......@@ -320,7 +320,7 @@ ir_graph *new_const_code_irg(void) {
#if USE_EXPLICIT_PHI_IN_STACK
res->Phi_in_stack = NULL;
#endif
res->obst = xmalloc(sizeof(*res->obst));
res->obst = XMALLOC(struct obstack);
obstack_init (res->obst);
res->extbb_obst = NULL;
......@@ -471,7 +471,7 @@ ir_graph *create_irg_copy(ir_graph *irg) {
#if USE_EXPLICIT_PHI_IN_STACK
res->Phi_in_stack = NULL;
#endif
res->obst = xmalloc(sizeof(*res->obst));
res->obst = XMALLOC(struct obstack);
obstack_init(res->obst);
res->extbb_obst = NULL;
......@@ -1035,7 +1035,7 @@ void set_irg_loc_description(ir_graph *irg, int n, void *description) {
assert(0 <= n && n < irg->n_loc);
if (! irg->loc_descriptions)
irg->loc_descriptions = xcalloc(sizeof(*irg->loc_descriptions), irg->n_loc);
irg->loc_descriptions = XMALLOCNZ(void*, irg->n_loc);
irg->loc_descriptions[n] = description;
}
......
......@@ -100,7 +100,7 @@ void ir_lnk_nodemap_destroy(ir_lnk_nodemap_t *nodemap);
* @return The initialized nodemap
*/
static INLINE ir_lnk_nodemap_t *ir_lnk_nodemap_new(size_t expected_elements) {
ir_lnk_nodemap_t *res = xmalloc(sizeof(*res));
ir_lnk_nodemap_t *res = XMALLOC(ir_lnk_nodemap_t);
ir_lnk_nodemap_init_size(res, expected_elements);
return res;
}
......
......@@ -99,7 +99,7 @@ void ir_lnk_nodeset_destroy(ir_lnk_nodeset_t *nodeset);
* @return The initialized nodeset
*/
static INLINE ir_lnk_nodeset_t *ir_lnk_nodeset_new(size_t expected_elements) {
ir_lnk_nodeset_t *res = xmalloc(sizeof(*res));
ir_lnk_nodeset_t *res = XMALLOC(ir_lnk_nodeset_t);
ir_lnk_nodeset_init_size(res, expected_elements);
return res;
}
......
......@@ -31,7 +31,6 @@
#define _FIRM_IRNODEMAP_H_
#include "irnode.h"
#include "xmalloc.h"
typedef struct ir_nodemap_entry_t {
const ir_node *node;
......
......@@ -90,7 +90,7 @@ void ir_nodeset_destroy(ir_nodeset_t *nodeset);
* @return The initialized nodeset
*/
static INLINE ir_nodeset_t *ir_nodeset_new(size_t expected_elements) {
ir_nodeset_t *res = xmalloc(sizeof(*res));
ir_nodeset_t *res = XMALLOC(ir_nodeset_t);
ir_nodeset_init_size(res, expected_elements);
return res;
}
......
......@@ -235,10 +235,7 @@ new_ir_op(unsigned code, const char *name, op_pin_state p,
unsigned flags, op_arity opar, int op_index, size_t attr_size,
const ir_op_ops *ops)
{
ir_op *res;
res = (ir_op *)xmalloc(sizeof(*res));
memset(res, 0, sizeof(*res));
ir_op *res = XMALLOCZ(ir_op);
res->code = code;
res->name = new_id_from_chars(name, strlen(name));
......
......@@ -49,7 +49,6 @@
#include "opt_polymorphy.h"
#include "irtools.h"
#include "array_t.h"
#include "xmalloc.h"
/* Make types visible to allow most efficient access */
#include "entity_t.h"
......
......@@ -299,7 +299,7 @@ static INLINE void _private_phase_enlarge(ir_phase *phase, unsigned max_idx)
max_idx = MAX(max_idx, last_irg_idx);
new_cap = (size_t) (max_idx * phase->growth_factor / 256);
phase->data_ptr = (void **)xrealloc(phase->data_ptr, new_cap * sizeof(phase->data_ptr[0]));
phase->data_ptr = XREALLOC(phase->data_ptr, void*, new_cap);
/* initialize the newly allocated memory. */
memset(phase->data_ptr + old_cap, 0, (new_cap - old_cap) * sizeof(phase->data_ptr[0]));
......
......@@ -51,11 +51,9 @@ ir_prog *get_irp(void) { return irp; }
/**
* Create a new incomplete ir_prog.
*/
static ir_prog *new_incomplete_ir_prog(void) {
ir_prog *res;
res = xmalloc(sizeof(*res));
memset(res, 0, sizeof(*res));
static ir_prog *new_incomplete_ir_prog(void)
{
ir_prog *res = XMALLOCZ(ir_prog);
res->kind = k_ir_prog;
res->graphs = NEW_ARR_F(ir_graph *, 0);
......
......@@ -89,7 +89,7 @@ void ir_valueset_destroy(ir_valueset_t *valueset);
* @return The initialized value set
*/
static INLINE ir_valueset_t *ir_valueset_new(size_t expected_elements) {
ir_valueset_t *res = xmalloc(sizeof(*res));
ir_valueset_t *res = XMALLOC(ir_valueset_t);
ir_valueset_init_size(res, expected_elements);
return res;
}
......
......@@ -81,8 +81,7 @@ static int lc_arg_cmp(const void *p1, const void *p2, UNUSED(size_t size))
lc_arg_env_t *lc_arg_new_env(void)
{
lc_arg_env_t *env = xmalloc(sizeof(*env));
memset(env, 0, sizeof(*env));
lc_arg_env_t *env = XMALLOCZ(lc_arg_env_t);
env->args = new_set(lc_arg_cmp, 16);
return env;
}
......@@ -257,7 +256,7 @@ static int std_emit(lc_appendable_t *app, const lc_arg_occ_t *occ, const lc_arg_
default:
{
int len = LC_MAX(128, occ->width + 1);
char *buf = xmalloc(len * sizeof(char));
char *buf = XMALLOCN(char, len);
res = dispatch_snprintf(buf, len, fmt, occ->lc_arg_type, val);
res = lc_appendable_snadd(app, buf, res);
xfree(buf);
......
......@@ -41,7 +41,6 @@
#include "iroptimize.h"
#include "array_t.h"
#include "pmap.h"
#include "xmalloc.h"
#include "error.h"
/** A type map for def_find_pointer_type. */
......
......@@ -59,7 +59,6 @@
#include "pdeq.h"
#include "irdump.h"
#include "array_t.h"
#include "xmalloc.h"
/** A map from mode to a primitive type. */
static pmap *prim_types;
......
......@@ -40,7 +40,6 @@
#include "trouts.h"
#include "irvrfy.h"
#include "pmap.h"
#include "xmalloc.h"
#include "array_t.h"
#include "iropt_dbg.h"
......
......@@ -421,7 +421,7 @@ static void optimize_blocks(ir_node *b, void *ctx) {
for (i = 0, k = get_Block_n_cfgpreds(b); i < k; ++i) {
max_preds += test_whether_dispensable(b, i);
}
in = xmalloc(max_preds * sizeof(*in));
in = XMALLOCN(ir_node*, max_preds);
/*- Fix the Phi nodes of the current block -*/
for (phi = get_irn_link(b); phi; ) {
......
......@@ -445,8 +445,7 @@ static path_t *find_path(ir_node *sel, unsigned len)
if (!is_Sel(pred)) {
/* we found the root */
res = xmalloc(sizeof(*res) + (len - 1) * sizeof(res->path));
res = XMALLOCF(path_t, path, len);
res->path_len = len;
}
else
......@@ -1144,7 +1143,7 @@ static void sync_mem_edges(env_t *env) {
vnum_state++;
/* We allocate the memory, that we need for the predecessors of the sync.*/
in = xmalloc(sizeof(ir_node*) *vnum_state);
in = XMALLOCN(ir_node*, vnum_state);
/* The global memory edge is the first predecessor of this sync node.*/
if(val_arr[env->gl_mem_vnum].mem_edge_state == NULL) {
......
......@@ -631,7 +631,7 @@ static void insert_nodes(ir_node *block, void *ctx)
DB((dbg, LEVEL_1, "Partial redundant %+F from block %+F found\n", expr, block));
in = xmalloc(arity * sizeof(*in));
in = XMALLOCN(ir_node*, arity);
/* for all predecessor blocks */
for (pos = 0; pos < arity; ++pos) {
ir_node *pred_blk = get_Block_cfgpred_block(block, pos);
......
......@@ -40,7 +40,6 @@
#include "irgwalk.h"
#include "irtools.h"
#include "array_t.h"
#include "xmalloc.h"
// debug
#include "irdump.h"
......
......@@ -525,7 +525,7 @@ static void Detotalise(ir_graph* irg)
size_t npreds = get_Block_n_cfgpreds(end_block);
size_t i;
unfinished_phis = xmalloc(sizeof(*unfinished_phis) * count_addrs);
unfinished_phis = XMALLOCN(ir_node, count_addrs);
for (i = 0; i < count_addrs; i++) {
unfinished_phis[i] = NULL;
}
......
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