In your call to MemMove, you're not copying the terminating NULL character.
Thus, you iterate off the end of the block you allocated.
By the way, why are you allocating a Handle and copying the string into it? Why
not work directly on pszRecord? After all, you're not modifying it; just
reading it.
-- Keith
Ralph Krausse <[EMAIL PROTECTED]> on 06/22/2000 06:43:11 AM
Please respond to "Palm Developer Forum" <[EMAIL PROTECTED]>
Sent by: Ralph Krausse <[EMAIL PROTECTED]>
To: "Palm Developer Forum" <[EMAIL PROTECTED]>
cc: (Keith Rollin/HQ/3Com)
Subject: Can anyone see anything wrong with this?
All I am doing is getting a record from a database, putting it into a
string, counting and then want to chop it off a wTotalCount, but it keeps on
blowing up..
thanks
Ralph Krausse
*********************************************************
Word CListObject::_GetStringLastPos(CharPtr pszRecord)
{
VoidHand vHandle = MemHandleNew(StrLen(pszRecord) + 1);
CharPtr pNextChar = (CharPtr)MemHandleLock(vHandle);
MemMove(pNextChar,pszRecord,StrLen(pszRecord));
int wTotalCount = 0;
for(;*pNextChar;pNextChar++)
{
if(*pNextChar == '\"' && *(pNextChar + 1) == ',' &&
*(pNextChar + 2) == '\"')
{
break;
}
wTotalCount++;
}
MemHandleUnlock(vHandle);
MemHandleFree(vHandle);
return wTotalCount;
}
--
For information on using the Palm Developer Forums, or to unsubscribe, please
see http://www.palmos.com/dev/tech/support/forums/
--
For information on using the Palm Developer Forums, or to unsubscribe, please see
http://www.palmos.com/dev/tech/support/forums/