mirror of
https://github.com/espressif/esp-idf.git
synced 2025-07-30 10:47:19 +02:00
fix(ble/bluedrooid): Fixed memory leak issue when deinit the host
(cherry picked from commit 6becf74cbb
)
Co-authored-by: zhanghaipeng <zhanghaipeng@espressif.com>
This commit is contained in:
@ -101,6 +101,7 @@ static controller_local_param_t *controller_param_ptr;
|
|||||||
|
|
||||||
#define AWAIT_COMMAND(command) future_await(controller_param.hci->transmit_command_futured(command))
|
#define AWAIT_COMMAND(command) future_await(controller_param.hci->transmit_command_futured(command))
|
||||||
|
|
||||||
|
static bool loaded = false;
|
||||||
// Module lifecycle functions
|
// Module lifecycle functions
|
||||||
|
|
||||||
static void start_up(void)
|
static void start_up(void)
|
||||||
@ -348,6 +349,17 @@ static void shut_down(void)
|
|||||||
controller_param.readable = false;
|
controller_param.readable = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if (BT_BLE_DYNAMIC_ENV_MEMORY == TRUE)
|
||||||
|
void free_controller_param(void)
|
||||||
|
{
|
||||||
|
if (controller_param_ptr) {
|
||||||
|
osi_free(controller_param_ptr);
|
||||||
|
controller_param_ptr = NULL;
|
||||||
|
loaded = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
static bool get_is_ready(void)
|
static bool get_is_ready(void)
|
||||||
{
|
{
|
||||||
return controller_param.readable;
|
return controller_param.readable;
|
||||||
@ -632,7 +644,6 @@ static const controller_t interface = {
|
|||||||
|
|
||||||
const controller_t *controller_get_interface(void)
|
const controller_t *controller_get_interface(void)
|
||||||
{
|
{
|
||||||
static bool loaded = false;
|
|
||||||
if (!loaded) {
|
if (!loaded) {
|
||||||
loaded = true;
|
loaded = true;
|
||||||
#if (BT_BLE_DYNAMIC_ENV_MEMORY == TRUE)
|
#if (BT_BLE_DYNAMIC_ENV_MEMORY == TRUE)
|
||||||
|
@ -64,6 +64,9 @@ static void bte_main_enable(void);
|
|||||||
bluedroid_init_done_cb_t bluedroid_init_done_cb;
|
bluedroid_init_done_cb_t bluedroid_init_done_cb;
|
||||||
|
|
||||||
extern void osi_mem_dbg_init(void);
|
extern void osi_mem_dbg_init(void);
|
||||||
|
#if (BT_BLE_DYNAMIC_ENV_MEMORY == TRUE)
|
||||||
|
extern void free_controller_param(void);
|
||||||
|
#endif
|
||||||
/******************************************************************************
|
/******************************************************************************
|
||||||
**
|
**
|
||||||
** Function bte_main_boot_entry
|
** Function bte_main_boot_entry
|
||||||
@ -85,7 +88,7 @@ int bte_main_boot_entry(bluedroid_init_done_cb_t cb)
|
|||||||
|
|
||||||
osi_init();
|
osi_init();
|
||||||
|
|
||||||
//Enbale HCI
|
//Enable HCI
|
||||||
bte_main_enable();
|
bte_main_enable();
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
@ -105,6 +108,11 @@ void bte_main_shutdown(void)
|
|||||||
#if (BLE_INCLUDED == TRUE)
|
#if (BLE_INCLUDED == TRUE)
|
||||||
BTA_VendorCleanup();
|
BTA_VendorCleanup();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if (BT_BLE_DYNAMIC_ENV_MEMORY == TRUE)
|
||||||
|
free_controller_param();
|
||||||
|
#endif
|
||||||
|
|
||||||
bte_main_disable();
|
bte_main_disable();
|
||||||
|
|
||||||
osi_deinit();
|
osi_deinit();
|
||||||
|
Reference in New Issue
Block a user