On Wed 06 Jan 2016 at 14:04:10 +0100, Detlef Graef wrote: > Is this fix ok?
Disclaimer: I don't know the innards of Pan and I hardly ever use C++, but it looks like an improvement to me. Before, prefs_string is a StringView, which would be converted to a temporary std::string (when returning from the get_string() function) and then put into another StringView (and the temporary would get destroyed after use). I looked at how StringView is implemented, and basically it is just a slight wrapper around C strings, managing none of the memory allocations that std::string would. In particular, if you put a std::string into a StringView (as happened here before you fixed it), it would just point to the internal memory of std::string. And when that is cleaned up (which would happen here), then the StringView points at garbage. So keeping every step of the way in the StringView realm is definitely better. Whether the actual string storage is safe in the long term, I didn't look at, but presumably it is or more things would go wrong (probably). This pattern may occur in more places, of course... > Detlef Graef -Olaf. -- ___ Olaf 'Rhialto' Seibert -- The Doctor: No, 'eureka' is Greek for \X/ rhialto/at/xs4all.nl -- 'this bath is too hot.'
signature.asc
Description: PGP signature
_______________________________________________ Pan-users mailing list Pan-users@nongnu.org https://lists.nongnu.org/mailman/listinfo/pan-users