Hi,

I'm writing a hack, and I have a routine that gets called repeatedly in my
code, based on user action. It looks like this:

void process1( Int16 c, FieldPtr fld, Boolean label, ptr_t *p ) {
// do a bunch of stuff
   (void) process2((Int16) x, (Int16) y, FldGetTextPtr(fld), *p1, *p2, *p3);
// do a bunch more stuff
   }

The variables p1, p2, and p3 are just pointer types. (It shouldn't matter
what types they point to, right?). The prototype for process2 is:

Boolean process2(Int16 v1, Int16 v2, char *buffer, type1 *d1, type2 *d2,
type3* d3);

Process2 looks at the contents of the passed field, but does not try to
change it in any way.

The first several times that process1 is called, everything works fine.
However, on the 8th call, somehow, the value of fld is getting corrupted. If
I change the code for debugging to this:

void process1( Int16 c, FieldPtr fld, Boolean label, ptr_t *p ) {
   UInt16             field_id;

// do a bunch of stuff
   field_id = fld->id;
HostTraceOutputTL(appErrorClass, "before process2 fld id is %X", field_id);
   (void) process2((Int16) x, (Int16) y, FldGetTextPtr(fld), *p1, *p2, *p3);
HostTraceOutputTL(appErrorClass, "after process2 fld id is %X", field_id);
// do a bunch more stuff
   }

My debugging output is:

before process2 fld id is FA2
after process2 fld id is FA2

repeated 7 times, followed by:

before process2 fld id is FA2
after process2 fld id is A2

Somehow, the high byte (0F) is getting lost.

And now, for the really weird part.... If I use the actual value of fld->id
(instead of a temporary variable) in my debugging statements, like this:

void process1( Int16 c, FieldPtr fld, Boolean label, ptr_t *p ) {
// do a bunch of stuff
HostTraceOutputTL(appErrorClass, "before process2 fld id is %X", fld->id);
   (void) process2((Int16) x, (Int16) y, FldGetTextPtr(fld), *p1, *p2, *p3);
HostTraceOutputTL(appErrorClass, "after process2 fld id is %X", fld->id);
// do a bunch more stuff
   }

everything suddenly works like it should no matter how many times I call
process1!

I'm using GCC (Win98), and running this on the Emulator. I've tried several
different ROMs, including 3.3 and 3.5.

Does anyone have an idea what the heck is going on, or a suggestion as to
how I could go about figuring it out?

Thanks.

Tom


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