From: Michael Beck Date: Tue, 6 Jun 2006 12:07:01 +0000 (+0000) Subject: use xmalloc instead of malloc X-Git-Url: http://nsz.repo.hu/git/?a=commitdiff_plain;h=b78bdd4d94de46de4156272e6dbfe44e97933a5b;p=libfirm use xmalloc instead of malloc [r7878] --- diff --git a/ir/adt/gaussjordan.c b/ir/adt/gaussjordan.c index 52d804032..678e43b94 100644 --- a/ir/adt/gaussjordan.c +++ b/ir/adt/gaussjordan.c @@ -33,8 +33,13 @@ /* returns -1 if ill-conditioned matrix */ /*------------------------------------------------------*/ +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + #include #include +#include "xmalloc.h" #define SMALL 0.00001 @@ -42,8 +47,8 @@ int firm_gaussjordansolve(double *A, double *vec, int nsize) { int i, j, row, col, col2, biggest_r, biggest_c; double big, temp, sum; - double *x = malloc(nsize * sizeof(double)); - double *scramvec = malloc(nsize * sizeof(double)); + double *x = xmalloc(nsize * sizeof(double)); + double *scramvec = xmalloc(nsize * sizeof(double)); #define _A(row,col) A[(row)*nsize + (col)] /* init x[] */ diff --git a/ir/ana2/qset.c b/ir/ana2/qset.c index c21e355f3..87ca9e319 100644 --- a/ir/ana2/qset.c +++ b/ir/ana2/qset.c @@ -63,7 +63,7 @@ static void *mix_malloc (struct obstack *obst, size_t size) if (NULL != obst) { return (obstack_alloc (obst, size)); } else { - return (malloc (size)); + return (xmalloc (size)); } } @@ -730,6 +730,9 @@ int qset_test_main (int argc, char **argv) /* $Log$ + Revision 1.12 2006/06/06 12:06:27 beck + use xmalloc instead of malloc + Revision 1.11 2005/06/22 09:34:11 beck typo fixed diff --git a/ir/ana2/timing.c b/ir/ana2/timing.c index f8eabed78..89622cf38 100644 --- a/ir/ana2/timing.c +++ b/ir/ana2/timing.c @@ -69,10 +69,10 @@ timeval_subtract (struct timeval *x, struct timeval *y) timing_t * start_timing (void) { - timing_t *t = (timing_t*) malloc (sizeof (timing_t)); + timing_t *t = (timing_t*) xmalloc (sizeof (timing_t)); - t->start = (struct timeval*) malloc (sizeof (struct timeval)); - t->end = (struct timeval*) malloc (sizeof (struct timeval)); + t->start = (struct timeval*) xmalloc (sizeof (struct timeval)); + t->end = (struct timeval*) xmalloc (sizeof (struct timeval)); gettimeofday (t->start, NULL); @@ -104,6 +104,9 @@ end_timing (timing_t *t) /* $Log$ + Revision 1.4 2006/06/06 12:06:27 beck + use xmalloc instead of malloc + Revision 1.3 2005/01/05 14:25:38 beck added Win32 "support" diff --git a/ir/ir/irdump.c b/ir/ir/irdump.c index bf0c81aa3..ccb1d324b 100644 --- a/ir/ir/irdump.c +++ b/ir/ir/irdump.c @@ -2217,7 +2217,7 @@ FILE *vcg_open (ir_graph *irg, const char * suffix1, const char *suffix2) { if (!suffix2) suffix2 = ""; /* open file for vcg graph */ - fname = malloc (len * 2 + strlen(suffix1) + strlen(suffix2) + 5); + fname = xmalloc (len * 2 + strlen(suffix1) + strlen(suffix2) + 5); /* strncpy (fname, nm, len); */ /* copy the filename */ j = 0; diff --git a/ir/ir/irdumptxt.c b/ir/ir/irdumptxt.c index 2b1c8f098..24b91cd6c 100644 --- a/ir/ir/irdumptxt.c +++ b/ir/ir/irdumptxt.c @@ -57,7 +57,7 @@ static FILE *text_open (const char *basename, const char * suffix1, const char * if (!suffix3) suffix3 = ".txt"; /* open file for vcg graph */ - fname = malloc (strlen(basename)*2 + strlen(suffix1) + strlen(suffix2) + 5); /* *2: space for excapes. */ + fname = xmalloc (strlen(basename)*2 + strlen(suffix1) + strlen(suffix2) + 5); /* *2: space for excapes. */ j = 0; for (i = 0; i < len; ++i) { /* replace '/' in the name: escape by @. */ diff --git a/ir/opt/data_flow_scalar_replace.c b/ir/opt/data_flow_scalar_replace.c index 8eea83691..f923a5cb0 100644 --- a/ir/opt/data_flow_scalar_replace.c +++ b/ir/opt/data_flow_scalar_replace.c @@ -1140,7 +1140,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 = malloc(sizeof(ir_node*) *vnum_state); + in = xmalloc(sizeof(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) { diff --git a/ir/tv/strcalc.c b/ir/tv/strcalc.c index e463bf4e8..b23b0ece1 100644 --- a/ir/tv/strcalc.c +++ b/ir/tv/strcalc.c @@ -1604,11 +1604,6 @@ void init_strcalc(int precision) calc_buffer = xmalloc(calc_buffer_size+1 * sizeof(char)); output_buffer = xmalloc(bit_pattern_size+1 * sizeof(char)); - if (calc_buffer == NULL || output_buffer == NULL) { - assert(0 && "malloc failed"); - exit(-1); - } - DEBUGPRINTF(("init strcalc: \n\tPRECISION: %d\n\tCALC_BUFFER_SIZE = %d\n\tMAX_VALUE_SIZE = %d\n\tbuffer pointer: %p\n", precision, calc_buffer_size, max_value_size, calc_buffer)); } } diff --git a/ir/tv/tv.c b/ir/tv/tv.c index 90d24bb7a..80ed8def2 100644 --- a/ir/tv/tv.c +++ b/ir/tv/tv.c @@ -52,6 +52,7 @@ #include "strcalc.h" #include "fltcalc.h" #include "irtools.h" +#include "xmalloc.h" #include "firm_common.h" /** Size of hash tables. Should correspond to average number of distinct constant @@ -1569,7 +1570,7 @@ char *get_tarval_bitpattern(tarval *tv) int i, j, pos = 0; int n = get_mode_size_bits(tv->mode); int bytes = (n + 7) / 8; - char *res = malloc((n + 1) * sizeof(char)); + char *res = xmalloc((n + 1) * sizeof(char)); unsigned char byte; for(i = 0; i < bytes; i++) {