Hi All,
I have problem understanding why data in rec gets changed in following function.
What it does is simple, write data from record rec to the record handle recordH.
While doing DmStrCopy, some data in the record gets changed. I don't understand
why. I am not sure if this was caused by the available dynamic memory. Thank
you in advance.
void PackFrpFacility(FrpFacility* rec, MemHandle recordH)
{
UInt16 length = 0;
char* s;
UInt16 strLen = 0;
UInt16 index;
length = sizeof(rec->frp_id) + sizeof(rec->frp_facility_id);
for (index = 0; index < frp_facilityCount; index++)
length += StrLen(rec->Data[index]);
length += frp_facilityCount; //number of string fields
if (MemHandleResize(recordH, length) == 0) {
s = MemHandleLock(recordH);
DmWrite(s, OffsetOf(FrpFacilityPacked, frp_id), (char*) &rec->frp_id,
sizeof(rec->frp_id) );
DmWrite(s, OffsetOf(FrpFacilityPacked, frp_facility_id), (char*)
&rec->frp_facility_id, sizeof(rec->frp_facility_id) );
for (index = 0; index < frp_facilityCount; index++) {
DmStrCopy(s, OffsetOf(FrpFacilityPacked, Data) + strLen,
rec->Data[index]);
strLen += StrLen(rec->Data[index]) + 1;
}
MemHandleUnlock(recordH);
}
}
--
For information on using the Palm Developer Forums, or to unsubscribe, please see
http://www.palmos.com/dev/tech/support/forums/