> From: Remo Hofer
>
> Could you please comment the following function:
>
> void UpdateControl(FormPtr f, UInt16 id, Char * s) {
>     ControlType *ctl;
>     Char        *label;
>
>     ctl = FrmGetObjectPtr(f, FrmGetObjectIndex(f, id));
>     label = (Char *) CtlGetLabel(ctl);
>     StrCopy(label, s);
>     CtlSetLabel(ctl, label);
> }

label is a stack-based (local) variable in the function UpdateControl.  As
soon as you exit UpdateControl, it's contents may change.  This is not a
good way to change the label of a control which will probably outlive the
function call.


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