[prev in list] [next in list] [prev in thread] [next in thread]
List: quagga-dev
Subject: [quagga-dev 3922] Re: offsetof and buffer.c
From: Vincent Jardin <vincent.jardin () 6wind ! com>
Date: 2006-01-11 23:40:25
Message-ID: 43C59769.1000207 () 6wind ! com
[Download RAW message or body]
Andrew J. Schorr wrote:
>On Wed, Jan 11, 2006 at 11:38:43PM +0100, Vincent Jardin wrote:
>
>
>>What is it supposed to be the length of this allocated memory ?
>>d = XMALLOC(MTYPE_BUFFER_DATA, offsetof(struct buffer_data, data[b->size]));
>>data[b->size] is not a member of struct buffer_data, but data is such a
>>member.
>>
>>
>
>According to <stddef.h>,
>
> #define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER)
>
>So,
>
> offsetof(struct buffer_data, data[b->size]) =
> ((size_t) &((struct buffer_data *)0)->data[b->size])
>
>So, if there are no alignment issues, it's essentially
>equal to:
> sizeof(struct buffer_data)+b->size
>
>Does that answer the question?
>
>
Yes, thanks Andrew.
Regards,
Vincent
>Regards,
>Andy
>
>
>
_______________________________________________
Quagga-dev mailing list
Quagga-dev@lists.quagga.net
http://lists.quagga.net/mailman/listinfo/quagga-dev
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic