Only user of the datatype flags field is DTYPE_F_ALLOC, replace it by
bitfield, squash byteorder to 8 bits which is sufficient.
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
struct expr;
-/**
- * enum datatype_flags
- *
- * @DTYPE_F_ALLOC: datatype is dynamically allocated
- */
-enum datatype_flags {
- DTYPE_F_ALLOC = (1 << 0),
-};
-
struct parse_ctx;
/**
* struct datatype
* @print: function to print a constant of this type
* @parse: function to parse a symbol and return an expression
* @sym_tbl: symbol table for this type
- * @refcnt: reference counter (only for DTYPE_F_ALLOC)
+ * @refcnt: reference counter (only for dynamically allocated, see .alloc)
*/
struct datatype {
uint32_t type;
- enum byteorder byteorder;
+ enum byteorder byteorder:8;
+ uint32_t alloc:1;
unsigned int flags;
unsigned int size;
unsigned int subtypes;
struct datatype *dtype;
dtype = xzalloc(sizeof(*dtype));
- dtype->flags = DTYPE_F_ALLOC;
+ dtype->alloc = 1;
dtype->refcnt = 1;
return dtype;
if (!dtype)
return NULL;
- if (!(dtype->flags & DTYPE_F_ALLOC))
+ if (!dtype->alloc)
return dtype;
dtype->refcnt++;
*dtype = *orig_dtype;
dtype->name = xstrdup(orig_dtype->name);
dtype->desc = xstrdup(orig_dtype->desc);
- dtype->flags = DTYPE_F_ALLOC | orig_dtype->flags;
+ dtype->alloc = 1;
dtype->refcnt = 1;
return dtype;
if (!dtype)
return;
- if (!(dtype->flags & DTYPE_F_ALLOC))
+ if (!dtype->alloc)
return;
assert(dtype->refcnt != 0);