Loads do not remove any nodes from the exec after sets. Also fix a 'node leak'.
[libfirm] / ir / adt / array.h
index 47c9f15..7a72b9e 100644 (file)
@@ -1,29 +1,42 @@
 /*
- * Project:     libFIRM
- * File name:   ir/adt/array.h
- * Purpose:     Declarations for Array.
- * Author:      Markus Armbruster
- * Modified by:
- * Created:     1999 by getting from fiasco
- * CVS-ID:      $Id$
- * Copyright:   (c) 1995, 1996 Markus Armbruster
- * Licence:     This file protected by GPL -  GNU GENERAL PUBLIC LICENSE.
+ * Copyright (C) 1995-2007 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.
  */
 
 /**
- * @file array.h   Dynamic and flexible arrays for C.
+ * @file
+ * @brief     Dynamic and flexible arrays for C.
+ * @author    Markus Armbruster
+ * @version   $Id$
  */
-
-#ifndef _ARRAY_H
-#define _ARRAY_H
+#ifndef FIRM_ADT_ARRAY_H
+#define FIRM_ADT_ARRAY_H
 
 #include <assert.h>
 #include <stddef.h>
-#include <obstack.h>
 
-#include "cookies.h"
+#include "obst.h"
+#include "fourcc.h"
+#include "align.h"
 #include "xmalloc.h"
 
+#define ARR_D_MAGIC    FOURCC('A','R','R','D')
+#define ARR_A_MAGIC    FOURCC('A','R','R','A')
+#define ARR_F_MAGIC    FOURCC('A','R','R','F')
 
 /**
  * Creates a flexible array.
  *         first element of this array).
  */
 #define NEW_ARR_F(type, nelts)                                         \
-  (XMALLOC_TRACE (type *)_new_arr_f ((nelts), sizeof(type) * (nelts)))
+  ((type *)_new_arr_f ((nelts), sizeof(type) * (nelts)))
 
 /**
- * Creates a new flxible array with the same number of elements as a
+ * Creates a new flexible array with the same number of elements as a
  * given one.
  *
  * @param type     The element type of the new array.
@@ -76,7 +89,7 @@
  *
  * @param arr    The flexible array.
  */
-#define DEL_ARR_F(arr) (XMALLOC_TRACE _del_arr_f ((arr)))
+#define DEL_ARR_F(arr) (_del_arr_f ((arr)))
 
 /**
  * Creates a dynamic array on an obstack.
 
 /**
  * Create an automatic array which will be deleted at return from function.
- * Beware, the data will be allocated un the functions stack!
+ * Beware, the data will be allocated on the function stack!
  *
  * @param type     The element type of the new array.
  * @param var      A lvalue of type (type *) which will hold the new array.
  * @remark  This macro may change arr, so update all references!
  */
 #define ARR_RESIZE(type, arr, n)                                       \
-  (XMALLOC_TRACE (arr) = _arr_resize ((arr), (n), sizeof(type)))
+  ((arr) = _arr_resize ((arr), (n), sizeof(type)))
 
 /**
  * Resize a flexible array, always reallocate data.
  * @remark  This macro may change arr, so update all references!
  */
 #define ARR_SETLEN(type, arr, n)                                       \
-  (XMALLOC_TRACE (arr) = _arr_setlen ((arr), (n), sizeof(type) * (n)))
+  ((arr) = _arr_setlen ((arr), (n), sizeof(type) * (n)))
 
 /** Set a length smaller than the current length of the array.  Do not
  *  resize. len must be <= ARR_LEN(arr). */
 # define ARR_IDX_VRFY(arr, idx) ((void)0)
 #else
 # define ARR_VRFY(arr)                                                                 \
-    assert (   (   (_ARR_DESCR((arr))->cookie == ARR_D_MAGIC)                          \
-               || (_ARR_DESCR((arr))->cookie == ARR_A_MAGIC)                           \
-               || (_ARR_DESCR((arr))->cookie == ARR_F_MAGIC))                          \
-           && (   (_ARR_DESCR((arr))->cookie != ARR_F_MAGIC)                           \
+    assert (   (   (_ARR_DESCR((arr))->magic == ARR_D_MAGIC)                           \
+               || (_ARR_DESCR((arr))->magic == ARR_A_MAGIC)                            \
+               || (_ARR_DESCR((arr))->magic == ARR_F_MAGIC))                           \
+           && (   (_ARR_DESCR((arr))->magic != ARR_F_MAGIC)                            \
                || (_ARR_DESCR((arr))->u.allocated >= _ARR_DESCR((arr))->nelts))        \
            && (_ARR_DESCR((arr))->nelts >= 0))
 # define ARR_IDX_VRFY(arr, idx)                                \
 # define _ARR_DBGINF_DECL
 # define _ARR_SET_DBGINF(descr, co, es)
 #else
-# define _ARR_DBGINF_DECL int cookie; size_t eltsize;
+# define _ARR_DBGINF_DECL int magic; size_t eltsize;
 # define _ARR_SET_DBGINF(descr, co, es)                                        \
-    ( (descr)->cookie = (co), (descr)->eltsize = (es) )
+    ( (descr)->magic = (co), (descr)->eltsize = (es) )
 #endif
 
 /**
@@ -333,4 +346,4 @@ void *_arr_setlen (void *, int, size_t);
 #define _ARR_ELTS_OFFS offsetof (_arr_descr, v.elts)
 #define _ARR_DESCR(elts) ((_arr_descr *)(void *)((char *)(elts) - _ARR_ELTS_OFFS))
 
-#endif
+#endif /* FIRM_ADT_ARRAY_H */