+/* helper macro to destructively resize buffers; assumes that bufsiz
+ * is initialized to 0 if buf is unallocated! */
+#define allocbuf(buf, bufsiz, need, type) do { \
+ if (!buf || (need) > (bufsiz)) \
+ { \
+ (bufsiz) = ((need) < 1024) ? 1024 : (need); \
+ xfree(buf); \
+ (buf) = (type)xmalloc(bufsiz); \
+ } \
+ } while (0);
+
+/* this is a brute-force conversion from UCS-2LE to US-ASCII, discarding
+ * the upper 9 bits */