At 01:42 AM 4/20/2004, you wrote:
Hello folks,

I think there is a bug in the API function StrNCompare in PalmOS5. When I use the function with a very long string to compare (several KB long), it fails. That means it does not return 0 where it should.

The strange thing is that I give a very small n value to compare, something like n=6, because the token to compare to is 6 Bytes long. So the function only has to process the first 6 Bytes at most, and it should not matter whether the string is ten or ten thousand bytes long. Also, the function does not need any memory allocation that could fail.

Yes, the strings are all null-terminated. My routine that needs the StrNCompare works perfectly in most of the cases. We have written our own implementation of StrNCompare and it works fine. But our own function is not ARM-optimised, and we prefer native API calls. I have not made any checks yet to determine the size limitation when it starts to fail.

Could you try recoding this as a call to TxtCompare? StrNCompare uses this internally, and the call to TxtCompare should be faster than StrNCompare if you know that you're dealing with a single-byte string.


I just did a quick look at the code, and the only way that I could see if failing would be if your long string had something that looked like a multibyte character in it.

-- Ben Combee, senior DTS engineer, PalmSource, Inc.
   Read "Combee on Palm OS" at http://palmos.combee.net/


-- For information on using the Palm Developer Forums, or to unsubscribe, please see http://www.palmos.com/dev/support/forums/

Reply via email to