From: Tomas Frydrych (tomas_at_frydrych.uklinux.net)
Date: Fri Apr 09 2004 - 16:02:40 EDT
> Again, the solution is to not use the .c_str() or
> .utf8_str() functions in these cases. Or if you do,
> you must really store the returned value.
>
> We are not returning a true temporary value from the
> function. The function returns an instance of a class,
> complete with copy constructors and assignment
> operators.
How un-temporary is that? That instance ceases to exist virtually at
the point at which the function returns; the operators are exactly as
usefull as the utf8_str() function. Since we have to make a copy of
that instance to be able to use it, it makes very little sense in
this case to create the object in the first place. We would be better
advised to return char *.
> Problems like these can be found easily enough using
> Valgrind, Purify, grep, or 5 seconds staring at the
> code.
If you know the bug is there and where it is; the fact is that this
has obviously lived in the code for a while going undetected, and it
is this that bothers me. I accept that using static varibable might
not be best solution, but problem is directly caused by the API.
So, my proposal is to remove UT_String getValue() and change the
other to char * getValueUTF8().
Tomas
This archive was generated by hypermail 2.1.4 : Fri Apr 09 2004 - 16:05:20 EDT