mirror of
https://github.com/thelsing/knx.git
synced 2024-12-18 19:08:18 +01:00
copy args
This commit is contained in:
parent
a585bf2bb7
commit
78122d13b1
@ -33,6 +33,7 @@ static void loop()
|
|||||||
}
|
}
|
||||||
|
|
||||||
static std::thread workerThread;
|
static std::thread workerThread;
|
||||||
|
static std::vector<std::string> argsVector;
|
||||||
static std::vector<const char*> argv;
|
static std::vector<const char*> argv;
|
||||||
|
|
||||||
struct StdStringCStrFunctor
|
struct StdStringCStrFunctor
|
||||||
@ -42,11 +43,13 @@ struct StdStringCStrFunctor
|
|||||||
|
|
||||||
static void Prepare(std::vector<std::string> args)
|
static void Prepare(std::vector<std::string> args)
|
||||||
{
|
{
|
||||||
|
// copy args so we control the livetime of the char*
|
||||||
|
argsVector = args;
|
||||||
//for(int i = 0; i < args.size(); i++)
|
//for(int i = 0; i < args.size(); i++)
|
||||||
// printf("%s\n", args[i].c_str());
|
// printf("%s\n", args[i].c_str());
|
||||||
|
|
||||||
argv = std::vector<const char*>(args.size());
|
argv = std::vector<const char*>(argsVector.size());
|
||||||
std::transform(args.begin(), args.end(), argv.begin(), StdStringCStrFunctor());
|
std::transform(argsVector.begin(), argsVector.end(), argv.begin(), StdStringCStrFunctor());
|
||||||
|
|
||||||
platform = new LinuxPlatform(argv.size(), const_cast<char**>(argv.data()));
|
platform = new LinuxPlatform(argv.size(), const_cast<char**>(argv.data()));
|
||||||
bau = new Bau57B0(*platform);
|
bau = new Bau57B0(*platform);
|
||||||
|
Loading…
Reference in New Issue
Block a user