Hi All,
        Is there anything wrong with this code?  When I run this 
using Codewarrior (I believe it's R6) and the Emulator (3.0a6, 3.3V 
or 3.1V Debug ROM), the debugger activated during DmResizeRecord and 
pops up a dialog box with some random characters in it.  Is there 
something wrong with my code or is there a problem with the 
emulator/codewarrior/palm os?

// Create/Open the DB
theDataRef = DmOpenDatabaseByTypeCreator('pict', 'pTCP', 
dmModeReadWrite | dmModeExclusive);
if(!theDataRef)
{
        err = DmGetLastErr();

        if(err && err != dmErrDatabaseOpen)
                err = DmCreateDatabase(0, "PictData", 'pTCP', 'pict', false);

        err = 0;
        theDataRef = DmOpenDatabaseByTypeCreator('pict', 'pTCP', 
dmModeReadWrite | dmModeExclusive);
        if(!theDataRef)
        {
                err = DmGetLastErr();
                ErrFatalDisplay("Database open/create error");
        }
}

// Create a new record
theRecordIndex = dmMaxRecordIndex;
thePictHand = DmNewRecord(theDataRef, &theRecordIndex, theDataMaxSize);
ErrFatalDisplayIf(!thePictHand, "Error creating record");

// Put data in the record
thePictPtr = MemHandleLock(thePictHand);

while(theDataSize > 0)
{
        theDataSize = NetLibDmReceive(AppNetRefnum, sock, thePictPtr, 
theDataPos, 512, netIOFlagOutOfBand, NULL, NULL, 0, &err);
        theFullDataSize = theFullDataSize + theDataSize;
        theDataPos = theDataPos + theDataSize;
        if(theDataPos >= theDataMaxSize)
        {
                theDataMaxSize = theDataMaxSize * 2;
                MemHandleUnlock(thePictHand);
                // Crashes (?) during next line...
                DmResizeRecord(thePictHand, theRecordIndex, theDataMaxSize);
                ErrFatalDisplayIf(!thePictHand, "Error resizeing record");
                thePictPtr = MemHandleLock(thePictHand);
        }
}

MemHandleUnlock(thePictHand);


        Thanks in advance,
                Michael Sealand
                BayNet World, Inc.

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

Reply via email to