@@ -40,9 +40,9 @@ bool ZigbeeEP::setManufacturerAndModel(const char *name, const char *model) {
40
40
log_e (" Manufacturer or model name is too long" );
41
41
return false ;
42
42
}
43
- // Allocate a new array of size length + 2 (1 for the length, 1 for null terminator)
44
- char * zb_name = new char [name_length + 2 ];
45
- char * zb_model = new char [model_length + 2 ];
43
+ // Allocate an array of size length + 2 (1 for the length, 1 for null terminator)
44
+ char zb_name[name_length + 2 ];
45
+ char zb_model[model_length + 2 ];
46
46
// Store the length as the first element
47
47
zb_name[0 ] = static_cast <char >(name_length); // Cast size_t to char
48
48
zb_model[0 ] = static_cast <char >(model_length);
@@ -63,8 +63,6 @@ bool ZigbeeEP::setManufacturerAndModel(const char *name, const char *model) {
63
63
if (ret_model != ESP_OK) {
64
64
log_e (" Failed to set model: 0x%x: %s" , ret_model, esp_err_to_name (ret_model));
65
65
}
66
- delete[] zb_name;
67
- delete[] zb_model;
68
66
return ret_name == ESP_OK && ret_model == ESP_OK;
69
67
}
70
68
@@ -245,7 +243,7 @@ void ZigbeeEP::zbReadBasicCluster(const esp_zb_zcl_attribute_t *attribute) {
245
243
/* Basic cluster attributes */
246
244
if (attribute->id == ESP_ZB_ZCL_ATTR_BASIC_MANUFACTURER_NAME_ID && attribute->data .type == ESP_ZB_ZCL_ATTR_TYPE_CHAR_STRING && attribute->data .value ) {
247
245
zbstring_t *zbstr = (zbstring_t *)attribute->data .value ;
248
- char * string = ( char *) malloc ( zbstr->len + 1 ) ;
246
+ char string[ zbstr->len + 1 ] ;
249
247
memcpy (string, zbstr->data , zbstr->len );
250
248
string[zbstr->len ] = ' \0 ' ;
251
249
log_i (" Peer Manufacturer is \" %s\" " , string);
@@ -254,7 +252,7 @@ void ZigbeeEP::zbReadBasicCluster(const esp_zb_zcl_attribute_t *attribute) {
254
252
}
255
253
if (attribute->id == ESP_ZB_ZCL_ATTR_BASIC_MODEL_IDENTIFIER_ID && attribute->data .type == ESP_ZB_ZCL_ATTR_TYPE_CHAR_STRING && attribute->data .value ) {
256
254
zbstring_t *zbstr = (zbstring_t *)attribute->data .value ;
257
- char * string = ( char *) malloc ( zbstr->len + 1 ) ;
255
+ char string[ zbstr->len + 1 ] ;
258
256
memcpy (string, zbstr->data , zbstr->len );
259
257
string[zbstr->len ] = ' \0 ' ;
260
258
log_i (" Peer Model is \" %s\" " , string);
0 commit comments