mirror of
https://github.com/espressif/esp-nimble.git
synced 2026-06-05 21:04:49 +00:00
fix(nimble): fix memory leak issue in Blufi example
This commit is contained in:
@@ -1250,7 +1250,7 @@ STAILQ_HEAD(ble_gatts_clt_cfg_list, ble_gatts_clt_cfg);
|
||||
* BLE_HS_ENOMEM on heap exhaustion.
|
||||
*/
|
||||
int ble_gatts_add_svcs(const struct ble_gatt_svc_def *svcs);
|
||||
|
||||
void ble_gatts_free_svcs(void);
|
||||
#if MYNEWT_VAL(BLE_DYNAMIC_SERVICE)
|
||||
/**
|
||||
* Adds a set of services for registration. All services added
|
||||
|
||||
@@ -58,6 +58,7 @@ int ble_svc_gap_device_key_material_set(uint8_t *session_key, uint8_t *iv);
|
||||
#endif
|
||||
|
||||
void ble_svc_gap_init(void);
|
||||
void ble_svc_gap_deinit(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
||||
@@ -370,3 +370,9 @@ ble_svc_gap_init(void)
|
||||
SYSINIT_PANIC_ASSERT(rc == 0);
|
||||
#endif
|
||||
}
|
||||
|
||||
void
|
||||
ble_svc_gap_deinit(void)
|
||||
{
|
||||
ble_gatts_free_svcs();
|
||||
}
|
||||
|
||||
@@ -51,7 +51,7 @@ uint8_t ble_svc_gatt_get_csfs(void);
|
||||
uint8_t ble_svc_gatt_get_local_cl_supported_feat(void);
|
||||
void ble_svc_gatt_changed(uint16_t start_handle, uint16_t end_handle);
|
||||
void ble_svc_gatt_init(void);
|
||||
|
||||
void ble_svc_gatt_deinit(void);
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -249,3 +249,9 @@ ble_svc_gatt_init(void)
|
||||
ble_svc_gatt_local_cl_sup_feat |= (1 << BLE_SVC_GATT_CLI_SUP_FEAT_ROBUST_CATCHING_BIT);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
ble_svc_gatt_deinit(void)
|
||||
{
|
||||
ble_gatts_free_svcs();
|
||||
}
|
||||
|
||||
@@ -3032,6 +3032,19 @@ done:
|
||||
return rc;
|
||||
}
|
||||
|
||||
void ble_gatts_free_svcs(void)
|
||||
{
|
||||
/* Ensure the memory is freed only if it was previously allocated */
|
||||
if (ble_gatts_svc_defs != NULL) {
|
||||
/* Free the memory for the service definitions */
|
||||
free(ble_gatts_svc_defs);
|
||||
/* Set the pointer to NULL to avoid dangling pointer */
|
||||
ble_gatts_svc_defs = NULL;
|
||||
/* Reset the number of service definitions to 0 */
|
||||
ble_gatts_num_svc_defs = 0;
|
||||
}
|
||||
}
|
||||
|
||||
int
|
||||
ble_gatts_svc_set_visibility(uint16_t handle, int visible)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user