Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit e2866f6a authored by Fukai Wang's avatar Fukai Wang Committed by Hansong Zhang
Browse files

Add btm_free() to clean up btm properly

Test: Run AdapterRepeatedEnableDisable in system/bt/test with
kTestRepeatCount set to 1000.

Merged-In: I3445a725d66e73e8bcffc7bfabe594f49a6fc863
Change-Id: I3445a725d66e73e8bcffc7bfabe594f49a6fc863
parent a363b7f2
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -47,6 +47,7 @@ extern tBTM_CB btm_cb;
 *******************************************
*/
extern void btm_init(void);
extern void btm_free(void);

/* Internal functions provided by btm_inq.cc
 ******************************************
+18 −0
Original line number Diff line number Diff line
@@ -74,3 +74,21 @@ void btm_init(void) {

  btm_dev_init(); /* Device Manager Structures & HCI_Reset */
}

/** This function is called to free dynamic memory and system resource allocated by btm_init */
void btm_free(void) {
  fixed_queue_free(btm_cb.page_queue, NULL);
  btm_cb.page_queue = NULL;

  fixed_queue_free(btm_cb.sec_pending_q, NULL);
  btm_cb.sec_pending_q = NULL;

  list_free(btm_cb.sec_dev_rec);
  btm_cb.sec_dev_rec = NULL;

  alarm_free(btm_cb.sec_collision_timer);
  btm_cb.sec_collision_timer = NULL;

  alarm_free(btm_cb.pairing_timer);
  btm_cb.pairing_timer = NULL;
}
+3 −1
Original line number Diff line number Diff line
@@ -87,9 +87,11 @@ void btu_init_core(void) {
 *****************************************************************************/
void btu_free_core(void) {
  /* Free the mandatory core stack components */
  gatt_free();

  l2c_free();

  gatt_free();
  btm_free();
}

/*****************************************************************************