Author: cgutman
Date: Fri Dec 2 06:55:05 2011
New Revision: 54561
URL:
http://svn.reactos.org/svn/reactos?rev=54561&view=rev
Log:
[LWIP]
- Save a bit of memory by changing the way pbufs are allocated for transmission
Modified:
trunk/reactos/lib/drivers/ip/transport/tcp/if.c
trunk/reactos/lib/drivers/lwip/src/rosip.c
Modified: trunk/reactos/lib/drivers/ip/transport/tcp/if.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/lib/drivers/ip/transport/t…
==============================================================================
--- trunk/reactos/lib/drivers/ip/transport/tcp/if.c [iso-8859-1] (original)
+++ trunk/reactos/lib/drivers/ip/transport/tcp/if.c [iso-8859-1] Fri Dec 2 06:55:05 2011
@@ -15,11 +15,9 @@
IP_PACKET Packet = { 0 };
IP_ADDRESS RemoteAddress, LocalAddress;
PIPv4_HEADER Header;
- UINT i;
- struct pbuf *p1;
-
+
/* The caller frees the pbuf struct */
-
+
if (((*(u8_t*)p->payload) & 0xF0) == 0x40)
{
Header = p->payload;
@@ -47,18 +45,17 @@
}
GetDataPtr(Packet.NdisPacket, 0, (PCHAR*)&Packet.Header,
&Packet.ContigSize);
-
- for (i = 0, p1 = p; i < p->tot_len; i += p1->len, p1 = p1->next)
- {
- ASSERT(p1);
- RtlCopyMemory(((PUCHAR)Packet.Header) + i, p1->payload, p1->len);
- }
-
+
+ ASSERT(p->tot_len == p->len);
+ ASSERT(Packet.ContigSize == p->len);
+
+ RtlCopyMemory(Packet.Header, p->payload, p->len);
+
Packet.HeaderSize = sizeof(IPv4_HEADER);
Packet.TotalSize = p->tot_len;
Packet.SrcAddr = LocalAddress;
Packet.DstAddr = RemoteAddress;
-
+
NdisStatus = IPSendDatagram(&Packet, NCE);
FreeNdisPacket(Packet.NdisPacket);
if (!NT_SUCCESS(NdisStatus))
Modified: trunk/reactos/lib/drivers/lwip/src/rosip.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/lib/drivers/lwip/src/rosip…
==============================================================================
--- trunk/reactos/lib/drivers/lwip/src/rosip.c [iso-8859-1] (original)
+++ trunk/reactos/lib/drivers/lwip/src/rosip.c [iso-8859-1] Fri Dec 2 06:55:05 2011
@@ -12,21 +12,19 @@
const void *const data,
const u32_t size)
{
- struct pbuf *p, *p1;
- u32_t i;
-
+ struct pbuf *p;
+
ASSERT(ifarg);
ASSERT(data);
ASSERT(size > 0);
- p = pbuf_alloc(PBUF_TRANSPORT, size, PBUF_POOL);
+ p = pbuf_alloc(PBUF_RAW, size, PBUF_RAM);
if (p)
{
- for (i = 0, p1 = p; i < size; i += p1->len, p1 = p1->next)
- {
- ASSERT(p1);
- RtlCopyMemory(p1->payload, ((PUCHAR)data) + i, p1->len);
- }
+ ASSERT(p->tot_len == p->len);
+ ASSERT(p->len == size);
+
+ RtlCopyMemory(p->payload, data, p->len);
((PNETIF)ifarg)->input(p, (PNETIF)ifarg);
}