-// Copyright (C) 2007-2021 CEA/DEN, EDF R&D, OPEN CASCADE
+// Copyright (C) 2007-2024 CEA, EDF, OPEN CASCADE
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
#include <execinfo.h>
#endif
+#include <memory>
+#include <functional>
namespace Kernel_Utils
{
std::string encode_s(const wchar_t* decoded)
{
- return std::string(encode(decoded));
+ std::unique_ptr<char,std::function<void(char*)>> tmp((char *)encode(decoded),[](char *ptr) { delete [] ptr; });
+ return std::string(tmp.get());
}
#ifndef WIN32
{
std::stringstream sstr;
sstr<<name<<'='<<value;
- if(rewrite || std::string(getenv(name)).length() == 0)
+ if(rewrite || getenv(name) == nullptr || std::string(getenv(name)).length() == 0)
return _putenv(sstr.str().c_str());
else return -1;
}