[EMAIL PROTECTED] wrote in message <[EMAIL PROTECTED]>... > > > >I didn't miss the extra one. Just look at the line followed the FOR statement, >which adds number of char* fields to variable length.
Ok, I see that ... it isn't obvious why you're adding "frp_facilityCount" to the length until it's explained. I'd change the comment there... >I don't have the problem if I do a DmRecordNew() and Pack new data to the >record. The problem only exists when trying to update the old data with new >data in the record. Hmmm.... I really don't see how that could affect the data in "rec" ... I mean that's a "const char *" param, it's not supposed to get changed. It's really data in the incomming struct "rec" that's being munged, and not data in the database record referred to by "recordH" and "s"? 'tis a puzzlement. > >-Elizabeth > btw: do you really need to include those huge "ascii art" header blocks? They really take up a lot of room for information that is already contained in the msg headers... > >|--------+-----------------------> >| | [EMAIL PROTECTED]| >| | uch.com | >| | | >| | 10/02/00 | >| | 04:23 PM | >| | Please | >| | respond to | >| | palm-dev-foru| >| | m | >| | | >|--------+-----------------------> > >-----------------------------------------------------------| > | | > | To: palm-dev-forum@news.palmos.com | > | cc: | > | Subject: Re: Data Moving Problem | > >-----------------------------------------------------------| > > > > > >I'm a little concerned about that > length += StrLen(rec->Data[index]); > >I -assume- that DmStrCopy() will write a terminating NUL char, which >means that your length should be StrLen(rec->Data[index])+1; Right >now the memhandle you are allocating will be short by one byte per >string. > >[EMAIL PROTECTED] wrote in message <[EMAIL PROTECTED]>... >> >> >> >>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; file://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); >> } >>} >> -- -Richard M. Hartman [EMAIL PROTECTED] 186,000 mi/sec: not just a good idea, it's the LAW! -- For information on using the ACCESS Developer Forums, or to unsubscribe, please see http://www.access-company.com/developers/forums/