At 19:31 2002-12-23 -0800, you wrote:
I'm getting a strange error from the emulator that I haven't seen before.
Does anybody know what I might be doing at the application level to cause this?
"... just changed emulated program counter to ___. This address is invalid
because it is not even". And indeed, the address ends in 'f'.
This is really odd :)
Thanks,
</edg>
Here's the function:
MemHandle PvtGetPrefEntry(UInt32 appFileCreator, UInt16 appPrefID, Boolean
saved)
{
UInt16 uwPrefLength = 0;
Int16 wPrefReturnValue;
MemHandle h;
MemPtr p;
wPrefReturnValue=
PrefGetAppPreferences(appFileCreator, appPrefID, NULL,
&uwPrefLength, saved);
if((uwPrefLength) && (wPrefReturnValue != noPreferenceFound)) {
ErrFatalDisplayIf(((h=MemHandleNew(uwPrefLength))==0),
"Cannot allocate memory");
ErrFatalDisplayIf(((p=MemHandleLock(h)) == NULL),
"Cannot lock memory");
if (PrefGetAppPreferences(appFileCreator, appPrefID,
&p, &uwPrefLength, saved) != noPreferenceFound) {
MemHandleUnlock(h);
return h;
} else {
MemHandleUnlock(h);
MemHandleFree(h);
return 0;
}
}
return 0;
}
Your problem is that you pass the address of p to PrefGetAppPreferences
rather than the value of p. The OS is retrieving the prefs and storing it
on the stack, which is overwriting your return address. You try to return
to the caller, there's an invalid program counter, and you get that errror.
This happens on the SECOND call to PvtGetPrefEntry:
hUserID = PvtGetPrefEntry(appFileCreator, prefUserID, true); //
this one succeeds
hServer = PvtGetPrefEntry(appFileCreator, prefServer, true); //
this one fails
hPassword = PvtGetPrefEntry(appFileCreator, prefPassword, false);
--
For information on using the Palm Developer Forums, or to unsubscribe,
please see http://www.palmos.com/dev/support/forums/
--
For information on using the Palm Developer Forums, or to unsubscribe, please see http://www.palmos.com/dev/support/forums/