Source-Changes-D archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: CVS commit: src/sys/kern

David Young wrote:
> Yuck. The offsetof() way was much more readable.

Yes, it's more readable but it's not standard C99.
And it's confusing to use offsetof when you want to use sizeof.

> Please put it back the old way.
> If you have to, provide and use a runtime_offsetof() that


What about something like this (untested)?

 * Return a size of a structure s with flexible-array member m
 * with n elements.
#define sizeof_fam(s, m, n) (sizeof(s) + sizeof(((s *)NULL)->m[0]) * (n))

and use like this:

sizeof_fam(struct pcq, pcq_items, nitems);


Home | Main Index | Thread Index | Old Index