1a3b02b71Smatthias.ringwald /* 2a0c35809S[email protected] * Copyright (C) 2014 BlueKitchen GmbH 3a3b02b71Smatthias.ringwald * 4a3b02b71Smatthias.ringwald * Redistribution and use in source and binary forms, with or without 5a3b02b71Smatthias.ringwald * modification, are permitted provided that the following conditions 6a3b02b71Smatthias.ringwald * are met: 7a3b02b71Smatthias.ringwald * 8a3b02b71Smatthias.ringwald * 1. Redistributions of source code must retain the above copyright 9a3b02b71Smatthias.ringwald * notice, this list of conditions and the following disclaimer. 10a3b02b71Smatthias.ringwald * 2. Redistributions in binary form must reproduce the above copyright 11a3b02b71Smatthias.ringwald * notice, this list of conditions and the following disclaimer in the 12a3b02b71Smatthias.ringwald * documentation and/or other materials provided with the distribution. 13a3b02b71Smatthias.ringwald * 3. Neither the name of the copyright holders nor the names of 14a3b02b71Smatthias.ringwald * contributors may be used to endorse or promote products derived 15a3b02b71Smatthias.ringwald * from this software without specific prior written permission. 166b64433eSmatthias.ringwald * 4. Any redistribution, use, or modification is done solely for 176b64433eSmatthias.ringwald * personal benefit and not for any commercial purpose or for 186b64433eSmatthias.ringwald * monetary gain. 19a3b02b71Smatthias.ringwald * 202e97c149S[email protected] * THIS SOFTWARE IS PROVIDED BY BLUEKITCHEN GMBH AND CONTRIBUTORS 21a3b02b71Smatthias.ringwald * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 22a3b02b71Smatthias.ringwald * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 23a3b02b71Smatthias.ringwald * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL MATTHIAS 24a3b02b71Smatthias.ringwald * RINGWALD OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 25a3b02b71Smatthias.ringwald * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 26a3b02b71Smatthias.ringwald * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS 27a3b02b71Smatthias.ringwald * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED 28a3b02b71Smatthias.ringwald * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 29a3b02b71Smatthias.ringwald * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF 30a3b02b71Smatthias.ringwald * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 31a3b02b71Smatthias.ringwald * SUCH DAMAGE. 32a3b02b71Smatthias.ringwald * 332e97c149S[email protected] * Please inquire about commercial licensing options at 342e97c149S[email protected] * [email protected] 356b64433eSmatthias.ringwald * 36a3b02b71Smatthias.ringwald */ 37a3b02b71Smatthias.ringwald 382e97c149S[email protected] 39a3b02b71Smatthias.ringwald /* 40a98592bcSMatthias Ringwald * btstack_memory.h 41a3b02b71Smatthias.ringwald * 42a3b02b71Smatthias.ringwald * @brief BTstack memory management via configurable memory pools 43a3b02b71Smatthias.ringwald * 44a98592bcSMatthias Ringwald * @note code generated by tool/btstack_memory_generator.py 45a3b02b71Smatthias.ringwald * 46a3b02b71Smatthias.ringwald */ 47a3b02b71Smatthias.ringwald 48a3b02b71Smatthias.ringwald #include "btstack_memory.h" 49d2e6c4b7SMatthias Ringwald #include "btstack_memory_pool.h" 50a3b02b71Smatthias.ringwald 51a3b02b71Smatthias.ringwald #include <stdlib.h> 52a3b02b71Smatthias.ringwald 53a3b02b71Smatthias.ringwald 542e97c149S[email protected] 55a3b02b71Smatthias.ringwald // MARK: hci_connection_t 56a265b909SMatthias Ringwald #if !defined(HAVE_MALLOC) && !defined(MAX_NR_HCI_CONNECTIONS) 57a265b909SMatthias Ringwald #if defined(MAX_NO_HCI_CONNECTIONS) 5827faf85aSMilanka Ringwald #error "Deprecated MAX_NO_HCI_CONNECTIONS defined instead of MAX_NR_HCI_CONNECTIONS. Please update your btstack_config.h to use MAX_NR_HCI_CONNECTIONS." 59a265b909SMatthias Ringwald #else 60a265b909SMatthias Ringwald #define MAX_NR_HCI_CONNECTIONS 0 61a265b909SMatthias Ringwald #endif 62a265b909SMatthias Ringwald #endif 63a265b909SMatthias Ringwald 64a265b909SMatthias Ringwald #ifdef MAX_NR_HCI_CONNECTIONS 65a265b909SMatthias Ringwald #if MAX_NR_HCI_CONNECTIONS > 0 66a265b909SMatthias Ringwald static hci_connection_t hci_connection_storage[MAX_NR_HCI_CONNECTIONS]; 6729d0c4f7SMatthias Ringwald static btstack_memory_pool_t hci_connection_pool; 686527a633S[email protected] hci_connection_t * btstack_memory_hci_connection_get(void){ 6929d0c4f7SMatthias Ringwald return (hci_connection_t *) btstack_memory_pool_get(&hci_connection_pool); 70a3b02b71Smatthias.ringwald } 716527a633S[email protected] void btstack_memory_hci_connection_free(hci_connection_t *hci_connection){ 7229d0c4f7SMatthias Ringwald btstack_memory_pool_free(&hci_connection_pool, hci_connection); 73a3b02b71Smatthias.ringwald } 74c4d3f927Smatthias.ringwald #else 756527a633S[email protected] hci_connection_t * btstack_memory_hci_connection_get(void){ 76c4d3f927Smatthias.ringwald return NULL; 77c4d3f927Smatthias.ringwald } 786527a633S[email protected] void btstack_memory_hci_connection_free(hci_connection_t *hci_connection){ 796f7ecb09S[email protected] // silence compiler warning about unused parameter in a portable way 802e97c149S[email protected] (void) hci_connection; 81c4d3f927Smatthias.ringwald }; 82c4d3f927Smatthias.ringwald #endif 83a3b02b71Smatthias.ringwald #elif defined(HAVE_MALLOC) 846527a633S[email protected] hci_connection_t * btstack_memory_hci_connection_get(void){ 856527a633S[email protected] return (hci_connection_t*) malloc(sizeof(hci_connection_t)); 86a3b02b71Smatthias.ringwald } 876527a633S[email protected] void btstack_memory_hci_connection_free(hci_connection_t *hci_connection){ 88a3b02b71Smatthias.ringwald free(hci_connection); 89a3b02b71Smatthias.ringwald } 90a3b02b71Smatthias.ringwald #endif 91a3b02b71Smatthias.ringwald 92a3b02b71Smatthias.ringwald 932e97c149S[email protected] 94a3b02b71Smatthias.ringwald // MARK: l2cap_service_t 95a265b909SMatthias Ringwald #if !defined(HAVE_MALLOC) && !defined(MAX_NR_L2CAP_SERVICES) 96a265b909SMatthias Ringwald #if defined(MAX_NO_L2CAP_SERVICES) 9727faf85aSMilanka Ringwald #error "Deprecated MAX_NO_L2CAP_SERVICES defined instead of MAX_NR_L2CAP_SERVICES. Please update your btstack_config.h to use MAX_NR_L2CAP_SERVICES." 98a265b909SMatthias Ringwald #else 99a265b909SMatthias Ringwald #define MAX_NR_L2CAP_SERVICES 0 100a265b909SMatthias Ringwald #endif 101a265b909SMatthias Ringwald #endif 102a265b909SMatthias Ringwald 103a265b909SMatthias Ringwald #ifdef MAX_NR_L2CAP_SERVICES 104a265b909SMatthias Ringwald #if MAX_NR_L2CAP_SERVICES > 0 105a265b909SMatthias Ringwald static l2cap_service_t l2cap_service_storage[MAX_NR_L2CAP_SERVICES]; 10629d0c4f7SMatthias Ringwald static btstack_memory_pool_t l2cap_service_pool; 1076527a633S[email protected] l2cap_service_t * btstack_memory_l2cap_service_get(void){ 10829d0c4f7SMatthias Ringwald return (l2cap_service_t *) btstack_memory_pool_get(&l2cap_service_pool); 109a3b02b71Smatthias.ringwald } 1106527a633S[email protected] void btstack_memory_l2cap_service_free(l2cap_service_t *l2cap_service){ 11129d0c4f7SMatthias Ringwald btstack_memory_pool_free(&l2cap_service_pool, l2cap_service); 112a3b02b71Smatthias.ringwald } 113c4d3f927Smatthias.ringwald #else 1146527a633S[email protected] l2cap_service_t * btstack_memory_l2cap_service_get(void){ 115c4d3f927Smatthias.ringwald return NULL; 116c4d3f927Smatthias.ringwald } 1176527a633S[email protected] void btstack_memory_l2cap_service_free(l2cap_service_t *l2cap_service){ 1186f7ecb09S[email protected] // silence compiler warning about unused parameter in a portable way 1196f7ecb09S[email protected] (void) l2cap_service; 120c4d3f927Smatthias.ringwald }; 121c4d3f927Smatthias.ringwald #endif 122a3b02b71Smatthias.ringwald #elif defined(HAVE_MALLOC) 1236527a633S[email protected] l2cap_service_t * btstack_memory_l2cap_service_get(void){ 1246527a633S[email protected] return (l2cap_service_t*) malloc(sizeof(l2cap_service_t)); 125a3b02b71Smatthias.ringwald } 1266527a633S[email protected] void btstack_memory_l2cap_service_free(l2cap_service_t *l2cap_service){ 127a3b02b71Smatthias.ringwald free(l2cap_service); 128a3b02b71Smatthias.ringwald } 129a3b02b71Smatthias.ringwald #endif 130a3b02b71Smatthias.ringwald 131a3b02b71Smatthias.ringwald 132a3b02b71Smatthias.ringwald // MARK: l2cap_channel_t 133a265b909SMatthias Ringwald #if !defined(HAVE_MALLOC) && !defined(MAX_NR_L2CAP_CHANNELS) 134a265b909SMatthias Ringwald #if defined(MAX_NO_L2CAP_CHANNELS) 13527faf85aSMilanka Ringwald #error "Deprecated MAX_NO_L2CAP_CHANNELS defined instead of MAX_NR_L2CAP_CHANNELS. Please update your btstack_config.h to use MAX_NR_L2CAP_CHANNELS." 136a265b909SMatthias Ringwald #else 137a265b909SMatthias Ringwald #define MAX_NR_L2CAP_CHANNELS 0 138a265b909SMatthias Ringwald #endif 139a265b909SMatthias Ringwald #endif 140a265b909SMatthias Ringwald 141a265b909SMatthias Ringwald #ifdef MAX_NR_L2CAP_CHANNELS 142a265b909SMatthias Ringwald #if MAX_NR_L2CAP_CHANNELS > 0 143a265b909SMatthias Ringwald static l2cap_channel_t l2cap_channel_storage[MAX_NR_L2CAP_CHANNELS]; 14429d0c4f7SMatthias Ringwald static btstack_memory_pool_t l2cap_channel_pool; 1456527a633S[email protected] l2cap_channel_t * btstack_memory_l2cap_channel_get(void){ 14629d0c4f7SMatthias Ringwald return (l2cap_channel_t *) btstack_memory_pool_get(&l2cap_channel_pool); 147a3b02b71Smatthias.ringwald } 1486527a633S[email protected] void btstack_memory_l2cap_channel_free(l2cap_channel_t *l2cap_channel){ 14929d0c4f7SMatthias Ringwald btstack_memory_pool_free(&l2cap_channel_pool, l2cap_channel); 150a3b02b71Smatthias.ringwald } 151c4d3f927Smatthias.ringwald #else 1526527a633S[email protected] l2cap_channel_t * btstack_memory_l2cap_channel_get(void){ 153c4d3f927Smatthias.ringwald return NULL; 154c4d3f927Smatthias.ringwald } 1556527a633S[email protected] void btstack_memory_l2cap_channel_free(l2cap_channel_t *l2cap_channel){ 1566f7ecb09S[email protected] // silence compiler warning about unused parameter in a portable way 1576f7ecb09S[email protected] (void) l2cap_channel; 158c4d3f927Smatthias.ringwald }; 159c4d3f927Smatthias.ringwald #endif 160a3b02b71Smatthias.ringwald #elif defined(HAVE_MALLOC) 1616527a633S[email protected] l2cap_channel_t * btstack_memory_l2cap_channel_get(void){ 1626527a633S[email protected] return (l2cap_channel_t*) malloc(sizeof(l2cap_channel_t)); 163a3b02b71Smatthias.ringwald } 1646527a633S[email protected] void btstack_memory_l2cap_channel_free(l2cap_channel_t *l2cap_channel){ 165a3b02b71Smatthias.ringwald free(l2cap_channel); 166a3b02b71Smatthias.ringwald } 167a3b02b71Smatthias.ringwald #endif 168a3b02b71Smatthias.ringwald 169a3b02b71Smatthias.ringwald 1702e97c149S[email protected] 171a3b02b71Smatthias.ringwald // MARK: rfcomm_multiplexer_t 172a265b909SMatthias Ringwald #if !defined(HAVE_MALLOC) && !defined(MAX_NR_RFCOMM_MULTIPLEXERS) 173a265b909SMatthias Ringwald #if defined(MAX_NO_RFCOMM_MULTIPLEXERS) 17427faf85aSMilanka Ringwald #error "Deprecated MAX_NO_RFCOMM_MULTIPLEXERS defined instead of MAX_NR_RFCOMM_MULTIPLEXERS. Please update your btstack_config.h to use MAX_NR_RFCOMM_MULTIPLEXERS." 175a265b909SMatthias Ringwald #else 176a265b909SMatthias Ringwald #define MAX_NR_RFCOMM_MULTIPLEXERS 0 177a265b909SMatthias Ringwald #endif 178a265b909SMatthias Ringwald #endif 179a265b909SMatthias Ringwald 180a265b909SMatthias Ringwald #ifdef MAX_NR_RFCOMM_MULTIPLEXERS 181a265b909SMatthias Ringwald #if MAX_NR_RFCOMM_MULTIPLEXERS > 0 182a265b909SMatthias Ringwald static rfcomm_multiplexer_t rfcomm_multiplexer_storage[MAX_NR_RFCOMM_MULTIPLEXERS]; 18329d0c4f7SMatthias Ringwald static btstack_memory_pool_t rfcomm_multiplexer_pool; 1846527a633S[email protected] rfcomm_multiplexer_t * btstack_memory_rfcomm_multiplexer_get(void){ 18529d0c4f7SMatthias Ringwald return (rfcomm_multiplexer_t *) btstack_memory_pool_get(&rfcomm_multiplexer_pool); 186a3b02b71Smatthias.ringwald } 1876527a633S[email protected] void btstack_memory_rfcomm_multiplexer_free(rfcomm_multiplexer_t *rfcomm_multiplexer){ 18829d0c4f7SMatthias Ringwald btstack_memory_pool_free(&rfcomm_multiplexer_pool, rfcomm_multiplexer); 189a3b02b71Smatthias.ringwald } 190c4d3f927Smatthias.ringwald #else 1916527a633S[email protected] rfcomm_multiplexer_t * btstack_memory_rfcomm_multiplexer_get(void){ 192c4d3f927Smatthias.ringwald return NULL; 193c4d3f927Smatthias.ringwald } 1946527a633S[email protected] void btstack_memory_rfcomm_multiplexer_free(rfcomm_multiplexer_t *rfcomm_multiplexer){ 1956f7ecb09S[email protected] // silence compiler warning about unused parameter in a portable way 1966f7ecb09S[email protected] (void) rfcomm_multiplexer; 197c4d3f927Smatthias.ringwald }; 198c4d3f927Smatthias.ringwald #endif 199a3b02b71Smatthias.ringwald #elif defined(HAVE_MALLOC) 2006527a633S[email protected] rfcomm_multiplexer_t * btstack_memory_rfcomm_multiplexer_get(void){ 2016527a633S[email protected] return (rfcomm_multiplexer_t*) malloc(sizeof(rfcomm_multiplexer_t)); 202a3b02b71Smatthias.ringwald } 2036527a633S[email protected] void btstack_memory_rfcomm_multiplexer_free(rfcomm_multiplexer_t *rfcomm_multiplexer){ 204a3b02b71Smatthias.ringwald free(rfcomm_multiplexer); 205a3b02b71Smatthias.ringwald } 206a3b02b71Smatthias.ringwald #endif 207a3b02b71Smatthias.ringwald 208a3b02b71Smatthias.ringwald 209a3b02b71Smatthias.ringwald // MARK: rfcomm_service_t 210a265b909SMatthias Ringwald #if !defined(HAVE_MALLOC) && !defined(MAX_NR_RFCOMM_SERVICES) 211a265b909SMatthias Ringwald #if defined(MAX_NO_RFCOMM_SERVICES) 21227faf85aSMilanka Ringwald #error "Deprecated MAX_NO_RFCOMM_SERVICES defined instead of MAX_NR_RFCOMM_SERVICES. Please update your btstack_config.h to use MAX_NR_RFCOMM_SERVICES." 213a265b909SMatthias Ringwald #else 214a265b909SMatthias Ringwald #define MAX_NR_RFCOMM_SERVICES 0 215a265b909SMatthias Ringwald #endif 216a265b909SMatthias Ringwald #endif 217a265b909SMatthias Ringwald 218a265b909SMatthias Ringwald #ifdef MAX_NR_RFCOMM_SERVICES 219a265b909SMatthias Ringwald #if MAX_NR_RFCOMM_SERVICES > 0 220a265b909SMatthias Ringwald static rfcomm_service_t rfcomm_service_storage[MAX_NR_RFCOMM_SERVICES]; 22129d0c4f7SMatthias Ringwald static btstack_memory_pool_t rfcomm_service_pool; 2226527a633S[email protected] rfcomm_service_t * btstack_memory_rfcomm_service_get(void){ 22329d0c4f7SMatthias Ringwald return (rfcomm_service_t *) btstack_memory_pool_get(&rfcomm_service_pool); 224a3b02b71Smatthias.ringwald } 2256527a633S[email protected] void btstack_memory_rfcomm_service_free(rfcomm_service_t *rfcomm_service){ 22629d0c4f7SMatthias Ringwald btstack_memory_pool_free(&rfcomm_service_pool, rfcomm_service); 227a3b02b71Smatthias.ringwald } 228c4d3f927Smatthias.ringwald #else 2296527a633S[email protected] rfcomm_service_t * btstack_memory_rfcomm_service_get(void){ 230c4d3f927Smatthias.ringwald return NULL; 231c4d3f927Smatthias.ringwald } 2326527a633S[email protected] void btstack_memory_rfcomm_service_free(rfcomm_service_t *rfcomm_service){ 2336f7ecb09S[email protected] // silence compiler warning about unused parameter in a portable way 2346f7ecb09S[email protected] (void) rfcomm_service; 235c4d3f927Smatthias.ringwald }; 236c4d3f927Smatthias.ringwald #endif 237a3b02b71Smatthias.ringwald #elif defined(HAVE_MALLOC) 2386527a633S[email protected] rfcomm_service_t * btstack_memory_rfcomm_service_get(void){ 2396527a633S[email protected] return (rfcomm_service_t*) malloc(sizeof(rfcomm_service_t)); 240a3b02b71Smatthias.ringwald } 2416527a633S[email protected] void btstack_memory_rfcomm_service_free(rfcomm_service_t *rfcomm_service){ 242a3b02b71Smatthias.ringwald free(rfcomm_service); 243a3b02b71Smatthias.ringwald } 244a3b02b71Smatthias.ringwald #endif 245a3b02b71Smatthias.ringwald 246a3b02b71Smatthias.ringwald 247a3b02b71Smatthias.ringwald // MARK: rfcomm_channel_t 248a265b909SMatthias Ringwald #if !defined(HAVE_MALLOC) && !defined(MAX_NR_RFCOMM_CHANNELS) 249a265b909SMatthias Ringwald #if defined(MAX_NO_RFCOMM_CHANNELS) 25027faf85aSMilanka Ringwald #error "Deprecated MAX_NO_RFCOMM_CHANNELS defined instead of MAX_NR_RFCOMM_CHANNELS. Please update your btstack_config.h to use MAX_NR_RFCOMM_CHANNELS." 251a265b909SMatthias Ringwald #else 252a265b909SMatthias Ringwald #define MAX_NR_RFCOMM_CHANNELS 0 253a265b909SMatthias Ringwald #endif 254a265b909SMatthias Ringwald #endif 255a265b909SMatthias Ringwald 256a265b909SMatthias Ringwald #ifdef MAX_NR_RFCOMM_CHANNELS 257a265b909SMatthias Ringwald #if MAX_NR_RFCOMM_CHANNELS > 0 258a265b909SMatthias Ringwald static rfcomm_channel_t rfcomm_channel_storage[MAX_NR_RFCOMM_CHANNELS]; 25929d0c4f7SMatthias Ringwald static btstack_memory_pool_t rfcomm_channel_pool; 2606527a633S[email protected] rfcomm_channel_t * btstack_memory_rfcomm_channel_get(void){ 26129d0c4f7SMatthias Ringwald return (rfcomm_channel_t *) btstack_memory_pool_get(&rfcomm_channel_pool); 262a3b02b71Smatthias.ringwald } 2636527a633S[email protected] void btstack_memory_rfcomm_channel_free(rfcomm_channel_t *rfcomm_channel){ 26429d0c4f7SMatthias Ringwald btstack_memory_pool_free(&rfcomm_channel_pool, rfcomm_channel); 265a3b02b71Smatthias.ringwald } 266c4d3f927Smatthias.ringwald #else 2676527a633S[email protected] rfcomm_channel_t * btstack_memory_rfcomm_channel_get(void){ 268c4d3f927Smatthias.ringwald return NULL; 269c4d3f927Smatthias.ringwald } 2706527a633S[email protected] void btstack_memory_rfcomm_channel_free(rfcomm_channel_t *rfcomm_channel){ 2716f7ecb09S[email protected] // silence compiler warning about unused parameter in a portable way 2726f7ecb09S[email protected] (void) rfcomm_channel; 273c4d3f927Smatthias.ringwald }; 274c4d3f927Smatthias.ringwald #endif 275a3b02b71Smatthias.ringwald #elif defined(HAVE_MALLOC) 2766527a633S[email protected] rfcomm_channel_t * btstack_memory_rfcomm_channel_get(void){ 2776527a633S[email protected] return (rfcomm_channel_t*) malloc(sizeof(rfcomm_channel_t)); 278a3b02b71Smatthias.ringwald } 2796527a633S[email protected] void btstack_memory_rfcomm_channel_free(rfcomm_channel_t *rfcomm_channel){ 280a3b02b71Smatthias.ringwald free(rfcomm_channel); 281a3b02b71Smatthias.ringwald } 282a3b02b71Smatthias.ringwald #endif 283a3b02b71Smatthias.ringwald 284fdb398c2S[email protected] 285e0e5e285Smatthias.ringwald 2862c455dadSMatthias Ringwald // MARK: btstack_link_key_db_memory_entry_t 287a265b909SMatthias Ringwald #if !defined(HAVE_MALLOC) && !defined(MAX_NR_BTSTACK_LINK_KEY_DB_MEMORY_ENTRIES) 288a265b909SMatthias Ringwald #if defined(MAX_NO_BTSTACK_LINK_KEY_DB_MEMORY_ENTRIES) 28927faf85aSMilanka Ringwald #error "Deprecated MAX_NO_BTSTACK_LINK_KEY_DB_MEMORY_ENTRIES defined instead of MAX_NR_BTSTACK_LINK_KEY_DB_MEMORY_ENTRIES. Please update your btstack_config.h to use MAX_NR_BTSTACK_LINK_KEY_DB_MEMORY_ENTRIES." 290a265b909SMatthias Ringwald #else 291a265b909SMatthias Ringwald #define MAX_NR_BTSTACK_LINK_KEY_DB_MEMORY_ENTRIES 0 292a265b909SMatthias Ringwald #endif 293a265b909SMatthias Ringwald #endif 294a265b909SMatthias Ringwald 295a265b909SMatthias Ringwald #ifdef MAX_NR_BTSTACK_LINK_KEY_DB_MEMORY_ENTRIES 296a265b909SMatthias Ringwald #if MAX_NR_BTSTACK_LINK_KEY_DB_MEMORY_ENTRIES > 0 297a265b909SMatthias Ringwald static btstack_link_key_db_memory_entry_t btstack_link_key_db_memory_entry_storage[MAX_NR_BTSTACK_LINK_KEY_DB_MEMORY_ENTRIES]; 2982c455dadSMatthias Ringwald static btstack_memory_pool_t btstack_link_key_db_memory_entry_pool; 2992c455dadSMatthias Ringwald btstack_link_key_db_memory_entry_t * btstack_memory_btstack_link_key_db_memory_entry_get(void){ 3002c455dadSMatthias Ringwald return (btstack_link_key_db_memory_entry_t *) btstack_memory_pool_get(&btstack_link_key_db_memory_entry_pool); 3011801b596Smatthias.ringwald } 3022c455dadSMatthias Ringwald void btstack_memory_btstack_link_key_db_memory_entry_free(btstack_link_key_db_memory_entry_t *btstack_link_key_db_memory_entry){ 3032c455dadSMatthias Ringwald btstack_memory_pool_free(&btstack_link_key_db_memory_entry_pool, btstack_link_key_db_memory_entry); 3041801b596Smatthias.ringwald } 305c4d3f927Smatthias.ringwald #else 3062c455dadSMatthias Ringwald btstack_link_key_db_memory_entry_t * btstack_memory_btstack_link_key_db_memory_entry_get(void){ 307c4d3f927Smatthias.ringwald return NULL; 308c4d3f927Smatthias.ringwald } 3092c455dadSMatthias Ringwald void btstack_memory_btstack_link_key_db_memory_entry_free(btstack_link_key_db_memory_entry_t *btstack_link_key_db_memory_entry){ 3106f7ecb09S[email protected] // silence compiler warning about unused parameter in a portable way 3112c455dadSMatthias Ringwald (void) btstack_link_key_db_memory_entry; 312c4d3f927Smatthias.ringwald }; 313c4d3f927Smatthias.ringwald #endif 3141801b596Smatthias.ringwald #elif defined(HAVE_MALLOC) 3152c455dadSMatthias Ringwald btstack_link_key_db_memory_entry_t * btstack_memory_btstack_link_key_db_memory_entry_get(void){ 3162c455dadSMatthias Ringwald return (btstack_link_key_db_memory_entry_t*) malloc(sizeof(btstack_link_key_db_memory_entry_t)); 3171801b596Smatthias.ringwald } 3182c455dadSMatthias Ringwald void btstack_memory_btstack_link_key_db_memory_entry_free(btstack_link_key_db_memory_entry_t *btstack_link_key_db_memory_entry){ 3192c455dadSMatthias Ringwald free(btstack_link_key_db_memory_entry); 320e0e5e285Smatthias.ringwald } 3211801b596Smatthias.ringwald #endif 3221801b596Smatthias.ringwald 3232e97c149S[email protected] 3242e97c149S[email protected] 3252e97c149S[email protected] // MARK: bnep_service_t 326a265b909SMatthias Ringwald #if !defined(HAVE_MALLOC) && !defined(MAX_NR_BNEP_SERVICES) 327a265b909SMatthias Ringwald #if defined(MAX_NO_BNEP_SERVICES) 32827faf85aSMilanka Ringwald #error "Deprecated MAX_NO_BNEP_SERVICES defined instead of MAX_NR_BNEP_SERVICES. Please update your btstack_config.h to use MAX_NR_BNEP_SERVICES." 329a265b909SMatthias Ringwald #else 330a265b909SMatthias Ringwald #define MAX_NR_BNEP_SERVICES 0 331a265b909SMatthias Ringwald #endif 332a265b909SMatthias Ringwald #endif 333a265b909SMatthias Ringwald 334a265b909SMatthias Ringwald #ifdef MAX_NR_BNEP_SERVICES 335a265b909SMatthias Ringwald #if MAX_NR_BNEP_SERVICES > 0 336a265b909SMatthias Ringwald static bnep_service_t bnep_service_storage[MAX_NR_BNEP_SERVICES]; 33729d0c4f7SMatthias Ringwald static btstack_memory_pool_t bnep_service_pool; 3382e97c149S[email protected] bnep_service_t * btstack_memory_bnep_service_get(void){ 33929d0c4f7SMatthias Ringwald return (bnep_service_t *) btstack_memory_pool_get(&bnep_service_pool); 3402e97c149S[email protected] } 3412e97c149S[email protected] void btstack_memory_bnep_service_free(bnep_service_t *bnep_service){ 34229d0c4f7SMatthias Ringwald btstack_memory_pool_free(&bnep_service_pool, bnep_service); 3432e97c149S[email protected] } 3442e97c149S[email protected] #else 3452e97c149S[email protected] bnep_service_t * btstack_memory_bnep_service_get(void){ 3462e97c149S[email protected] return NULL; 3472e97c149S[email protected] } 3482e97c149S[email protected] void btstack_memory_bnep_service_free(bnep_service_t *bnep_service){ 3492e97c149S[email protected] // silence compiler warning about unused parameter in a portable way 3502e97c149S[email protected] (void) bnep_service; 3512e97c149S[email protected] }; 3522e97c149S[email protected] #endif 3532e97c149S[email protected] #elif defined(HAVE_MALLOC) 3542e97c149S[email protected] bnep_service_t * btstack_memory_bnep_service_get(void){ 3552e97c149S[email protected] return (bnep_service_t*) malloc(sizeof(bnep_service_t)); 3562e97c149S[email protected] } 3572e97c149S[email protected] void btstack_memory_bnep_service_free(bnep_service_t *bnep_service){ 3582e97c149S[email protected] free(bnep_service); 3592e97c149S[email protected] } 3602e97c149S[email protected] #endif 3612e97c149S[email protected] 3622e97c149S[email protected] 3632e97c149S[email protected] // MARK: bnep_channel_t 364a265b909SMatthias Ringwald #if !defined(HAVE_MALLOC) && !defined(MAX_NR_BNEP_CHANNELS) 365a265b909SMatthias Ringwald #if defined(MAX_NO_BNEP_CHANNELS) 36627faf85aSMilanka Ringwald #error "Deprecated MAX_NO_BNEP_CHANNELS defined instead of MAX_NR_BNEP_CHANNELS. Please update your btstack_config.h to use MAX_NR_BNEP_CHANNELS." 367a265b909SMatthias Ringwald #else 368a265b909SMatthias Ringwald #define MAX_NR_BNEP_CHANNELS 0 369a265b909SMatthias Ringwald #endif 370a265b909SMatthias Ringwald #endif 371a265b909SMatthias Ringwald 372a265b909SMatthias Ringwald #ifdef MAX_NR_BNEP_CHANNELS 373a265b909SMatthias Ringwald #if MAX_NR_BNEP_CHANNELS > 0 374a265b909SMatthias Ringwald static bnep_channel_t bnep_channel_storage[MAX_NR_BNEP_CHANNELS]; 37529d0c4f7SMatthias Ringwald static btstack_memory_pool_t bnep_channel_pool; 3762e97c149S[email protected] bnep_channel_t * btstack_memory_bnep_channel_get(void){ 37729d0c4f7SMatthias Ringwald return (bnep_channel_t *) btstack_memory_pool_get(&bnep_channel_pool); 3782e97c149S[email protected] } 3792e97c149S[email protected] void btstack_memory_bnep_channel_free(bnep_channel_t *bnep_channel){ 38029d0c4f7SMatthias Ringwald btstack_memory_pool_free(&bnep_channel_pool, bnep_channel); 3812e97c149S[email protected] } 3822e97c149S[email protected] #else 3832e97c149S[email protected] bnep_channel_t * btstack_memory_bnep_channel_get(void){ 3842e97c149S[email protected] return NULL; 3852e97c149S[email protected] } 3862e97c149S[email protected] void btstack_memory_bnep_channel_free(bnep_channel_t *bnep_channel){ 3872e97c149S[email protected] // silence compiler warning about unused parameter in a portable way 3882e97c149S[email protected] (void) bnep_channel; 3892e97c149S[email protected] }; 3902e97c149S[email protected] #endif 3912e97c149S[email protected] #elif defined(HAVE_MALLOC) 3922e97c149S[email protected] bnep_channel_t * btstack_memory_bnep_channel_get(void){ 3932e97c149S[email protected] return (bnep_channel_t*) malloc(sizeof(bnep_channel_t)); 3942e97c149S[email protected] } 3952e97c149S[email protected] void btstack_memory_bnep_channel_free(bnep_channel_t *bnep_channel){ 3962e97c149S[email protected] free(bnep_channel); 3972e97c149S[email protected] } 3982e97c149S[email protected] #endif 3992e97c149S[email protected] 4002e97c149S[email protected] 401ea5029c9SMilanka Ringwald 402ea5029c9SMilanka Ringwald // MARK: hfp_connection_t 403a265b909SMatthias Ringwald #if !defined(HAVE_MALLOC) && !defined(MAX_NR_HFP_CONNECTIONS) 404a265b909SMatthias Ringwald #if defined(MAX_NO_HFP_CONNECTIONS) 40527faf85aSMilanka Ringwald #error "Deprecated MAX_NO_HFP_CONNECTIONS defined instead of MAX_NR_HFP_CONNECTIONS. Please update your btstack_config.h to use MAX_NR_HFP_CONNECTIONS." 406a265b909SMatthias Ringwald #else 407a265b909SMatthias Ringwald #define MAX_NR_HFP_CONNECTIONS 0 408a265b909SMatthias Ringwald #endif 409a265b909SMatthias Ringwald #endif 410a265b909SMatthias Ringwald 411a265b909SMatthias Ringwald #ifdef MAX_NR_HFP_CONNECTIONS 412a265b909SMatthias Ringwald #if MAX_NR_HFP_CONNECTIONS > 0 413a265b909SMatthias Ringwald static hfp_connection_t hfp_connection_storage[MAX_NR_HFP_CONNECTIONS]; 41429d0c4f7SMatthias Ringwald static btstack_memory_pool_t hfp_connection_pool; 415ea5029c9SMilanka Ringwald hfp_connection_t * btstack_memory_hfp_connection_get(void){ 41629d0c4f7SMatthias Ringwald return (hfp_connection_t *) btstack_memory_pool_get(&hfp_connection_pool); 417ea5029c9SMilanka Ringwald } 418ea5029c9SMilanka Ringwald void btstack_memory_hfp_connection_free(hfp_connection_t *hfp_connection){ 41929d0c4f7SMatthias Ringwald btstack_memory_pool_free(&hfp_connection_pool, hfp_connection); 420ea5029c9SMilanka Ringwald } 421ea5029c9SMilanka Ringwald #else 422ea5029c9SMilanka Ringwald hfp_connection_t * btstack_memory_hfp_connection_get(void){ 423ea5029c9SMilanka Ringwald return NULL; 424ea5029c9SMilanka Ringwald } 425ea5029c9SMilanka Ringwald void btstack_memory_hfp_connection_free(hfp_connection_t *hfp_connection){ 426ea5029c9SMilanka Ringwald // silence compiler warning about unused parameter in a portable way 427ea5029c9SMilanka Ringwald (void) hfp_connection; 428ea5029c9SMilanka Ringwald }; 429ea5029c9SMilanka Ringwald #endif 430ea5029c9SMilanka Ringwald #elif defined(HAVE_MALLOC) 431ea5029c9SMilanka Ringwald hfp_connection_t * btstack_memory_hfp_connection_get(void){ 432ea5029c9SMilanka Ringwald return (hfp_connection_t*) malloc(sizeof(hfp_connection_t)); 433ea5029c9SMilanka Ringwald } 434ea5029c9SMilanka Ringwald void btstack_memory_hfp_connection_free(hfp_connection_t *hfp_connection){ 435ea5029c9SMilanka Ringwald free(hfp_connection); 436ea5029c9SMilanka Ringwald } 437ea5029c9SMilanka Ringwald #endif 438ea5029c9SMilanka Ringwald 439ea5029c9SMilanka Ringwald 440cd9ee144SMatthias Ringwald 441cd9ee144SMatthias Ringwald // MARK: service_record_item_t 442a265b909SMatthias Ringwald #if !defined(HAVE_MALLOC) && !defined(MAX_NR_SERVICE_RECORD_ITEMS) 443a265b909SMatthias Ringwald #if defined(MAX_NO_SERVICE_RECORD_ITEMS) 44427faf85aSMilanka Ringwald #error "Deprecated MAX_NO_SERVICE_RECORD_ITEMS defined instead of MAX_NR_SERVICE_RECORD_ITEMS. Please update your btstack_config.h to use MAX_NR_SERVICE_RECORD_ITEMS." 445a265b909SMatthias Ringwald #else 446a265b909SMatthias Ringwald #define MAX_NR_SERVICE_RECORD_ITEMS 0 447a265b909SMatthias Ringwald #endif 448a265b909SMatthias Ringwald #endif 449a265b909SMatthias Ringwald 450a265b909SMatthias Ringwald #ifdef MAX_NR_SERVICE_RECORD_ITEMS 451a265b909SMatthias Ringwald #if MAX_NR_SERVICE_RECORD_ITEMS > 0 452a265b909SMatthias Ringwald static service_record_item_t service_record_item_storage[MAX_NR_SERVICE_RECORD_ITEMS]; 45329d0c4f7SMatthias Ringwald static btstack_memory_pool_t service_record_item_pool; 454cd9ee144SMatthias Ringwald service_record_item_t * btstack_memory_service_record_item_get(void){ 45529d0c4f7SMatthias Ringwald return (service_record_item_t *) btstack_memory_pool_get(&service_record_item_pool); 456cd9ee144SMatthias Ringwald } 457cd9ee144SMatthias Ringwald void btstack_memory_service_record_item_free(service_record_item_t *service_record_item){ 45829d0c4f7SMatthias Ringwald btstack_memory_pool_free(&service_record_item_pool, service_record_item); 459cd9ee144SMatthias Ringwald } 460cd9ee144SMatthias Ringwald #else 461cd9ee144SMatthias Ringwald service_record_item_t * btstack_memory_service_record_item_get(void){ 462cd9ee144SMatthias Ringwald return NULL; 463cd9ee144SMatthias Ringwald } 464cd9ee144SMatthias Ringwald void btstack_memory_service_record_item_free(service_record_item_t *service_record_item){ 465cd9ee144SMatthias Ringwald // silence compiler warning about unused parameter in a portable way 466cd9ee144SMatthias Ringwald (void) service_record_item; 467cd9ee144SMatthias Ringwald }; 468cd9ee144SMatthias Ringwald #endif 469cd9ee144SMatthias Ringwald #elif defined(HAVE_MALLOC) 470cd9ee144SMatthias Ringwald service_record_item_t * btstack_memory_service_record_item_get(void){ 471cd9ee144SMatthias Ringwald return (service_record_item_t*) malloc(sizeof(service_record_item_t)); 472cd9ee144SMatthias Ringwald } 473cd9ee144SMatthias Ringwald void btstack_memory_service_record_item_free(service_record_item_t *service_record_item){ 474cd9ee144SMatthias Ringwald free(service_record_item); 475cd9ee144SMatthias Ringwald } 476cd9ee144SMatthias Ringwald #endif 477cd9ee144SMatthias Ringwald 478cd9ee144SMatthias Ringwald 47927faf85aSMilanka Ringwald 480*0e826a17SMilanka Ringwald // MARK: avdtp_stream_endpoint_t 481*0e826a17SMilanka Ringwald #if !defined(HAVE_MALLOC) && !defined(MAX_NR_AVDTP_STREAM_ENDPOINTS) 482*0e826a17SMilanka Ringwald #if defined(MAX_NO_AVDTP_STREAM_ENDPOINTS) 483*0e826a17SMilanka Ringwald #error "Deprecated MAX_NO_AVDTP_STREAM_ENDPOINTS defined instead of MAX_NR_AVDTP_STREAM_ENDPOINTS. Please update your btstack_config.h to use MAX_NR_AVDTP_STREAM_ENDPOINTS." 48427faf85aSMilanka Ringwald #else 485*0e826a17SMilanka Ringwald #define MAX_NR_AVDTP_STREAM_ENDPOINTS 0 48627faf85aSMilanka Ringwald #endif 48727faf85aSMilanka Ringwald #endif 48827faf85aSMilanka Ringwald 489*0e826a17SMilanka Ringwald #ifdef MAX_NR_AVDTP_STREAM_ENDPOINTS 490*0e826a17SMilanka Ringwald #if MAX_NR_AVDTP_STREAM_ENDPOINTS > 0 491*0e826a17SMilanka Ringwald static avdtp_stream_endpoint_t avdtp_stream_endpoint_storage[MAX_NR_AVDTP_STREAM_ENDPOINTS]; 492*0e826a17SMilanka Ringwald static btstack_memory_pool_t avdtp_stream_endpoint_pool; 493*0e826a17SMilanka Ringwald avdtp_stream_endpoint_t * btstack_memory_avdtp_stream_endpoint_get(void){ 494*0e826a17SMilanka Ringwald return (avdtp_stream_endpoint_t *) btstack_memory_pool_get(&avdtp_stream_endpoint_pool); 49527faf85aSMilanka Ringwald } 496*0e826a17SMilanka Ringwald void btstack_memory_avdtp_stream_endpoint_free(avdtp_stream_endpoint_t *avdtp_stream_endpoint){ 497*0e826a17SMilanka Ringwald btstack_memory_pool_free(&avdtp_stream_endpoint_pool, avdtp_stream_endpoint); 49827faf85aSMilanka Ringwald } 49927faf85aSMilanka Ringwald #else 500*0e826a17SMilanka Ringwald avdtp_stream_endpoint_t * btstack_memory_avdtp_stream_endpoint_get(void){ 50127faf85aSMilanka Ringwald return NULL; 50227faf85aSMilanka Ringwald } 503*0e826a17SMilanka Ringwald void btstack_memory_avdtp_stream_endpoint_free(avdtp_stream_endpoint_t *avdtp_stream_endpoint){ 50427faf85aSMilanka Ringwald // silence compiler warning about unused parameter in a portable way 505*0e826a17SMilanka Ringwald (void) avdtp_stream_endpoint; 50627faf85aSMilanka Ringwald }; 50727faf85aSMilanka Ringwald #endif 50827faf85aSMilanka Ringwald #elif defined(HAVE_MALLOC) 509*0e826a17SMilanka Ringwald avdtp_stream_endpoint_t * btstack_memory_avdtp_stream_endpoint_get(void){ 510*0e826a17SMilanka Ringwald return (avdtp_stream_endpoint_t*) malloc(sizeof(avdtp_stream_endpoint_t)); 51127faf85aSMilanka Ringwald } 512*0e826a17SMilanka Ringwald void btstack_memory_avdtp_stream_endpoint_free(avdtp_stream_endpoint_t *avdtp_stream_endpoint){ 513*0e826a17SMilanka Ringwald free(avdtp_stream_endpoint); 51427faf85aSMilanka Ringwald } 51527faf85aSMilanka Ringwald #endif 51627faf85aSMilanka Ringwald 51727faf85aSMilanka Ringwald 518a9a4c409SMatthias Ringwald #ifdef ENABLE_BLE 5192e97c149S[email protected] 5202e97c149S[email protected] // MARK: gatt_client_t 521a265b909SMatthias Ringwald #if !defined(HAVE_MALLOC) && !defined(MAX_NR_GATT_CLIENTS) 522a265b909SMatthias Ringwald #if defined(MAX_NO_GATT_CLIENTS) 52327faf85aSMilanka Ringwald #error "Deprecated MAX_NO_GATT_CLIENTS defined instead of MAX_NR_GATT_CLIENTS. Please update your btstack_config.h to use MAX_NR_GATT_CLIENTS." 524a265b909SMatthias Ringwald #else 525a265b909SMatthias Ringwald #define MAX_NR_GATT_CLIENTS 0 526a265b909SMatthias Ringwald #endif 527a265b909SMatthias Ringwald #endif 528a265b909SMatthias Ringwald 529a265b909SMatthias Ringwald #ifdef MAX_NR_GATT_CLIENTS 530a265b909SMatthias Ringwald #if MAX_NR_GATT_CLIENTS > 0 531a265b909SMatthias Ringwald static gatt_client_t gatt_client_storage[MAX_NR_GATT_CLIENTS]; 53229d0c4f7SMatthias Ringwald static btstack_memory_pool_t gatt_client_pool; 533d0fdae3cS[email protected] gatt_client_t * btstack_memory_gatt_client_get(void){ 53429d0c4f7SMatthias Ringwald return (gatt_client_t *) btstack_memory_pool_get(&gatt_client_pool); 535d0fdae3cS[email protected] } 536d0fdae3cS[email protected] void btstack_memory_gatt_client_free(gatt_client_t *gatt_client){ 53729d0c4f7SMatthias Ringwald btstack_memory_pool_free(&gatt_client_pool, gatt_client); 538d0fdae3cS[email protected] } 539d0fdae3cS[email protected] #else 540d0fdae3cS[email protected] gatt_client_t * btstack_memory_gatt_client_get(void){ 541d0fdae3cS[email protected] return NULL; 542d0fdae3cS[email protected] } 543d0fdae3cS[email protected] void btstack_memory_gatt_client_free(gatt_client_t *gatt_client){ 5446f7ecb09S[email protected] // silence compiler warning about unused parameter in a portable way 5456f7ecb09S[email protected] (void) gatt_client; 546d0fdae3cS[email protected] }; 547d0fdae3cS[email protected] #endif 548d0fdae3cS[email protected] #elif defined(HAVE_MALLOC) 549d0fdae3cS[email protected] gatt_client_t * btstack_memory_gatt_client_get(void){ 550d0fdae3cS[email protected] return (gatt_client_t*) malloc(sizeof(gatt_client_t)); 551d0fdae3cS[email protected] } 552d0fdae3cS[email protected] void btstack_memory_gatt_client_free(gatt_client_t *gatt_client){ 553d0fdae3cS[email protected] free(gatt_client); 554d0fdae3cS[email protected] } 555d0fdae3cS[email protected] #endif 5562e97c149S[email protected] 5572e97c149S[email protected] 558656bec4fSMatthias Ringwald // MARK: whitelist_entry_t 559a265b909SMatthias Ringwald #if !defined(HAVE_MALLOC) && !defined(MAX_NR_WHITELIST_ENTRIES) 560a265b909SMatthias Ringwald #if defined(MAX_NO_WHITELIST_ENTRIES) 56127faf85aSMilanka Ringwald #error "Deprecated MAX_NO_WHITELIST_ENTRIES defined instead of MAX_NR_WHITELIST_ENTRIES. Please update your btstack_config.h to use MAX_NR_WHITELIST_ENTRIES." 562a265b909SMatthias Ringwald #else 563a265b909SMatthias Ringwald #define MAX_NR_WHITELIST_ENTRIES 0 564a265b909SMatthias Ringwald #endif 565a265b909SMatthias Ringwald #endif 566a265b909SMatthias Ringwald 567a265b909SMatthias Ringwald #ifdef MAX_NR_WHITELIST_ENTRIES 568a265b909SMatthias Ringwald #if MAX_NR_WHITELIST_ENTRIES > 0 569a265b909SMatthias Ringwald static whitelist_entry_t whitelist_entry_storage[MAX_NR_WHITELIST_ENTRIES]; 57029d0c4f7SMatthias Ringwald static btstack_memory_pool_t whitelist_entry_pool; 571656bec4fSMatthias Ringwald whitelist_entry_t * btstack_memory_whitelist_entry_get(void){ 57229d0c4f7SMatthias Ringwald return (whitelist_entry_t *) btstack_memory_pool_get(&whitelist_entry_pool); 573656bec4fSMatthias Ringwald } 574656bec4fSMatthias Ringwald void btstack_memory_whitelist_entry_free(whitelist_entry_t *whitelist_entry){ 57529d0c4f7SMatthias Ringwald btstack_memory_pool_free(&whitelist_entry_pool, whitelist_entry); 576656bec4fSMatthias Ringwald } 577656bec4fSMatthias Ringwald #else 578656bec4fSMatthias Ringwald whitelist_entry_t * btstack_memory_whitelist_entry_get(void){ 579656bec4fSMatthias Ringwald return NULL; 580656bec4fSMatthias Ringwald } 581656bec4fSMatthias Ringwald void btstack_memory_whitelist_entry_free(whitelist_entry_t *whitelist_entry){ 582656bec4fSMatthias Ringwald // silence compiler warning about unused parameter in a portable way 583656bec4fSMatthias Ringwald (void) whitelist_entry; 584656bec4fSMatthias Ringwald }; 585656bec4fSMatthias Ringwald #endif 586656bec4fSMatthias Ringwald #elif defined(HAVE_MALLOC) 587656bec4fSMatthias Ringwald whitelist_entry_t * btstack_memory_whitelist_entry_get(void){ 588656bec4fSMatthias Ringwald return (whitelist_entry_t*) malloc(sizeof(whitelist_entry_t)); 589656bec4fSMatthias Ringwald } 590656bec4fSMatthias Ringwald void btstack_memory_whitelist_entry_free(whitelist_entry_t *whitelist_entry){ 591656bec4fSMatthias Ringwald free(whitelist_entry); 592656bec4fSMatthias Ringwald } 593656bec4fSMatthias Ringwald #endif 594656bec4fSMatthias Ringwald 595656bec4fSMatthias Ringwald 596cf49570bSMatthias Ringwald // MARK: sm_lookup_entry_t 597a265b909SMatthias Ringwald #if !defined(HAVE_MALLOC) && !defined(MAX_NR_SM_LOOKUP_ENTRIES) 598a265b909SMatthias Ringwald #if defined(MAX_NO_SM_LOOKUP_ENTRIES) 59927faf85aSMilanka Ringwald #error "Deprecated MAX_NO_SM_LOOKUP_ENTRIES defined instead of MAX_NR_SM_LOOKUP_ENTRIES. Please update your btstack_config.h to use MAX_NR_SM_LOOKUP_ENTRIES." 600a265b909SMatthias Ringwald #else 601a265b909SMatthias Ringwald #define MAX_NR_SM_LOOKUP_ENTRIES 0 602a265b909SMatthias Ringwald #endif 603a265b909SMatthias Ringwald #endif 604a265b909SMatthias Ringwald 605a265b909SMatthias Ringwald #ifdef MAX_NR_SM_LOOKUP_ENTRIES 606a265b909SMatthias Ringwald #if MAX_NR_SM_LOOKUP_ENTRIES > 0 607a265b909SMatthias Ringwald static sm_lookup_entry_t sm_lookup_entry_storage[MAX_NR_SM_LOOKUP_ENTRIES]; 60829d0c4f7SMatthias Ringwald static btstack_memory_pool_t sm_lookup_entry_pool; 609cf49570bSMatthias Ringwald sm_lookup_entry_t * btstack_memory_sm_lookup_entry_get(void){ 61029d0c4f7SMatthias Ringwald return (sm_lookup_entry_t *) btstack_memory_pool_get(&sm_lookup_entry_pool); 611cf49570bSMatthias Ringwald } 612cf49570bSMatthias Ringwald void btstack_memory_sm_lookup_entry_free(sm_lookup_entry_t *sm_lookup_entry){ 61329d0c4f7SMatthias Ringwald btstack_memory_pool_free(&sm_lookup_entry_pool, sm_lookup_entry); 614cf49570bSMatthias Ringwald } 615cf49570bSMatthias Ringwald #else 616cf49570bSMatthias Ringwald sm_lookup_entry_t * btstack_memory_sm_lookup_entry_get(void){ 617cf49570bSMatthias Ringwald return NULL; 618cf49570bSMatthias Ringwald } 619cf49570bSMatthias Ringwald void btstack_memory_sm_lookup_entry_free(sm_lookup_entry_t *sm_lookup_entry){ 620cf49570bSMatthias Ringwald // silence compiler warning about unused parameter in a portable way 621cf49570bSMatthias Ringwald (void) sm_lookup_entry; 622cf49570bSMatthias Ringwald }; 623cf49570bSMatthias Ringwald #endif 624cf49570bSMatthias Ringwald #elif defined(HAVE_MALLOC) 625cf49570bSMatthias Ringwald sm_lookup_entry_t * btstack_memory_sm_lookup_entry_get(void){ 626cf49570bSMatthias Ringwald return (sm_lookup_entry_t*) malloc(sizeof(sm_lookup_entry_t)); 627cf49570bSMatthias Ringwald } 628cf49570bSMatthias Ringwald void btstack_memory_sm_lookup_entry_free(sm_lookup_entry_t *sm_lookup_entry){ 629cf49570bSMatthias Ringwald free(sm_lookup_entry); 630cf49570bSMatthias Ringwald } 631cf49570bSMatthias Ringwald #endif 632cf49570bSMatthias Ringwald 633cf49570bSMatthias Ringwald 6342e97c149S[email protected] #endif 635a3b02b71Smatthias.ringwald // init 636a3b02b71Smatthias.ringwald void btstack_memory_init(void){ 637a265b909SMatthias Ringwald #if MAX_NR_HCI_CONNECTIONS > 0 638a265b909SMatthias Ringwald btstack_memory_pool_create(&hci_connection_pool, hci_connection_storage, MAX_NR_HCI_CONNECTIONS, sizeof(hci_connection_t)); 639a3b02b71Smatthias.ringwald #endif 640a265b909SMatthias Ringwald #if MAX_NR_L2CAP_SERVICES > 0 641a265b909SMatthias Ringwald btstack_memory_pool_create(&l2cap_service_pool, l2cap_service_storage, MAX_NR_L2CAP_SERVICES, sizeof(l2cap_service_t)); 642a3b02b71Smatthias.ringwald #endif 643a265b909SMatthias Ringwald #if MAX_NR_L2CAP_CHANNELS > 0 644a265b909SMatthias Ringwald btstack_memory_pool_create(&l2cap_channel_pool, l2cap_channel_storage, MAX_NR_L2CAP_CHANNELS, sizeof(l2cap_channel_t)); 645a3b02b71Smatthias.ringwald #endif 646a265b909SMatthias Ringwald #if MAX_NR_RFCOMM_MULTIPLEXERS > 0 647a265b909SMatthias Ringwald btstack_memory_pool_create(&rfcomm_multiplexer_pool, rfcomm_multiplexer_storage, MAX_NR_RFCOMM_MULTIPLEXERS, sizeof(rfcomm_multiplexer_t)); 648a3b02b71Smatthias.ringwald #endif 649a265b909SMatthias Ringwald #if MAX_NR_RFCOMM_SERVICES > 0 650a265b909SMatthias Ringwald btstack_memory_pool_create(&rfcomm_service_pool, rfcomm_service_storage, MAX_NR_RFCOMM_SERVICES, sizeof(rfcomm_service_t)); 651a3b02b71Smatthias.ringwald #endif 652a265b909SMatthias Ringwald #if MAX_NR_RFCOMM_CHANNELS > 0 653a265b909SMatthias Ringwald btstack_memory_pool_create(&rfcomm_channel_pool, rfcomm_channel_storage, MAX_NR_RFCOMM_CHANNELS, sizeof(rfcomm_channel_t)); 654a3b02b71Smatthias.ringwald #endif 655a265b909SMatthias Ringwald #if MAX_NR_BTSTACK_LINK_KEY_DB_MEMORY_ENTRIES > 0 656a265b909SMatthias Ringwald btstack_memory_pool_create(&btstack_link_key_db_memory_entry_pool, btstack_link_key_db_memory_entry_storage, MAX_NR_BTSTACK_LINK_KEY_DB_MEMORY_ENTRIES, sizeof(btstack_link_key_db_memory_entry_t)); 6571801b596Smatthias.ringwald #endif 658a265b909SMatthias Ringwald #if MAX_NR_BNEP_SERVICES > 0 659a265b909SMatthias Ringwald btstack_memory_pool_create(&bnep_service_pool, bnep_service_storage, MAX_NR_BNEP_SERVICES, sizeof(bnep_service_t)); 6602e97c149S[email protected] #endif 661a265b909SMatthias Ringwald #if MAX_NR_BNEP_CHANNELS > 0 662a265b909SMatthias Ringwald btstack_memory_pool_create(&bnep_channel_pool, bnep_channel_storage, MAX_NR_BNEP_CHANNELS, sizeof(bnep_channel_t)); 6632e97c149S[email protected] #endif 664a265b909SMatthias Ringwald #if MAX_NR_HFP_CONNECTIONS > 0 665a265b909SMatthias Ringwald btstack_memory_pool_create(&hfp_connection_pool, hfp_connection_storage, MAX_NR_HFP_CONNECTIONS, sizeof(hfp_connection_t)); 666ea5029c9SMilanka Ringwald #endif 667a265b909SMatthias Ringwald #if MAX_NR_SERVICE_RECORD_ITEMS > 0 668a265b909SMatthias Ringwald btstack_memory_pool_create(&service_record_item_pool, service_record_item_storage, MAX_NR_SERVICE_RECORD_ITEMS, sizeof(service_record_item_t)); 669cd9ee144SMatthias Ringwald #endif 670*0e826a17SMilanka Ringwald #if MAX_NR_AVDTP_STREAM_ENDPOINTS > 0 671*0e826a17SMilanka Ringwald btstack_memory_pool_create(&avdtp_stream_endpoint_pool, avdtp_stream_endpoint_storage, MAX_NR_AVDTP_STREAM_ENDPOINTS, sizeof(avdtp_stream_endpoint_t)); 67227faf85aSMilanka Ringwald #endif 673a9a4c409SMatthias Ringwald #ifdef ENABLE_BLE 674a265b909SMatthias Ringwald #if MAX_NR_GATT_CLIENTS > 0 675a265b909SMatthias Ringwald btstack_memory_pool_create(&gatt_client_pool, gatt_client_storage, MAX_NR_GATT_CLIENTS, sizeof(gatt_client_t)); 676d0fdae3cS[email protected] #endif 677a265b909SMatthias Ringwald #if MAX_NR_WHITELIST_ENTRIES > 0 678a265b909SMatthias Ringwald btstack_memory_pool_create(&whitelist_entry_pool, whitelist_entry_storage, MAX_NR_WHITELIST_ENTRIES, sizeof(whitelist_entry_t)); 679656bec4fSMatthias Ringwald #endif 680a265b909SMatthias Ringwald #if MAX_NR_SM_LOOKUP_ENTRIES > 0 681a265b909SMatthias Ringwald btstack_memory_pool_create(&sm_lookup_entry_pool, sm_lookup_entry_storage, MAX_NR_SM_LOOKUP_ENTRIES, sizeof(sm_lookup_entry_t)); 682cf49570bSMatthias Ringwald #endif 683a7d12effS[email protected] #endif 684a3b02b71Smatthias.ringwald } 685