> >> Your string goes out of scope as soon as the function returns [..]
> 
>       Another way to fix it might be to change the return type of
>       GetCountString() from "const char*" to "string",
>       and change the value() call to
>       countOutp->value(GetCountString().c_str()).
> 
>       The lifetime of the temporary string will then live
>       long enough through the return of the function to
>       reach value() before it gets deallocated.
> 
>       Assuming value() makes an internal copy of the string,
>       all should be good, and this avoids the need for a
>       reentry-unsafe static variable in the function.

Yup - like that.

Or, as another option, pass in a buffer (and a size) to your
GetCountString() function for it to use - that's a kinda traditonal *nix
way of handling this I guess...

SELEX Galileo Ltd
Registered Office: Sigma House, Christopher Martin Road, Basildon, Essex SS14 
3EL
A company registered in England & Wales.  Company no. 02426132
********************************************************************
This email and any attachments are confidential to the intended
recipient and may also be privileged. If you are not the intended
recipient please delete it from your system and notify the sender.
You should not copy it or use it for any purpose nor disclose or
distribute its contents to any other person.
********************************************************************

_______________________________________________
fltk mailing list
[email protected]
http://lists.easysw.com/mailman/listinfo/fltk

Reply via email to