[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: SV: [lwip-users] Alignment problem i pbuf_alloc()
From: |
K.J. Mansley |
Subject: |
Re: SV: [lwip-users] Alignment problem i pbuf_alloc() |
Date: |
25 May 2004 08:57:14 +0100 |
On Tue, 2004-05-25 at 07:05, Lars Thorup wrote:
> Fra: K.J. Mansley [mailto:address@hidden
> > Looks like it, but I'm not sure which bit is wrong. Out of
> > interest, where does the "6" bytes in the offset come from?
> > I'm guessing some physical layer header?
>
> Yes, we are running on top of an ARCNET, and we use a 6 byte header on the
> physical layer.
>
> > I can think of a number of work-arounds, but does anyone have
> > a suggestion for a solid fix?
>
> This is the original code from pbuf_alloc():
>
> case PBUF_RAM:
> /* If pbuf is to be allocated in RAM, allocate memory for it. */
> p = mem_malloc(MEM_ALIGN_SIZE(sizeof(struct pbuf) + length + offset));
>
> I have changed the third line to
>
> p = mem_malloc(MEM_ALIGN_SIZE(sizeof(struct pbuf) + offset) +
> MEM_ALIGN_SIZE(length));
Would it be better to have:
p = mem_malloc(MEM_ALIGN_SIZE(sizeof(struct pbuf)) + MEM_ALIGN_SIZE(offset +
length));
This makes more sense to me, as "offset" and "length" go together to
make the payload of the pbuf, but it may mean the payload pointer starts
off pointing at a non-word aligned address, which might cause problems?
Thanks
Kieran
Re: SV: SV: [lwip-users] Alignment problem i pbuf_alloc(), 刘良, 2004/05/25
[lwip-users] Alignment problem i pbuf_alloc(), Lars Thorup, 2004/05/25