Well on what line does it crash? Have you tried the debugger? Also, what
exactly does GetFieldData do?

> -----Original Message-----
> From: [EMAIL PROTECTED] [mailto:bounce-449040-
> [EMAIL PROTECTED] On Behalf Of druid
> Sent: Monday, July 18, 2005 7:34 PM
> To: Palm Developer Forum
> Subject: Crash if I click button twice
> 
> this code will crash If I click the save button twice
> I must not be releasing some memory somewhere
> 
> 
> static Boolean frmMain_saveButton_OnSelect(EventPtr event)
> {
>  Char name[256];
>  Char level[256];
>  Char expFld[256];
>  Char desc[256];
>  FormType *frmP;
> 
>  ControlType *ctlP;
>  Char *labela;
>  Char labelb[256];
> 
>  frmP = FrmGetActiveForm();
> 
>  ctlP = FrmGetObjectPtr( frmP, FrmGetObjectIndex( frmP, frmPopupTrig1
) );
>  labela = (Char *)CtlGetLabel( ctlP );
>  StrCopy(expFld, (const char *)labela);
> 
>  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:
> 
> 
>    GetFieldData( fldName, name );
>    GetFieldData( fldLevel, level );
>    GetFieldData( fldNewDesc, desc );
> 
>    size = StrLen(name)+1+ StrLen(level)+1+ StrLen(expFld)+1+
> StrLen(desc)+1;
>    index = dmMaxRecordIndex;
> 
>    h = DmNewRecord(dbPtr, &index, size);
>    ptr = MemHandleLock(h);
>    Offset = 0;
>    DmWrite(ptr, Offset, (const void *)name, StrLen(name)+1);
>    Offset += StrLen(name)+1;
>    DmWrite(ptr, Offset, (const void *)level, StrLen(level)+1);
>    Offset += StrLen(level)+1;
>    DmWrite(ptr, Offset, (const void *)expFld, StrLen(expFld)+1);
>    Offset += StrLen(expFld)+1;
>    DmWrite(ptr, Offset, (const void *)desc, StrLen(desc)+1);
>    MemHandleUnlock(h);
>    DmReleaseRecord(dbPtr, index, true);
>    err = DmCloseDatabase(dbPtr);
>   return true;
> }
> 
> --
> 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