[sldev] Uses of LLString and std::string ?

alissa_sabre at yahoo.co.jp alissa_sabre at yahoo.co.jp
Thu Jan 24 20:31:28 PST 2008


Thank you Lindens for much detailed explanations!

> So that's where we stand today, a bunch of code that relies on an almost  
> deprecated class.  In case anyone was still considering writing new code  
> that uses LLStrings...
> 
> I think it would make sense to complete the process by finding all char*  
> to LLString conversions and using ll_safe_string instead.

In short, the recommended uses of std::string and LLString *now* are,
in my understanding:

- New codes should use std::string and avoid LLSting as much as
  possible.  Use ll_safe_string() if you are converting from char *
  that can be a NULL.

- Replace LLString objects with std::string if you are modifying
  existing codes and the changes are straightforward, also using
  ll_safe_string().

- Code updates only to replace LLString is not desired for the moment,
  however.

- We can keep using static member functions of LLString.

Correct me if I'm wrong.

I have an additional comment.

I think there are two totally separate cases that a NULL pointer is
passed to LLString(char const *).  Case (1) is the programming
mistake, e.g., passing a NULL indicating an error to LLString(char
const *) without testing for a possibility of the error.  Case (2) is
the intended uses of a NULL as a _string_containing_nothing_.

Case (2) is fine, but the case (1) is a bug.  Even though
LLString(NULL) doesn't crash at that point, the program should have
tested the return value from the possibility of an error and should
behave appropriately.  I'm afraid simply going on with an emply string
makes the viewer instable...  Well, isn't it better that the viewer
crashes during the QA cycle, than that the viewer misbehave after the
release?  Blindly enclosing with ll_safe_string() can hide some
serious bugs...

Based on the consideration above, I suggest adding one more guideline:

- Explicitly test NULL pointer return from a function that indicates
  an error.  Don't use ll_safe_string() for the purpose.

How about this?

    Alissa Sabre
--------------------------------------
Easy + Joy + Powerful = Yahoo! Bookmarks x Toolbar
http://pr.mail.yahoo.co.jp/toolbar/


More information about the SLDev mailing list