use xmalloc instead of malloc
authorMichael Beck <beck@ipd.info.uni-karlsruhe.de>
Tue, 6 Jun 2006 12:07:01 +0000 (12:07 +0000)
committerMichael Beck <beck@ipd.info.uni-karlsruhe.de>
Tue, 6 Jun 2006 12:07:01 +0000 (12:07 +0000)
[r7878]

ir/adt/gaussjordan.c
ir/ana2/qset.c
ir/ana2/timing.c
ir/ir/irdump.c
ir/ir/irdumptxt.c
ir/opt/data_flow_scalar_replace.c
ir/tv/strcalc.c
ir/tv/tv.c

index 52d8040..678e43b 100644 (file)
 /* returns -1 if ill-conditioned matrix                 */
 /*------------------------------------------------------*/
 
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
 #include <math.h>
 #include <stdlib.h>
+#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[] */
index c21e355..87ca9e3 100644 (file)
@@ -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
 
index f8eabed..89622cf 100644 (file)
@@ -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)
 \f
 /*
   $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"
 
index bf0c81a..ccb1d32 100644 (file)
@@ -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;
index 2b1c8f0..24b91cd 100644 (file)
@@ -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 @. */
index 8eea836..f923a5c 100644 (file)
@@ -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) {
index e463bf4..b23b0ec 100644 (file)
@@ -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));
   }
 }
index 90d24bb..80ed8de 100644 (file)
@@ -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++) {