Thanks for the quick reply, Ben--and the pointer about using the register
view.  That's a new one for me. Sure enough, I can see the A6 register being
overwritten when I step over that call.  I'm not sure why my 6 byte buffer
was overflowing since there were only 5 bytes (including the null) in the
string but when I "do the right thing" and use timeStringLength as the
buffer size, all is well.

Thanks big guy! :)
David

----- Original Message ----- 
From: "David Beers" <[EMAIL PROTECTED]>
To: "David Beers" <[EMAIL PROTECTED]>
Sent: Thursday, August 21, 2003 4:14 PM
Subject: bus error when table custom draw routine is modularized


> At 04:42 PM 8/21/2003, David Beers wrote:
> >I've got a custom drawing routine for an item in a table that need to
draw
> >quite a bit of stuff, so I thought I'd modularize the code into some
> >different drawing functions. In the process, some calls to the following
> >conversion function were moved from the table callback out to the drawing
> >functions. This function didn't cause problems when it was called from
> >inside the callback routine, but if it's called from the drawing
functions
> >I get a bus error when the calling function returns control to the table
> >callback routine.
>
> OK, so here's a quick idea.  Set a breakpoint on the call to this
> SecondsToString
> function.  Bring up the register view, click on A7 (the stack pointer),
> then do Debug/View Data in the CW debugger.  This will show you your
> stack.  Step over the function.  Since the caller defines
>
> Char strTime[6];
>
> I bet TimeToAscii is writing more than five characters and a NUL and is
> overwriting the return address.  It may not have been a problem in your
> original code due to having more variables on the stack.  There is a
reason
> why DateTime.h defines
>
> #define timeStringLength                9
>
> You should be sure to use that value as the minimum length of a buffer you
> pass to TimeToAscii.
>
> -- 
> Ben Combee <[EMAIL PROTECTED]>
> CodeWarrior for Palm OS technical lead
> Palm OS programming help @ www.palmoswerks.com
>
>


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

Reply via email to