/*
- * 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.
*/
/**
#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)
{
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;
}
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;
}
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;
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);