void AddAddr(address) unsigned char *address; { extern unsigned char *Addr[]; extern short int AddrCnt; int i; /* If it's the first address we just add it. */ if (AddrCnt == 0) Addr[AddrCnt++] = address; else { /* If there are already 100 addresses we can't process any more so we'll just return. */ if (AddrCnt == 100) return; /* We'll compare the new address against each one in the list until we find the appropriate place to insert it. */ for (i = 0; i < AddrCnt; i++) { /* If the new address is smaller than the current address in the array we'll insert the new one at this position. */ if (address < Addr[i]) { /* We need a temporary loop counter so we can move all the array entries from the current one to the end down one position to make room for the new address. */ int j; for (j = AddrCnt; j > i; j--) Addr[j] = Addr[j-1]; Addr[i] = address; AddrCnt++; break; } /* If the address is already in the list we'll skip it. */ if (address == Addr[i]) break; } /* If the new address is higher than the last one on the list we'll add it to the end of the array. */ if (address > Addr[AddrCnt-1]) Addr[AddrCnt++] = address; return; } }