Skip to content

Commit 0a281a3

Browse files
committed
auto-free block when udp-packet is read entirely
1 parent 160df53 commit 0a281a3

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

UIPUdp.cpp

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -263,8 +263,14 @@ UIPUDP::read(unsigned char* buffer, size_t len)
263263
UIPEthernetClass::tick();
264264
if (appdata.packet_in != NOBLOCK)
265265
{
266-
int read = UIPEthernetClass::network.readPacket(appdata.packet_in,0,buffer,len);
267-
UIPEthernetClass::network.resizeBlock(appdata.packet_in,read);
266+
memaddress read = UIPEthernetClass::network.readPacket(appdata.packet_in,0,buffer,len);
267+
if (read == UIPEthernetClass::network.blockSize(appdata.packet_in))
268+
{
269+
UIPEthernetClass::network.freeBlock(appdata.packet_in);
270+
appdata.packet_in = NOBLOCK;
271+
}
272+
else
273+
UIPEthernetClass::network.resizeBlock(appdata.packet_in,read);
268274
return read;
269275
}
270276
return 0;

0 commit comments

Comments
 (0)