I have the following code:

skelACWorkDBType       findRecord, r;  // where this is the database
structure

...
r.TimeH = (record->TimeH);
r.TimeM = (record->TimeM);
r.TimeS = (record->TimeS);
...

MemPtr p = MemHandleLock(h);
Err err = DmWrite(p, 0, &r, sizeof(r));

Now - I have this all over the place... and in only one instance and
only on a Treo/T|T/T|5 will this give me a DmWriteCheck Crash Error
(dmErrWriteOutOfBounds).  This problem does not occur on the Palm
Emulators at all (debug or release).

When I replaced

Err err = DmWrite(p, 0, &r, sizeof(r));

with Err err = DmWrite(p, 0, &r, sizeof(skelACWorkDBType));

the problem goes away.  Now looking at this, this should be the correct
way to do it - so the question is why would the former work everywhere else?


Now the interesting thing is that new records created after this code
change don't fail, but old records do.

I added the following code:

if (DmWriteCheck(p, 0, sizeof(skelACWorkDBType)) == errNone)
                    error = DmWrite(p, 0, &r, sizeof(skelACWorkDBType));
                else {
                    MemHandle hTmp = DmResizeRecord (gACCatDB,
gAEROBICINDEX, sizeof(skelACWorkDBType));
                    MemPtr pTmp = (skelACCatDBType*)
MemHandleLock(hTmp);
                    error = DmWrite(pTmp, 0, &r, sizeof(skelACWorkDBType));
                    MemPtrUnlock(pTmp);
                }
                MemPtrUnlock(p);
                DmReleaseRecord(gACWorkDB, gAEROBICINDEX, true);

Sure enough, it fails on the DmWriteCheck and moves to the else
statement (even though the sizes are the same (154 bytes - as I am not
using packed records).  It resiszes the record, writes the data to the
record w/o error, but in this case, the changes are not saved to the record.

Any ideas?

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

Reply via email to