+/**
+ * Resize a flexible array, allocate more data if needed but do NOT
+ * reduce.
+ *
+ * @param elts The flexible array (pointer to the first element).
+ * @param nelts The new number of elements.
+ * @param eltsize The size of the array elements.
+ *
+ * @return A resized flexible array, possibly other address than
+ * elts.
+ *
+ * @remark Helper function, use ARR_RESIZE() instead.
+ */
+void *ir_arr_resize(void *elts, size_t nelts, size_t eltsize)
+{
+ ir_arr_descr *dp = ARR_DESCR(elts);
+ size_t n;
+
+ 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->u.allocated);
+ while (nelts > n) n <<= 1;
+ while (3*nelts < n) n >>= 1;
+ assert(n >= nelts);
+
+ if (n != dp->u.allocated) {
+ dp = (ir_arr_descr*) xrealloc(dp, ARR_ELTS_OFFS+eltsize*n);
+ dp->u.allocated = n;
+ }
+ dp->nelts = nelts;
+
+ return dp->elts;
+}