On Aug 21, 2008, at 11:48 PM, gbiggs wrote:
> As I recall, there is no guarantee that the strings returned by this
> function will be around for the life of the driver. You should
> be duplicating it somehow. Don't forget to check if the return value
> NULL before duplicating, too.
I don't think that this issue has been documented properly, but you
can assume that the const char* will remain valid for the duration of
execution. It points into a ConfigFile object that is declared
globally as a pointer, allocated before any drivers start up, and not
freed until all drivers have been shutdown. 
Regarding error-checking, you can only get NULL as a return value if
you supply NULL as the third argument, and the option that you're
looking for isn't supplied in the .cfg file (i.e., you say that NULL
is the default, and this default gets used).
The common pattern that Paul points out is safe to continue using.
 I've described how things work when using the Player server. This
is how almost everyone uses Player, but it's worth noting that if you
write your own application that links against libplayercore and
libplayerdrivers, you have to replicate this persistence of the
> Paul Osmialowski wrote:
>> Hello devels,
>> In few of my drivers and also in drivers written by others (e.g.
>> XSensMT.cc) there's a pointer to string declared inside of private
>> section of driver class like that:
>> const char* portName;
>> Later, in class constructor which takes pointer to configuration file
>> object as a parameter, we can notice such a code:
>> portName = cf->ReadString (section, "port", DEFAULT_PORT);
>> This portName field is later used by other driver methods expecting
>> that it contains valid pointer to an array of characters (a string).
>> My question is: is it assured by API spec, that configuration file
>> with all its ingredients (including char arrays) are kept forever
>> the end of Player Server process? If not, many drivers must be
>> to do deep copy of character arrays given by pointers returned by
>> ReadString() method.
> This SF.Net email is sponsored by the Moblin Your Move Developer's
> Build the coolest Linux based applications with Moblin SDK & win
> great prizes
> Grand prize is a trip for two to an Open Source event anywhere in
> the world
> Playerstage-developers mailing list