lwip-users
[Top][All Lists]
Advanced

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

[lwip-users] Re: [lwip] Memory leak and queued packets in etharp.c


From: Jani Monoses
Subject: [lwip-users] Re: [lwip] Memory leak and queued packets in etharp.c
Date: Thu, 09 Jan 2003 00:29:36 -0000

> I think it can.
> 
> In case the ARP cache is full, and all entries are marked PENDING,
> find_arp_entry() will
> return ARP_TABLE_SIZE.

If they are all pending i will be ARP_TABLE_SIZE when exiting the first for 
then it enters the if.
So since none are stable j will remain 0 and i is assigned 0 and the first 
entry is discared.
j should be initialised to ARP_TABLE_SIZE instead of 0

static u8_t
find_arp_entry(void)
{
  u8_t i, j, maxtime;
  
  /* Try to find an unused entry in the ARP table. */
  for(i = 0; i < ARP_TABLE_SIZE; ++i) {
    if(arp_table[i].state == ETHARP_STATE_EMPTY) {
      break;
    }
  }
  
  /* If no unused entry is found, we try to find the oldest entry and
     throw it away. */
  if(i == ARP_TABLE_SIZE) {
    maxtime = 0;
+    j = ARP_TABLE_SIZE; 
-    j = 0;
    for(i = 0; i < ARP_TABLE_SIZE; ++i) {
      if(arp_table[i].state == ETHARP_STATE_STABLE &&
         ctime - arp_table[i].ctime > maxtime) {
        maxtime = ctime - arp_table[i].ctime;
        j = i;
      }
    }

    i = j; 
  }
  return i;
} 

[This message was sent through the lwip discussion list.]




reply via email to

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