You are not setting dbPtr back to NULL after closing the database, so the
second time through your Open() routine, the database is not reopened, dpPtr
remains pointing to garbage and Open() returns no error.

--------------------
Jeff Loucks
Work 425-284-1128 [EMAIL PROTECTED]
Home 253-851-8908 [EMAIL PROTECTED]
Mobile 253-691-8812


-----Original Message-----
From: druid [mailto:[EMAIL PROTECTED] 
Sent: Wednesday, August 10, 2005 7:32 PM
To: Palm Developer Forum
Subject: Re: Need some help determing what might be crashing this code


Here is the open routine

static Err Open(void)
{
        // Open the database or create it if it doesn't exist:
        if(dbPtr == NULL)
        {
                // First see if we can find it:
                LocalID dbID = DmFindDatabase(DB_CARDNO, DB_NAME);
                if(!dbID)
                {
                        // Couldn't find it, so create it:
                        Err err = DmCreateDatabase(DB_CARDNO, DB_NAME,
DB_CREATOR, DB_TYPE, false);
                        if(err)
                                return err;
                        // Now we ought to find it:
                        dbID = DmFindDatabase(DB_CARDNO, DB_NAME);
                        if(!dbID)
                                return 1;
                }
                // Found it, now open it:
                dbPtr = DmOpenDatabase(DB_CARDNO, dbID, dmModeReadWrite);
                if(dbPtr == NULL)
                        return 1;
        }
        // Everything went smoothly:
        return 0;
}


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

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

Reply via email to