tech-kern archive

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

Re: proposal: some pointer and arithmetic utilities



On Fri, Mar 22, 2013 at 01:36:01PM +0000, Taylor R Campbell wrote:
 > We could do the arithmetic without a macro, but it's more complicated
 > to get that correct.  Compare
 > 
 >      struct foo *f = alloc(offsetin(*f, f_data[n]));
 > 
 > with
 > 
 >      struct foo *f = alloc(sizeof(*f) + sizeof(typeof(f->f_data[0])[n]));

if you fix this to read

        struct foo *f = alloc(sizeof(*f) + n * sizeof(f->f_data[0]));

it ceases to be a problem, IMO.

-- 
David A. Holland
dholland%netbsd.org@localhost


Home | Main Index | Thread Index | Old Index