make find_uint_array() never create negative indices
This commit is contained in:
parent
01348f6f7c
commit
e334eb3580
|
@ -549,8 +549,8 @@ sort_uint_array( uint_array_t array )
|
||||||
int
|
int
|
||||||
find_uint_array( uint_array_t array, uint value )
|
find_uint_array( uint_array_t array, uint value )
|
||||||
{
|
{
|
||||||
int bot = 0, top = array.size - 1;
|
int bot = 0, top = array.size;
|
||||||
while (bot <= top) {
|
while (bot < top) {
|
||||||
int i = (bot + top) / 2;
|
int i = (bot + top) / 2;
|
||||||
uint elt = array.data[i];
|
uint elt = array.data[i];
|
||||||
if (elt == value)
|
if (elt == value)
|
||||||
|
@ -558,7 +558,7 @@ find_uint_array( uint_array_t array, uint value )
|
||||||
if (elt < value)
|
if (elt < value)
|
||||||
bot = i + 1;
|
bot = i + 1;
|
||||||
else
|
else
|
||||||
top = i - 1;
|
top = i;
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user