At 5:08 PM +0100 21-01-00, Thomas Ward wrote:
>1. You say the old version had "several bugs". What other bugs am I likely
>to encounter?
I don't remember exactly, sorry. But, I think the old version would
occasionally return a result that was past the end of the array, so in your
case if you tried to do pp_array[searchpos].id you could be dereferencing
invalid memory. Also, I think it called the search function at times with
an array position that was past the end of the array, so your search
function could reference invalid memory. I believe there was also a
problem if the array passed had length 0.
As to why there's no mention in the documentation... I don't know! That's
a good point though.
I can understand you're wanting to use the OS routine, and if what you're
doing has been working, then that's good for you and you should be fine.
If you're only writing code for newer OSs (and I note that 3.3 is a free
upgrade to 3.0 devices), then you don't have to worry about it.
However, the binary search implementation I sent isn't really very big, and
if you customize it you can both make it smaller and make it faster. So,
you might think twice about writing your own... especially if you want to
run on older OS releases.
--Bob