This is the expected behavior.  The function accepts "strings" as parameters. A
"string" is a sequence of characters terminated by a NULL.

-- Keith






"Ji Lee" <[EMAIL PROTECTED]> on 03/20/2001 06:49:33 PM

Please respond to "Palm Developer Forum" <[EMAIL PROTECTED]>

Sent by:  "Ji Lee" <[EMAIL PROTECTED]>


To:   "Palm Developer Forum" <[EMAIL PROTECTED]>
cc:    (Keith Rollin/US/PALM)
Subject:  StrNCompare & PalmOS4



Hi,

I have just ran into problem where if I am comparing two NON null terminated
string,
StrNCompare will cause crash (I could verify this only on OS4 DR4 rom
image..)
Here is a code sample:

    Char* test1 = (Char*)MemPtrNew ( 4 );
    Char* test2 = (Char*)MemPtrNew ( 4 );
    test1[0] = 1;
    test1[1] = 1;
    test1[2] = 1;
    test1[3] = 1;
    test2[0] = 1;
    test2[1] = 1;
    test2[2] = 1;
    test2[3] = 1;

    StrNCompare ( test1, test2, 4 );

This code crashes and from the stack, it looks like StrNCompare is calling
StrLen
internally. (I am not 100% sure.. that was as far as I could tell from CW
debugger.)

I can currently getting around this problem by using "StrNCompareAscii",
which doesn't
suffer from this problem.

My question is whether this is expected behavior. If not, is it fixed on DR5
image?

Thanks

-Ji





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

Reply via email to