lwip-users
[Top][All Lists]
Advanced

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

RE: [lwip-users] Sending UDP


From: Julian Gardner [RSD]
Subject: RE: [lwip-users] Sending UDP
Date: Tue, 11 Sep 2007 16:22:10 +0100

I know i should not change the pointer, the code was what i would LIKE to do so 
i dont have to copy data from a fixed buffer to another fixed buffer.

can i change the pointer if i do something like

  newBufHeader = pbuf_alloc( PBUF_TRANSPORT, 0, PBUF_RAM);
  newBuf = pbuf_alloc( PBUF_TRANSPORT, 1324, PBUF_REF);
  chain( newBufHeader, newBuf);
  while( bytesToSend)
  {
    newBuf->payload = currentBufferPointer);
    udp_send( outUdp, newBuf);
    currentBufferPointer += 1324;
    bytesToSend -= 1324;
  }
  pbuf_free( newBuf);

joolz

-----Original Message-----
From: address@hidden on behalf of Goldschmidt Simon
Sent: Tue 11/09/2007 16:16
To: Mailing list for lwIP users
Subject: RE: [lwip-users] Sending UDP
 
 
 
>What is the best way, pbuf_chain to do the same but just point the
newBuf->payload at the data without copying it!!
>       
>eg
c>  while( bytesToSend)
>  {
>    newBuf->payload = currentBufferPointer;
>    udp_send( outUdp, newBuf);
>    currentBufferPointer += 1324;
>    bytesToSend -= 1324;
>  }
>  pbuf_free( newBuf);

You must not modify the payload pointer directly for PBUF_RAM or
PBUF_POOL!!! In fact, you allocated memory when you called
pbuf_alloc(..., PBUF_RAM). When changing the payload pointer you don't
used that memory any more, is that what you intended? Maybe you want to
use PBUF_REF instead?

That said, we've had a discussion about PBUF_RAM at
http://savannah.nongnu.org/task/?6735 I think. I don't know exactly what
we decided, but there was a suggestion applications may not re-use
PBUF_RAM after passing it to an output function... Your report is
definitively worth a thought in that task!

Simon


_______________________________________________
lwip-users mailing list
address@hidden
http://lists.nongnu.org/mailman/listinfo/lwip-users

<<winmail.dat>>


reply via email to

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