Commit 5498b039 authored by Dridi Boukelmoune's avatar Dridi Boukelmoune

miniobj: A flex array may start in struct padding

We lose the ability to check that fld is indeed the last field, but we
never had that ability to begin with.
parent 264046f3
......@@ -32,11 +32,8 @@
#define ALLOC_FLEX_OBJ(to, fld, len, type_magic) \
do { \
v_static_assert( \
sizeof *(to) == offsetof(typeof(*(to)), fld), \
"the last field must be a flexible array"); \
(to) = calloc(1, \
sizeof *(to) + ((len) * sizeof *((to)->fld))); \
(to) = calloc(1, offsetof(typeof(*(to)), fld) + \
((len) * sizeof *((to)->fld))); \
if ((to) != NULL) \
(to)->magic = (type_magic); \
} while (0)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment