I am sending data via UDP, but for every block of data i send
which is 1324 bytes i do the following
while(
bytesToSend)
{
newBuf = pbuf_alloc(
PBUF_TRANSPORT, 1324, PBUF_RAM);
memcpy(
newBuf->payload, currentBufferPointer, 1324);
udp_send( outUdp, newBuf);
pbuf_free(
newBuf);
currentBufferPointer +=
1324;
bytesToSend -= 1324;
}
if i do
the allocate outside of the send loop and the delete after sending all , my
code fails!
newBuf = pbuf_alloc( PBUF_TRANSPORT, 1324,
PBUF_RAM);
while( bytesToSend)
{
memcpy( newBuf->payload, currentBufferPointer, 1324);
udp_send( outUdp, newBuf);
currentBufferPointer +=
1324;
bytesToSend -= 1324;
}
pbuf_free( newBuf);
Also i have to copy the data from its original
place to the newBuf->payload every time
What is the best way,
pbuf_chain to do the same but just point the newBuf->payload at the data
without copying it!!
eg
newBuf = pbuf_alloc( PBUF_TRANSPORT,
1324, PBUF_RAM);
while( bytesToSend)
{
newBuf->payload =
currentBufferPointer;
udp_send( outUdp,
newBuf);
currentBufferPointer +=
1324;
bytesToSend -= 1324;
}
pbuf_free( newBuf);
joolz