Skip to content

Commit 454c726

Browse files
Xie,Qisgbihu
authored andcommitted
fix KW issue for class BLEDescriptor, BLECharacteristic and port.c
1 parent b4bce63 commit 454c726

File tree

1 file changed

+38
-0
lines changed

1 file changed

+38
-0
lines changed

libraries/BLE/src/BLECharacteristic.cpp

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,44 @@ BLECharacteristic& BLECharacteristic::operator= (const BLECharacteristic& rhs)
9494
return *this;
9595
}
9696

97+
BLECharacteristic::BLECharacteristic(const BLECharacteristic& rhs)
98+
{
99+
unsigned char *_value = (unsigned char*)malloc(rhs._value_size);
100+
if (_value)
101+
{
102+
memcpy(_value, rhs._value, rhs._value_size);
103+
_value_size = rhs._value_size;
104+
memcpy(_uuid_cstr, rhs._uuid_cstr, sizeof(_uuid_cstr));
105+
_properties = rhs._properties;
106+
_event_handlers = rhs._event_handlers;
107+
_internal = rhs._internal;
108+
_bledev = BLEDevice(&rhs._bledev);
109+
}
110+
}
111+
112+
BLECharacteristic& BLECharacteristic::operator= (const BLECharacteristic& rhs)
113+
{
114+
if (this != &rhs)
115+
{
116+
if (_value)
117+
{
118+
free(_value);
119+
}
120+
_value = (unsigned char*)malloc(rhs._value_size);
121+
if (_value)
122+
{
123+
memcpy(_value, rhs._value, rhs._value_size);
124+
_value_size = rhs._value_size;
125+
memcpy(_uuid_cstr, rhs._uuid_cstr, sizeof(_uuid_cstr));
126+
_properties = rhs._properties;
127+
_event_handlers = rhs._event_handlers;
128+
_internal = rhs._internal;
129+
_bledev = BLEDevice(&rhs._bledev);
130+
}
131+
}
132+
return *this;
133+
}
134+
97135
BLECharacteristic::~BLECharacteristic()
98136
{
99137
if (_value)

0 commit comments

Comments
 (0)