+/*
+ * Allocate a "parse item", which is a union of several parse tree
+ * structure types, together with a string buffer. The s_sz argument
+ * specifies the size of the string (including its terminator), which
+ * may be zero.
+ *
+ * The union's declarator member is pre-initialized to a valid "identifier"
+ * declarator, which shares several interesting offsets with the "declspec"
+ * structure for an "identifier" type specifier.
+ */
+struct parse_item *cdecl__alloc_item(size_t s_sz)
+{
+ struct parse_item *ret;
+
+ ret = malloc(offsetof(struct parse_item, s) + s_sz);
+ if (!ret) {
+ cdecl__errmsg(CDECL__ENOMEM);
+ return NULL;
+ }
+
+ ret->u.declarator.child = NULL;
+ ret->u.declarator.type = CDECL_DECL_IDENT;
+ ret->u.declarator.u.ident = ret->s;
+
+ return ret;
+}
+