I 've mark the link where error occurs and here 's the error and the code.
This is caused by trying to access the phtxt ... this error doesn't occur if
ptxt is less than 9 char.
Any idea y does this happen ? How do we manipulate String in palm...?
Error :
======
"test " just read directly from unallocated chunk of memory.
Code :
=====
Char *phtxt, *ptxt;
ptxt = "123456789";
clen = plen = StrLen(ptxt);
phandle = MemHandleNew(plen+1);
phtxt = (Char*) MemHandleLock(phandle);
hexdump(ptxt,phtxt,plen,phandle);
FrmCustomAlert(InfoAlert,"crypto() - 5",ptxt,NULL);
FrmCustomAlert(InfoAlert,"crypto() - 10",NULL,phtxt); <-- ERROR
MemHandleUnlock(phandle);
MemHandleFree(phandle);
static void hexdump(Char* stxt, Char* hextxt, Int16 slen, MemHandle
hexHandle)
{
MemHandle hhnd;
Char* htxt;
Int16 i;
if (!stxt) stxt="";
hhnd = MemHandleNew(slen ? 3*slen : 1);
htxt = MemHandleLock(hhnd);
for(i=0;i<slen;++i) {
htxt[3*i] = hs[((unsigned char)stxt[i])>>4];
htxt[3*i+1] = hs[((unsigned char)stxt[i])&15];
htxt[3*i+2] = ' ';
}
if (i) htxt[3*i-1] = '\0'; else htxt[0] = '\0';
MemHandleUnlock(hexHandle);
MemHandleResize(hexHandle,StrLen(htxt)+1);
hextxt = (Char *)MemHandleLock((MemHandle)hexHandle);
StrCopy(hextxt,htxt)
MemHandleUnlock(hhnd);
MemHandleFree(hhnd);
}
--
For information on using the Palm Developer Forums, or to unsubscribe, please see
http://www.palmos.com/dev/tech/support/forums/