Squash the two submissions of previous.

component/bt: The application layer does not allocate memory correctly causing the btc layer pointer to cross the border.

bt/examples: Change the gattc_multi_connect.c incorrect memory apply method.
This commit is contained in:
Yulong 2017-10-22 23:07:03 -04:00
parent 477ed8ce62
commit a1495b0e49
3 changed files with 10 additions and 10 deletions

View file

@ -170,7 +170,7 @@ static void gattc_profile_event_handler(esp_gattc_cb_event_t event, esp_gatt_if_
} }
if (count > 0){ if (count > 0){
char_elem_result = (esp_gattc_char_elem_t *)malloc(sizeof(char_elem_result) * count); char_elem_result = (esp_gattc_char_elem_t *)malloc(sizeof(esp_gattc_char_elem_t) * count);
if (!char_elem_result){ if (!char_elem_result){
ESP_LOGE(GATTC_TAG, "gattc no mem"); ESP_LOGE(GATTC_TAG, "gattc no mem");
}else{ }else{
@ -216,7 +216,7 @@ static void gattc_profile_event_handler(esp_gattc_cb_event_t event, esp_gatt_if_
ESP_LOGE(GATTC_TAG, "esp_ble_gattc_get_attr_count error"); ESP_LOGE(GATTC_TAG, "esp_ble_gattc_get_attr_count error");
} }
if (count > 0){ if (count > 0){
descr_elem_result = malloc(sizeof(descr_elem_result) * count); descr_elem_result = malloc(sizeof(esp_gattc_descr_elem_t) * count);
if (!descr_elem_result){ if (!descr_elem_result){
ESP_LOGE(GATTC_TAG, "malloc error, gattc no mem"); ESP_LOGE(GATTC_TAG, "malloc error, gattc no mem");
}else{ }else{

View file

@ -191,7 +191,7 @@ static void gattc_profile_event_handler(esp_gattc_cb_event_t event, esp_gatt_if_
ESP_LOGE(GATTC_TAG, "esp_ble_gattc_get_attr_count error, %d", __LINE__); ESP_LOGE(GATTC_TAG, "esp_ble_gattc_get_attr_count error, %d", __LINE__);
} }
if (count > 0){ if (count > 0){
char_elem_result = (esp_gattc_char_elem_t *)malloc(sizeof(char_elem_result) * count); char_elem_result = (esp_gattc_char_elem_t *)malloc(sizeof(esp_gattc_char_elem_t) * count);
if (!char_elem_result){ if (!char_elem_result){
ESP_LOGE(GATTC_TAG, "gattc no mem"); ESP_LOGE(GATTC_TAG, "gattc no mem");
}else{ }else{
@ -245,7 +245,7 @@ static void gattc_profile_event_handler(esp_gattc_cb_event_t event, esp_gatt_if_
ESP_LOGE(GATTC_TAG, "esp_ble_gattc_get_attr_count error, %d", __LINE__); ESP_LOGE(GATTC_TAG, "esp_ble_gattc_get_attr_count error, %d", __LINE__);
} }
if (count > 0){ if (count > 0){
descr_elem_result = malloc(sizeof(descr_elem_result) * count); descr_elem_result = malloc(sizeof(esp_gattc_descr_elem_t) * count);
if (!descr_elem_result){ if (!descr_elem_result){
ESP_LOGE(GATTC_TAG, "malloc error, gattc no mem"); ESP_LOGE(GATTC_TAG, "malloc error, gattc no mem");
}else{ }else{

View file

@ -209,7 +209,7 @@ static void gattc_profile_a_event_handler(esp_gattc_cb_event_t event, esp_gatt_i
ESP_LOGE(GATTC_TAG, "esp_ble_gattc_get_attr_count error"); ESP_LOGE(GATTC_TAG, "esp_ble_gattc_get_attr_count error");
} }
if (count > 0) { if (count > 0) {
char_elem_result_a = (esp_gattc_char_elem_t *)malloc(sizeof(char_elem_result_a) * count); char_elem_result_a = (esp_gattc_char_elem_t *)malloc(sizeof(esp_gattc_char_elem_t) * count);
if (!char_elem_result_a){ if (!char_elem_result_a){
ESP_LOGE(GATTC_TAG, "gattc no mem"); ESP_LOGE(GATTC_TAG, "gattc no mem");
}else { }else {
@ -255,7 +255,7 @@ static void gattc_profile_a_event_handler(esp_gattc_cb_event_t event, esp_gatt_i
ESP_LOGE(GATTC_TAG, "esp_ble_gattc_get_attr_count error"); ESP_LOGE(GATTC_TAG, "esp_ble_gattc_get_attr_count error");
} }
if (count > 0){ if (count > 0){
descr_elem_result_a = malloc(sizeof(descr_elem_result_a) * count); descr_elem_result_a = (esp_gattc_descr_elem_t *)malloc(sizeof(esp_gattc_descr_elem_t) * count);
if (!descr_elem_result_a){ if (!descr_elem_result_a){
ESP_LOGE(GATTC_TAG, "malloc error, gattc no mem"); ESP_LOGE(GATTC_TAG, "malloc error, gattc no mem");
}else{ }else{
@ -410,7 +410,7 @@ static void gattc_profile_b_event_handler(esp_gattc_cb_event_t event, esp_gatt_i
} }
if (count > 0){ if (count > 0){
char_elem_result_b = (esp_gattc_char_elem_t *)malloc(sizeof(char_elem_result_b) * count); char_elem_result_b = (esp_gattc_char_elem_t *)malloc(sizeof(esp_gattc_char_elem_t) * count);
if (!char_elem_result_b){ if (!char_elem_result_b){
ESP_LOGE(GATTC_TAG, "gattc no mem"); ESP_LOGE(GATTC_TAG, "gattc no mem");
}else{ }else{
@ -457,7 +457,7 @@ static void gattc_profile_b_event_handler(esp_gattc_cb_event_t event, esp_gatt_i
ESP_LOGE(GATTC_TAG, "esp_ble_gattc_get_attr_count error"); ESP_LOGE(GATTC_TAG, "esp_ble_gattc_get_attr_count error");
} }
if (count > 0){ if (count > 0){
descr_elem_result_b = malloc(sizeof(descr_elem_result_b) * count); descr_elem_result_b = (esp_gattc_descr_elem_t *)malloc(sizeof(esp_gattc_descr_elem_t) * count);
if (!descr_elem_result_b){ if (!descr_elem_result_b){
ESP_LOGE(GATTC_TAG, "malloc error, gattc no mem"); ESP_LOGE(GATTC_TAG, "malloc error, gattc no mem");
}else{ }else{
@ -609,7 +609,7 @@ static void gattc_profile_c_event_handler(esp_gattc_cb_event_t event, esp_gatt_i
} }
if (count > 0){ if (count > 0){
char_elem_result_c = (esp_gattc_char_elem_t *)malloc(sizeof(char_elem_result_c) * count); char_elem_result_c = (esp_gattc_char_elem_t *)malloc(sizeof(esp_gattc_char_elem_t) * count);
if (!char_elem_result_c){ if (!char_elem_result_c){
ESP_LOGE(GATTC_TAG, "gattc no mem"); ESP_LOGE(GATTC_TAG, "gattc no mem");
}else{ }else{
@ -655,7 +655,7 @@ static void gattc_profile_c_event_handler(esp_gattc_cb_event_t event, esp_gatt_i
ESP_LOGE(GATTC_TAG, "esp_ble_gattc_get_attr_count error"); ESP_LOGE(GATTC_TAG, "esp_ble_gattc_get_attr_count error");
} }
if (count > 0){ if (count > 0){
descr_elem_result_c = malloc(sizeof(descr_elem_result_c) * count); descr_elem_result_c = (esp_gattc_descr_elem_t *)malloc(sizeof(esp_gattc_descr_elem_t) * count);
if (!descr_elem_result_c){ if (!descr_elem_result_c){
ESP_LOGE(GATTC_TAG, "malloc error, gattc no mem"); ESP_LOGE(GATTC_TAG, "malloc error, gattc no mem");
}else{ }else{