corrected byte order during access to sorted array

This commit is contained in:
Waldemar Porscha 2022-10-19 20:36:03 +02:00
parent f9f9914130
commit c56182a80f

View File

@ -38,7 +38,6 @@ uint16_t AddressTableObject::getTsap(uint16_t addr)
{
uint16_t size = entryCount();
#ifdef USE_BINSEARCH
addr = htons(addr);
uint16_t low,high,i;
low = 1;
@ -47,9 +46,10 @@ uint16_t AddressTableObject::getTsap(uint16_t addr)
while(low <= high)
{
i = (low+high)/2;
if (_groupAddresses[i] == addr)
uint16_t ga = ntohs(_groupAddresses[i]);
if (ga == addr)
return i;
if(addr < _groupAddresses[i])
if(addr < ga)
high = i - 1;
else
low = i + 1 ;