On Fri, Oct 23, 2020 at 02:44:06PM +0200, Bartosz Golaszewski wrote: > On Fri, Oct 23, 2020 at 2:08 PM Andy Shevchenko > <andy.shevchenko@xxxxxxxxx> wrote: > > > > On Fri, Oct 23, 2020 at 3:06 PM Andy Shevchenko > > <andy.shevchenko@xxxxxxxxx> wrote: > > > On Fri, Oct 23, 2020 at 2:39 PM Bartosz Golaszewski <brgl@xxxxxxxx> wrote: > > > > On Fri, Oct 23, 2020 at 12:24 PM Andy Shevchenko > > > > <andy.shevchenko@xxxxxxxxx> wrote: > > > > ... > > > > > > Nope because gcc will scream: > > > > > > > > error: flexible array member in union > > > > > > Ah, of course. Should be > > > struct ... **lines; > > > > But it is not gonna work... we need an array here. or just one member > > > > struct *lines; > > > > bulk: > > lines = malloc(num_lines * sizeof(lines)); > > xxx->lines = lines; > > > > single: > > xxx->lines = line; > > The definition I used is clearer - it's explicit about using an array > with a single member by default and can be extended as needed when > allocating. According to [1] it makes harder to avoid sizeof() type of calculation mistakes for such struct. >From my point of view extending something that has been already predefined is not cool. But it's up to you to decide. [1]: https://www.kernel.org/doc/html/v5.9-rc1/process/deprecated.html#zero-length-and-one-element-arrays -- With Best Regards, Andy Shevchenko