details see stackoverflow.
/* C99 */
struct s {
int n;
double d[];
};
int m = /* some value */;
struct s *p = malloc(sizeof (struct s) + sizeof (double [m]));
/* before C99 */
struct bts_action {
u16 type;
u16 size;
u8 data[0];
};
This is a way to have variable sizes of data, without having to call malloc
(kmalloc
in this case) twice.
The so-called 柔性数组(flexible array)?