use string as a pointer to keep the reference to id
This commit is contained in:
parent
e246158502
commit
996683d43c
@ -62,10 +62,7 @@ struct PollinSwitch : Switch {
|
||||
PollinSwitch(const char* group, const unsigned char channel, const char* name = nullptr, const char* area = nullptr)
|
||||
: Switch(nullptr, [group, channel]{
|
||||
// copy id from string into a new pointer, to avoid memory leaks
|
||||
string s = Protocol_1::buildId(group, channel);
|
||||
char* uId = new char[s.length() + 1];
|
||||
strcpy(uId, s.c_str());
|
||||
return uId;
|
||||
return (new string{Protocol_1::buildId(group, channel)})->c_str();
|
||||
}()), group(group), channel(channel) {
|
||||
if (!name) name = (new string{string(man).append(" ").append(id)})->c_str();
|
||||
mainDevice = &DeviceConfig::create(id).withName(name).withManufacturer(man).withArea(area).withParent(gatewayDevice);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user