lwip-users
[Top][All Lists]
Advanced

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

Re: [lwip-users] Alignment problem i pbuf_alloc()


From: K.J. Mansley
Subject: Re: [lwip-users] Alignment problem i pbuf_alloc()
Date: 26 May 2004 11:07:56 +0100

On Tue, 2004-05-25 at 16:28, Bill Knight wrote:
> I'll jump in here.  'payload' is declared as a void pointer.  If all
> it is ever used for is to access bytes, then 'offset' does not need to
> be taken into the alignment calc. when determining the address to
> store into 'payload'.  If however, if is used to read or store 16 or
> 32 bit values from and to the network device, and if it is aligned,
> the data would not have to be broken into bytes and then reassembled.
> I would suggest adding 'offset' into the alignment calc.

Just for the avoidance of doubt, you suggest we use:

p = mem_malloc(MEM_ALIGN_SIZE(sizeof(struct pbuf) + offset) + 
MEM_ALIGN_SIZE(length));
p->payload = MEM_ALIGN((void *)((u8_t *)p + sizeof(struct pbuf) + offset));

rather than:

p = mem_malloc(MEM_ALIGN_SIZE(sizeof(struct pbuf)) + MEM_ALIGN_SIZE(length + 
offset));
p->payload = MEM_ALIGN((void *)((u8_t *)p + sizeof(struct pbuf))) + offset;

Is that correct?

Kieran





reply via email to

[Prev in Thread] Current Thread [Next in Thread]