Hi all,
Are there any known problems with FtrPtrResize in PalmOS 3.1. In my program
it acts very strange - it increments the lock count of the chunk and even
overlocks it. It happens only when the chunk grows and has to be moved (of
course not every time). I have got the lock count of the chunk with
MemHandleLockCount before and after the resizing and received results like
these:
1 -> 8
8 -> 6
6 -> 1
1 -> 7
I have tryed to solve the problem by manually unlocking the chunk before and
after the resizing, but that didn't help - the gremlin still crashes the
program at the same step. Apparently FtrPtrResize has locked the chunk more
then 13 times.
The same code works fine on OS greater then 3.1. The lock count remains
always 1.
Here is the code:
static void ExtAddToPrevios(Char* word)
{
UInt16* prevs;
FtrGet(appFileCreator, appFtrAlreadyPredicted, (UInt32*)&prevs);
UInt16 sz[2] = {*prevs, *(prevs + 1)};
UInt16 strln = (UInt16)StrLen(word) + 1;
MemHandle h = MemPtrRecoverHandle(prevs);
UInt16 l1 = MemHandleLockCount(h);
#ifdef DEBUG
UInt16* prv1 = prevs;
#endif
for(; l1 > 1; l1--)
MemHandleUnlock(h);
UInt32 size = sz[0] + strln;
{
HostFILEType* fp = HostFOpen("C:\\Windows\\Desktop\\prevs.txt", "a+t");
HostFPrintF(fp, "Current size: %ld\n", size);
HostFClose(fp);
}
FtrPtrResize(appFileCreator, appFtrAlreadyPredicted, size,
(void **)&prevs);
h = MemPtrRecoverHandle(prevs);
UInt16 l2 = MemHandleLockCount(h);
#ifdef DEBUG
if(l1 != l2)
{
HostFILEType* fp = HostFOpen("C:\\Windows\\Desktop\\prevs.txt", "a+t");
HostFPrintF(fp, "Current word: %s\n", word);
HostFPrintF(fp, "before: %d\n", l1);
HostFPrintF(fp, "after: %d\n", l2);
if(prv1 != prevs)
HostFPutS("MOVED!!!!!!!!!!\n", fp);
else
HostFPutS("NOT MOVED!!!!!!!!!!\n", fp);
HostFClose(fp);
}
#endif
for(; l2 > 1; l2--)
MemHandleUnlock(h);
DmWrite(prevs, sz[0], word, strln);
sz[0] += strln;
sz[1]++;
DmWrite(prevs, 0, sz, sizeof(UInt32));
}
Any help is appretiated.
Cheers
--
For information on using the Palm Developer Forums, or to unsubscribe, please see
http://www.palmos.com/dev/support/forums/