You don't show the return value from PackRecord, but you appear to be
skipping an offset in the DmWrite. Do you really want to do this? Are you
calculating the size of the record taking this (offset = size) into account?

Matt

----- Original Message -----
From: "Dan Dorton" <[EMAIL PROTECTED]>
To: "Palm Developer Forum" <[EMAIL PROTECTED]>
Sent: Saturday, May 18, 2002 12:42 PM
Subject: DmWriteCheck failed during DmWrite


I am getting this error in one of my packrecord functions.  I am hoping this
is a simple problem.  I have looked at this so closely and so long I can not
see the problem.

I am packing sub-objects/records into a packed record.  Before packing them,
I have the objects in a linked list.  The following portion of a packrecord
function walks the list and calls another packrecord function for each node
in the list.  The memory is already allocated, locked and passed to this
function.

I think the problem is somewhere in this function.  The variable pos should
keep track of where the where in the destination chunk the next sub-object
should be pack into.

UInt16 PackRecord(CRecipientNodePtr Head, void * pDest)
{
UInt16 offset = 0;
CRecipientNodePtr Cur = Head;
CRecipientType Recip = {0};
Char * pos;

CRecipientNodeListType Header = {0};

// Skip Header
offset += sizeof (CRecipientNodeListType);
pos = (Char *)pDest;
pos += offset;

while (Cur != NULL)
{
Header.Count++;
UnpackRecord(Cur->Recip, &Recip);

// the following line calls the packrecord function that has the error.
offset += PackRecord(&Recip, (CRecipientPackedPtr)pos);
pos += offset;

Cur = Cur->Next;
}


Here is the beginning of the packrecord function that is called from above.
While the error occurs in this function, I don't think the problem is in
this function as it works fine when called in other places.

UInt16 PackRecord(CRecipientPtr pSrc, CRecipientPackedPtr pDest)
UInt16 size;
UInt16 offset = 0;

pSrc->m_FieldFlags.m_ByFields = 0;

// Skip Field Flags
offset += sizeof(RecipientFieldFlags);

size = sizeof(AddressTargetTypeConstants);

// The error is happening on the following line
DmWrite(pDest, offset, &pSrc->m_Target, size);


Any help would be appreciated.

TIA,

-  Dan  :D

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




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

Reply via email to