On Mon, 2002/07/15 at 04:24:33 -0700, Terry Lambert wrote:
> Luigi Rizzo wrote:
> > sorry but all this just does not make sense to me.
> > 
> > sizeof(foo) should give the same result irrespective of
> > where you use it.
> > 
> > Perhaps the best thing would be to put a
> > 
> >         printf("struct ip_fw has size %d\n", sizeof(struct ip_fw));
> > 
> > both in ipfw2.c and somewhere in ip_fw2.c and see if there is
> > a mismatch between the two numbers.
> 
> I have to assume that what didn't make sense was that his patch
> worked?  8-).
> 
> He's making the valid point that for:
> 
>       struct foo *fee;
> 
> It's possible that:
> 
>       sizeof(struct foo) != (((char *)&fee[1]) - ((char *)&fee[0]))

No, I do not. In fact, the opposite:

        sizeof(struct foo) = (((char *)&fee[1]) - ((char *)&fee[0]))

_must_ always be true, since it is legal to compute the size of
storage needed for an n-element array of struct foo by using
(sizeof(struct foo) * n).

My point was that, because of the above, any padding that might be
required between the first and last member of two struct foo's
immediately following each other must be _included_ in struct foo,
after the last element.

        - thomas

-- 
Thomas Moestl <[EMAIL PROTECTED]> http://www.tu-bs.de/~y0015675/
              <[EMAIL PROTECTED]> http://people.FreeBSD.org/~tmm/
PGP fingerprint: 1C97 A604 2BD0 E492 51D0  9C0F 1FE6 4F1D 419C 776C

To Unsubscribe: send mail to [EMAIL PROTECTED]
with "unsubscribe freebsd-current" in the body of the message

Reply via email to