From 83dc1a98635e0897f3bc004d9d1e08586d1e2649 Mon Sep 17 00:00:00 2001 From: Matthias Ringwald Date: Thu, 4 Nov 2021 11:46:15 +0100 Subject: [PATCH] hci: extract hci_whitelist_free --- src/hci.c | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/src/hci.c b/src/hci.c index 9dbd86647..387b0d97e 100644 --- a/src/hci.c +++ b/src/hci.c @@ -173,6 +173,7 @@ static void hci_trigger_remote_features_for_connection(hci_connection_t * connec // called from test/ble_client/advertising_data_parser.c void le_handle_advertisement_report(uint8_t *packet, uint16_t size); static uint8_t hci_whitelist_remove(bd_addr_type_t address_type, const bd_addr_t address); +static void hci_whitelist_free(void); static hci_connection_t * gap_get_outgoing_connection(void); #endif #endif @@ -5006,16 +5007,7 @@ static void hci_run(void){ #ifdef ENABLE_BLE #ifdef ENABLE_LE_CENTRAL - // free whitelist entries - { - btstack_linked_list_iterator_t lit; - btstack_linked_list_iterator_init(&lit, &hci_stack->le_whitelist); - while (btstack_linked_list_iterator_has_next(&lit)){ - whitelist_entry_t * entry = (whitelist_entry_t*) btstack_linked_list_iterator_next(&lit); - btstack_linked_list_remove(&hci_stack->le_whitelist, (btstack_linked_item_t *) entry); - btstack_memory_whitelist_entry_free(entry); - } - } + hci_whitelist_free(); #endif #endif // close all open connections @@ -6242,6 +6234,17 @@ static void hci_whitelist_clear(void){ } } +// free all entries unconditionally +static void hci_whitelist_free(void){ + btstack_linked_list_iterator_t lit; + btstack_linked_list_iterator_init(&lit, &hci_stack->le_whitelist); + while (btstack_linked_list_iterator_has_next(&lit)){ + whitelist_entry_t * entry = (whitelist_entry_t*) btstack_linked_list_iterator_next(&lit); + btstack_linked_list_remove(&hci_stack->le_whitelist, (btstack_linked_item_t *) entry); + btstack_memory_whitelist_entry_free(entry); + } +} + /** * @brief Clear Whitelist * @return 0 if ok