-#define array_roundsize(base,n) ((n) | 4 & ~3)
-
-#define array_needsize(base,cur,cnt,init) \
- if (expect_false ((cnt) > cur)) \
- { \
- int newcnt = cur; \
- do \
- { \
- newcnt = array_roundsize (base, newcnt << 1); \
- } \
- while ((cnt) > newcnt); \
- \
- base = realloc (base, sizeof (*base) * (newcnt)); \
- init (base + cur, newcnt - cur); \
- cur = newcnt; \
+#define array_roundsize(type,n) ((n) | 4 & ~3)
+
+#define array_needsize(type,base,cur,cnt,init) \
+ if (expect_false ((cnt) > cur)) \
+ { \
+ int newcnt = cur; \
+ do \
+ { \
+ newcnt = array_roundsize (type, newcnt << 1); \
+ } \
+ while ((cnt) > newcnt); \
+ \
+ base = (type *)ev_realloc (base, sizeof (type) * (newcnt));\
+ init (base + cur, newcnt - cur); \
+ cur = newcnt; \
+ }
+
+#define array_slim(type,stem) \
+ if (stem ## max < array_roundsize (stem ## cnt >> 2)) \
+ { \
+ stem ## max = array_roundsize (stem ## cnt >> 1); \
+ base = (type *)ev_realloc (base, sizeof (type) * (stem ## max));\
+ fprintf (stderr, "slimmed down " # stem " to %d\n", stem ## max);/*D*/\