added makro to shrink an array by resetting the length
authorGötz Lindenmaier <goetz@ipd.info.uni-karlsruhe.de>
Tue, 16 Nov 2004 10:16:27 +0000 (10:16 +0000)
committerGötz Lindenmaier <goetz@ipd.info.uni-karlsruhe.de>
Tue, 16 Nov 2004 10:16:27 +0000 (10:16 +0000)
[r4403]

ir/adt/array.h

index d42322e..7db99bd 100644 (file)
 #define ARR_SETLEN(type, arr, n)                                       \
   (XMALLOC_TRACE (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_SHRINKLEN(arr,len)                                          \
+   (ARR_VRFY ((arr)), assert(_ARR_DESCR((arr))->nelts >= len),             \
+    _ARR_DESCR((arr))->nelts = len)
+
 /**
  * Resize a flexible array by growing it by delta elements.
  *