Greetings
I am having difficulty unpacking records from my palm database. some attempts it
just fails quietly, other attempts it crashes, complaining about reading from
low memory (addresses below 256). I do not see what I am doing different than in
the example(s) in the Palm OS Bible and the N Rhodes books and my other program
that has a similar structure (only it works fine).
does pretty much the same thing using Cygwin or Linux, I tried both.
Here is the definition of the record I am trying to read:
typedef struct _packedcoderecord {
Char code[1]; /* primary key, quicksorted after thawing */
Char desc[1];
Char mesg[1];
} PackedCodeRecord;
typedef struct _coderecord {
Char *code;
Char *desc;
Char *mesg;
} CodeRecord;
//Here is the code snippet where I retrieve the MemHandle:
numFacRecords = DmNumRecords(FacDB);
while ( ( i < (numFacRecords - 1 ) ) && ( i < (dmRecNumCategories - 1) ) ){
recordH = DmQueryRecord( FacDB, i );
if ( recordH ){
pacFacRecord = MemHandleLock( recordH );
// pacFacRecord->code works okay here in the debugger
unPackCodeRecord( facRecord, pacFacRecord );
StrNCopy( CategoryList[i], facRecord->desc,dmCategoryLength-1);
MemHandleUnlock( recordH );
}
i++;
}
StrCopy( CategoryList[i], "Unfiled" );
// Here Be Monsters
Err unPackCodeRecord( CodeRecord *Code, const PackedCodeRecord *pcode ) {
Char *s = pcode->code; // s works
// Code->code|desc|mesg none of them end up with anything
// but the s variable steps through okay
Code->code = s; // also tried: Code->code = (Char *) s;
s += StrLen(s) + 1; // pose complains about writing low memory
Code->desc = s;
s += StrLen(s) + 1;
Code->mesg = s;
return errNone;
}
Thanks in advance.
David Martin
--
For information on using the Palm Developer Forums, or to unsubscribe, please see
http://www.palmos.com/dev/support/forums/