On Tue, Jan 31, 2012 at 22:53:37 +, Alexander Nasonov wrote:
> David Laight wrote:
> > I don't believe there is a problem using m[0], just m[non-constant-expr].
>
> Practically speaking, m[0] is not a problem but the standard says
>
> ... to the structure member (designated by member-designa
On Jan 31, 2012, at 3:53 PM, Alexander Nasonov wrote:
> David Laight wrote:
>> I don't believe there is a problem using m[0], just m[non-constant-expr].
>
> Practically speaking, m[0] is not a problem but the standard says
>
> ... to the structure member (designated by member-designator), ...
>
David Laight wrote:
> I don't believe there is a problem using m[0], just m[non-constant-expr].
Practically speaking, m[0] is not a problem but the standard says
... to the structure member (designated by member-designator), ...
^^
> OTOH 'sizeof (s *)0->m[0]' might be d
On Tue, Jan 31, 2012 at 09:51:17PM +, Alexander Nasonov wrote:
> Joerg Sonnenberger wrote:
> > That's still not necessarily optimal, depending on the padding rules of
> > the platform. You want to do offsetof(s, m[0]) + n * sizeof((s*)NULL->m[0]).
>
> Using m[0] inside offsetof is non-standard
Joerg Sonnenberger wrote:
> That's still not necessarily optimal, depending on the padding rules of
> the platform. You want to do offsetof(s, m[0]) + n * sizeof((s*)NULL->m[0]).
Using m[0] inside offsetof is non-standard but I think this will work:
offsetof(s, m) + n * sizeof((s*)NULL->m[0]).
A
On Tue, Jan 31, 2012 at 07:50:26PM +, Alexander Nasonov wrote:
> Joerg Sonnenberger wrote:
> > On Tue, Jan 31, 2012 at 07:32:52PM +, Alexander Nasonov wrote:
> > > #define sizeof_fam(s, m, n) (sizeof(s) + sizeof(((s *)NULL)->m[0]) * (n))
> >
> > That's still not necessarily optimal, depend
Joerg Sonnenberger wrote:
> On Tue, Jan 31, 2012 at 07:32:52PM +, Alexander Nasonov wrote:
> > #define sizeof_fam(s, m, n) (sizeof(s) + sizeof(((s *)NULL)->m[0]) * (n))
>
> That's still not necessarily optimal, depending on the padding rules of
> the platform. You want to do offsetof(s, m[0])
On Tue, Jan 31, 2012 at 07:32:52PM +, Alexander Nasonov wrote:
> 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))
That's st
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
> DTRT.
DTRT TWW
On Tue, Jan 31, 2012 at 07:11:38PM +, Alexander Nasonov wrote:
> Module Name: src
> Committed By: alnsn
> Date: Tue Jan 31 19:11:38 UTC 2012
>
> Modified Files:
> src/sys/kern: subr_pcq.c
>
> Log Message:
> Replace offsetof(pcq_t, pcq_items[nitems]) with sizeof(pcq_t) + sizeof(
On Mon, Jan 30, 2012 at 06:14:43AM +, David A. Holland wrote:
> Module Name: src
> Committed By: dholland
> Date: Mon Jan 30 06:14:43 UTC 2012
>
> Modified Files:
> src/usr.bin/quota: quotautil.c quotautil.h
>
> Log Message:
> Remove stray p in identifier name. This has (as far
11 matches
Mail list logo