I can see a several things wrong with this code.  I don't know which 
(if any) would lead to a bus error (possibly the third one):

* When calling UnpackReminder, you lock h, but you don't later unlock it.

* When calling DmWrite, you don't first resize h to have the same size as h2.

* DmWrite takes a pointer as the third parameter -- you're passing a 
handle.  I'm amazed that your compiler is not complaining about this!

-- Keith


At 7:44 PM -0600 12/11/01, Sean McMains wrote:
>I'm trying to save the results from a form with 2 fields in it into 
>my application's database. In the debugger, everything appears to be 
>working ok up until I get to the DmWrite call, when my app throws a 
>bus error in POSE.
>
>static void EditReminderFormSave()
>{
>       Reminder r;
>       MemHandle h, h2;
>       FieldType* fld;
>       UInt32 size;
>
>       // Get Record from DB
>       h = DmGetRecord( gDB, gCurrentRecord - 1 );
>       UnpackReminder( &r, MemHandleLock( h ) );
>
>       // put the text from the fields into the unpacked record
>       fld = GetObjectPtr( EditReminderButtonTextField );
>       r.buttonText = FldGetTextPtr( fld );
>       fld = GetObjectPtr( EditReminderReminderTextField );
>       r.reminderText = FldGetTextPtr( fld );
>
>       // pack the revised reminder into a new memory handle
>       h2 = MemHandleNew( 1 ); // PackReminder will resize the 
>handle appropriately
>       PackReminder( &r,  h2 );
>
>       // write the new packed record to the DB and release the record
>       size = MemHandleSize( h2 );
>       DmWrite( MemHandleLock( h ), 0, h2, size );
>       MemHandleUnlock( h );
>       DmReleaseRecord( gDB, gCurrentRecord - 1, true );
>}
>
>Can anyone give me a clue as to where this bus error is coming from? 
>Thanks in advance for any help!

-- 
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