On Sun, Dec 02, 2007 at 07:42:17PM +0100, Peter Kümmel wrote: >>> --- lyx-devel/trunk/src/support/environment.cpp (original) >>> +++ lyx-devel/trunk/src/support/environment.cpp Sat Dec 1 11:52:52 2007 >>> @@ -18,6 +18,7 @@ >>> #include "support/os.h" >>> #include <boost/tokenizer.hpp> >>> +#include <boost/shared_array.hpp> >>> #include <cstdlib> >>> #include <map> >>> @@ -65,22 +66,17 @@ >>> string const encoded = to_local8bit(from_utf8(value)); >>> #if defined (HAVE_SETENV) >>> return ::setenv(name.c_str(), encoded.c_str(), true); >>> - >>> #elif defined (HAVE_PUTENV) >>> - static std::map<string, char *> varmap; >>> + static std::map<string, boost::shared_array<char> > varmap; >>> string envstr = name + '=' + encoded; >>> - char * newptr = new char[envstr.size() + 1]; >>> - envstr.copy(newptr, envstr.length()); >>> - newptr[envstr.length()] = '\0'; >>> - int const retval = ::putenv(newptr); >>> + boost::shared_array<char> newptr(new char[envstr.size() + 1]); >>> + envstr.copy(newptr.get(), envstr.length()); >>> + newptr.get()[envstr.length()] = '\0'; >>> + bool const retval = ::putenv(newptr.get()) == 0; >> Out of curiosity: Is that conceptionally different from a std::string? >> Andre' > > I also wondered why std::string is not used, but I wanna touch this > function > as little as possible, maybe there was a good (?) reason not to use > std::string.
Probably because the code originally was plain C, not C++. Just guessing. Andre'