433 return size; |
433 return size; |
434 } else if (result == 0) { |
434 } else if (result == 0) { |
435 return 0; |
435 return 0; |
436 } |
436 } |
437 |
437 |
|
438 // special case: there is only one element and that is smaller |
|
439 if (size == 1) return 0; |
|
440 |
438 // check the last array element |
441 // check the last array element |
439 result = cmp_func(elem, array + elem_size * (size - 1)); |
442 result = cmp_func(elem, array + elem_size * (size - 1)); |
440 if (result >= 0) { |
443 if (result >= 0) { |
441 return size - 1; |
444 return size - 1; |
442 } |
445 } |