beifg: Factorise code to count interference components.
[libfirm] / ir / adt / array.c
index b21d4b5..d56f3a5 100644 (file)
@@ -1,20 +1,6 @@
 /*
- * Copyright (C) 1995-2011 University of Karlsruhe.  All right reserved.
- *
  * This file is part of libFirm.
- *
- * This file may be distributed and/or modified under the terms of the
- * GNU General Public License version 2 as published by the Free Software
- * Foundation and appearing in the file LICENSE.GPL included in the
- * packaging of this file.
- *
- * Licensees holding valid libFirm Professional Edition licenses may use
- * this file in accordance with the libFirm Commercial License.
- * Agreement provided with the Software.
- *
- * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
- * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE.
+ * Copyright (C) 2012 University of Karlsruhe.
  */
 
 /**
@@ -28,6 +14,7 @@
 #include <stdlib.h>
 
 #include "array_t.h"
+#include "util.h"
 #include "xmalloc.h"
 
 /* Undefine the macros to get the functions instead, cf tmalloc.c.  */
 #undef xstrdup
 #undef xfree
 
-#ifndef MAX
-# define MAX(a,b) ((a) > (b) ? (a) : (b))
-#endif
-#ifndef MIN
-# define MIN(a,b) ((a) > (b) ? (b) : (a))
-#endif
-
 /**
  * An empty dynamic array descriptor.
  */
-ir_arr_descr arr_mt_descr = { ARR_D_MAGIC, 0, 0, 0,  { { 0 } } };
+ir_arr_descr arr_mt_descr = { ARR_D_MAGIC, 0, 0, { { 0 } } };
 
 void ir_verify_arr(const void *arr)
 {
@@ -79,7 +59,7 @@ void *ir_new_arr_d(struct obstack *obstack, size_t nelts, size_t elts_size)
        assert(obstack);
 
        dp = (ir_arr_descr*)obstack_alloc(obstack, ARR_ELTS_OFFS + elts_size);
-       ARR_SET_DBGINF(dp, ARR_D_MAGIC, elts_size/nelts);
+       ARR_SET_DBGINF(dp, ARR_D_MAGIC);
        dp->allocated = dp->nelts = nelts;
        return dp->elts;
 }
@@ -100,7 +80,7 @@ void *ir_new_arr_f(size_t nelts, size_t elts_size)
        ir_arr_descr *newa;
 
        newa = (ir_arr_descr*)xmalloc(ARR_ELTS_OFFS+elts_size);
-       ARR_SET_DBGINF(newa, ARR_F_MAGIC, nelts ? elts_size/nelts : 0);
+       ARR_SET_DBGINF(newa, ARR_F_MAGIC);
        newa->allocated = newa->nelts = nelts;
        return newa->elts;
 }
@@ -143,7 +123,6 @@ void *ir_arr_setlen (void *elts, size_t nelts, size_t elts_size)
 
        assert(dp->magic == ARR_F_MAGIC);
        ARR_VRFY(elts);
-       assert(!dp->eltsize || !nelts || (dp->eltsize == elts_size/nelts));
 
        dp = (ir_arr_descr*) xrealloc(dp, ARR_ELTS_OFFS+elts_size);
        dp->allocated = dp->nelts = nelts;
@@ -171,7 +150,6 @@ void *ir_arr_resize(void *elts, size_t nelts, size_t eltsize)
 
        assert(dp->magic == ARR_F_MAGIC);
        ARR_VRFY(elts);
-       assert(dp->eltsize ? dp->eltsize == eltsize : (dp->eltsize = eltsize, 1));
 
        /* @@@ lots of resizes for small nelts */
        n = MAX(1, dp->allocated);