| | |
| | | static void |
| | | ble_gatts_free_svc_defs(void) |
| | | { |
| | | free(ble_gatts_svc_defs); |
| | | nimble_mem_free(ble_gatts_svc_defs); |
| | | ble_gatts_svc_defs = NULL; |
| | | ble_gatts_num_svc_defs = 0; |
| | | } |
| | |
| | | static void |
| | | ble_gatts_free_mem(void) |
| | | { |
| | | free(ble_gatts_clt_cfg_mem); |
| | | nimble_mem_free(ble_gatts_clt_cfg_mem); |
| | | ble_gatts_clt_cfg_mem = NULL; |
| | | |
| | | free(ble_gatts_svc_entries); |
| | | nimble_mem_free(ble_gatts_svc_entries); |
| | | ble_gatts_svc_entries = NULL; |
| | | } |
| | | |
| | |
| | | } |
| | | |
| | | if (ble_hs_max_client_configs > 0) { |
| | | ble_gatts_clt_cfg_mem = pvPortMalloc( |
| | | ble_gatts_clt_cfg_mem = nimble_mem_alloc( |
| | | OS_MEMPOOL_BYTES(ble_hs_max_client_configs, |
| | | sizeof (struct ble_gatts_clt_cfg))); |
| | | if (ble_gatts_clt_cfg_mem == NULL) { |
| | |
| | | |
| | | if (ble_hs_max_services > 0) { |
| | | ble_gatts_svc_entries = |
| | | pvPortMalloc(ble_hs_max_services * sizeof *ble_gatts_svc_entries); |
| | | nimble_mem_alloc(ble_hs_max_services * sizeof *ble_gatts_svc_entries); |
| | | if (ble_gatts_svc_entries == NULL) { |
| | | rc = BLE_HS_ENOMEM; |
| | | goto done; |
| | |
| | | goto done; |
| | | } |
| | | |
| | | #if 1 |
| | | p = nimble_mem_alloc((ble_gatts_num_svc_defs + 1) * sizeof *ble_gatts_svc_defs); |
| | | if (p == NULL) { |
| | | rc = BLE_HS_ENOMEM; |
| | | goto done; |
| | | } |
| | | |
| | | memcpy(p, ble_gatts_svc_defs, ble_gatts_num_svc_defs * (sizeof *ble_gatts_svc_defs)); |
| | | nimble_mem_free(ble_gatts_svc_defs); |
| | | |
| | | #else |
| | | p = realloc(ble_gatts_svc_defs, |
| | | (ble_gatts_num_svc_defs + 1) * sizeof *ble_gatts_svc_defs); |
| | | if (p == NULL) { |
| | | rc = BLE_HS_ENOMEM; |
| | | goto done; |
| | | } |
| | | #endif |
| | | |
| | | ble_gatts_svc_defs = p; |
| | | ble_gatts_svc_defs[ble_gatts_num_svc_defs] = svcs; |