mirror of
https://github.com/espressif/esp-idf.git
synced 2025-07-29 18:27:20 +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))
|
||||
|
||||
static bool loaded = false;
|
||||
// Module lifecycle functions
|
||||
|
||||
static void start_up(void)
|
||||
@ -348,6 +349,17 @@ static void shut_down(void)
|
||||
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)
|
||||
{
|
||||
return controller_param.readable;
|
||||
@ -632,7 +644,6 @@ static const controller_t interface = {
|
||||
|
||||
const controller_t *controller_get_interface(void)
|
||||
{
|
||||
static bool loaded = false;
|
||||
if (!loaded) {
|
||||
loaded = 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;
|
||||
|
||||
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
|
||||
@ -85,7 +88,7 @@ int bte_main_boot_entry(bluedroid_init_done_cb_t cb)
|
||||
|
||||
osi_init();
|
||||
|
||||
//Enbale HCI
|
||||
//Enable HCI
|
||||
bte_main_enable();
|
||||
|
||||
return 0;
|
||||
@ -105,6 +108,11 @@ void bte_main_shutdown(void)
|
||||
#if (BLE_INCLUDED == TRUE)
|
||||
BTA_VendorCleanup();
|
||||
#endif
|
||||
|
||||
#if (BT_BLE_DYNAMIC_ENV_MEMORY == TRUE)
|
||||
free_controller_param();
|
||||
#endif
|
||||
|
||||
bte_main_disable();
|
||||
|
||||
osi_deinit();
|
||||
|
Reference in New Issue
Block a user