[mythtv] API suggestions
renchi at pooh.tam.uiuc.edu
Fri Feb 6 14:49:31 EST 2004
On Fri, 6 Feb 2004, Henrik (Mauritz) Johnson wrote:
> Renchi Raju wrote:
> >"const QString& function()" never hurts. in fact i would recommend it over
> >just plain "QString function()"
> I beg to differ. Take the current example:
> const QString &returnString(void)
> return "Here we go much to fast. Watch out boy were gonna craash.";
> This will result in corrupted stack and a crash three function calls
> later and a couple of hours debugging. Still, sometimes it's ok as long
> as the returned string isn't garbage collected on return from the
> function but then were back to "you are very sure of what you are doing".
this is just plain stupid and should have been obvious. you created
something on the stack and returned it by reference. if it wasn't obvious
i was referring to returning a const reference to a member data.
More information about the mythtv-dev