Thank you for your reply;

Actually, i have ever done that like you said,but the error sill has 
occured,the error is "datamgr.c, Line:7394, DmWrite: DmWriteCheck failed";

Thanks in advance.



the codes:

static Err AddNewRecord(DmOpenRef dbP)
{
        Err     err = errNone;
        UInt16 u16Index = DmNumRecords (dbP);
        TestType testType;
        
        
        testType.testSubList = (TestSubType*)MemPtrNew (sizeof (TestSubType)*2);
        testType.name = (Char*)MemPtrNew (StrLen ("test a database") + 1);
        testType.path = (Char*)MemPtrNew (StrLen ("test path") + 1);
        
        if (testType.path == NULL || testType.name == NULL || 
testType.testSubList == NULL)
        {
                
                if (testType.path)
                {
                        MemPtrFree (testType.path);
                }
                if (testType.name)
                {
                        MemPtrFree (testType.name);
                }
                if (testType.testSubList)
                {
                        MemPtrFree (testType.testSubList);
                }
                
                return 1;
        }
        
        StrCopy (testType.name, "test a database");
        StrCopy (testType.path, "test path");
        
        testType.testSubList[0].dbCreator = 'test';
        testType.testSubList[0].dbType = 'appl';
        testType.testSubList[0].dbSize = 144111;
        
        
        testType.testSubList[1].dbCreator = 'test';
        testType.testSubList[1].dbType = 'appl';
        testType.testSubList[1].dbSize = 1444557;
        
        
        MemHandle recordH = DmNewRecord (dbP, &u16Index,  sizeof (testType));
        if (recordH == NULL)
        {
                return DmGetLastErr ();
        }
        
        
        TestType * testTypePtr = (TestType*)MemHandleLock (recordH);
        
        MemSet (testTypePtr, sizeof (testType), 0);

        //DmWrite (testTypePtr, 0, &testType, sizeof(testType));
        
          DmWrite (testTypePtr, NameStart, testType.name, StrLen 
(testType.name) );
          DmWrite (testTypePtr, PathStart, testType.path, StrLen 
(testType.path));
          DmWrite (testTypePtr, DbNumStart, &testType.dbNum, sizeof (UInt32));
          DmWrite (testTypePtr, TestSubListStart, testType.testSubList, sizeof 
(TestSubType));
        
        
        MemHandleUnlock (recordH);
        DmReleaseRecord (dbP, u16Index, true );
        
        return err;
}
 
-- 
For information on using the PalmSource Developer Forums, or to unsubscribe, 
please see http://www.palmos.com/dev/support/forums/

Reply via email to