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 56*a265b909SMatthias Ringwald #if !defined(HAVE_MALLOC) && !defined(MAX_NR_HCI_CONNECTIONS) 57*a265b909SMatthias Ringwald #if defined(MAX_NO_HCI_CONNECTIONS) 58*a265b909SMatthias 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" 59*a265b909SMatthias Ringwald #else 60*a265b909SMatthias Ringwald #define MAX_NR_HCI_CONNECTIONS 0 61*a265b909SMatthias Ringwald #endif 62*a265b909SMatthias Ringwald #endif 63*a265b909SMatthias Ringwald 64*a265b909SMatthias Ringwald #ifdef MAX_NR_HCI_CONNECTIONS 65*a265b909SMatthias Ringwald #if MAX_NR_HCI_CONNECTIONS > 0 66*a265b909SMatthias 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 95*a265b909SMatthias Ringwald #if !defined(HAVE_MALLOC) && !defined(MAX_NR_L2CAP_SERVICES) 96*a265b909SMatthias Ringwald #if defined(MAX_NO_L2CAP_SERVICES) 97*a265b909SMatthias 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" 98*a265b909SMatthias Ringwald #else 99*a265b909SMatthias Ringwald #define MAX_NR_L2CAP_SERVICES 0 100*a265b909SMatthias Ringwald #endif 101*a265b909SMatthias Ringwald #endif 102*a265b909SMatthias Ringwald 103*a265b909SMatthias Ringwald #ifdef MAX_NR_L2CAP_SERVICES 104*a265b909SMatthias Ringwald #if MAX_NR_L2CAP_SERVICES > 0 105*a265b909SMatthias 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 133*a265b909SMatthias Ringwald #if !defined(HAVE_MALLOC) && !defined(MAX_NR_L2CAP_CHANNELS) 134*a265b909SMatthias Ringwald #if defined(MAX_NO_L2CAP_CHANNELS) 135*a265b909SMatthias 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" 136*a265b909SMatthias Ringwald #else 137*a265b909SMatthias Ringwald #define MAX_NR_L2CAP_CHANNELS 0 138*a265b909SMatthias Ringwald #endif 139*a265b909SMatthias Ringwald #endif 140*a265b909SMatthias Ringwald 141*a265b909SMatthias Ringwald #ifdef MAX_NR_L2CAP_CHANNELS 142*a265b909SMatthias Ringwald #if MAX_NR_L2CAP_CHANNELS > 0 143*a265b909SMatthias 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 172*a265b909SMatthias Ringwald #if !defined(HAVE_MALLOC) && !defined(MAX_NR_RFCOMM_MULTIPLEXERS) 173*a265b909SMatthias Ringwald #if defined(MAX_NO_RFCOMM_MULTIPLEXERS) 174*a265b909SMatthias 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" 175*a265b909SMatthias Ringwald #else 176*a265b909SMatthias Ringwald #define MAX_NR_RFCOMM_MULTIPLEXERS 0 177*a265b909SMatthias Ringwald #endif 178*a265b909SMatthias Ringwald #endif 179*a265b909SMatthias Ringwald 180*a265b909SMatthias Ringwald #ifdef MAX_NR_RFCOMM_MULTIPLEXERS 181*a265b909SMatthias Ringwald #if MAX_NR_RFCOMM_MULTIPLEXERS > 0 182*a265b909SMatthias 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 210*a265b909SMatthias Ringwald #if !defined(HAVE_MALLOC) && !defined(MAX_NR_RFCOMM_SERVICES) 211*a265b909SMatthias Ringwald #if defined(MAX_NO_RFCOMM_SERVICES) 212*a265b909SMatthias 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" 213*a265b909SMatthias Ringwald #else 214*a265b909SMatthias Ringwald #define MAX_NR_RFCOMM_SERVICES 0 215*a265b909SMatthias Ringwald #endif 216*a265b909SMatthias Ringwald #endif 217*a265b909SMatthias Ringwald 218*a265b909SMatthias Ringwald #ifdef MAX_NR_RFCOMM_SERVICES 219*a265b909SMatthias Ringwald #if MAX_NR_RFCOMM_SERVICES > 0 220*a265b909SMatthias 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 248*a265b909SMatthias Ringwald #if !defined(HAVE_MALLOC) && !defined(MAX_NR_RFCOMM_CHANNELS) 249*a265b909SMatthias Ringwald #if defined(MAX_NO_RFCOMM_CHANNELS) 250*a265b909SMatthias 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" 251*a265b909SMatthias Ringwald #else 252*a265b909SMatthias Ringwald #define MAX_NR_RFCOMM_CHANNELS 0 253*a265b909SMatthias Ringwald #endif 254*a265b909SMatthias Ringwald #endif 255*a265b909SMatthias Ringwald 256*a265b909SMatthias Ringwald #ifdef MAX_NR_RFCOMM_CHANNELS 257*a265b909SMatthias Ringwald #if MAX_NR_RFCOMM_CHANNELS > 0 258*a265b909SMatthias 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 287*a265b909SMatthias Ringwald #if !defined(HAVE_MALLOC) && !defined(MAX_NR_BTSTACK_LINK_KEY_DB_MEMORY_ENTRIES) 288*a265b909SMatthias Ringwald #if defined(MAX_NO_BTSTACK_LINK_KEY_DB_MEMORY_ENTRIES) 289*a265b909SMatthias 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" 290*a265b909SMatthias Ringwald #else 291*a265b909SMatthias Ringwald #define MAX_NR_BTSTACK_LINK_KEY_DB_MEMORY_ENTRIES 0 292*a265b909SMatthias Ringwald #endif 293*a265b909SMatthias Ringwald #endif 294*a265b909SMatthias Ringwald 295*a265b909SMatthias Ringwald #ifdef MAX_NR_BTSTACK_LINK_KEY_DB_MEMORY_ENTRIES 296*a265b909SMatthias Ringwald #if MAX_NR_BTSTACK_LINK_KEY_DB_MEMORY_ENTRIES > 0 297*a265b909SMatthias 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 326*a265b909SMatthias Ringwald #if !defined(HAVE_MALLOC) && !defined(MAX_NR_BNEP_SERVICES) 327*a265b909SMatthias Ringwald #if defined(MAX_NO_BNEP_SERVICES) 328*a265b909SMatthias 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" 329*a265b909SMatthias Ringwald #else 330*a265b909SMatthias Ringwald #define MAX_NR_BNEP_SERVICES 0 331*a265b909SMatthias Ringwald #endif 332*a265b909SMatthias Ringwald #endif 333*a265b909SMatthias Ringwald 334*a265b909SMatthias Ringwald #ifdef MAX_NR_BNEP_SERVICES 335*a265b909SMatthias Ringwald #if MAX_NR_BNEP_SERVICES > 0 336*a265b909SMatthias 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 364*a265b909SMatthias Ringwald #if !defined(HAVE_MALLOC) && !defined(MAX_NR_BNEP_CHANNELS) 365*a265b909SMatthias Ringwald #if defined(MAX_NO_BNEP_CHANNELS) 366*a265b909SMatthias 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" 367*a265b909SMatthias Ringwald #else 368*a265b909SMatthias Ringwald #define MAX_NR_BNEP_CHANNELS 0 369*a265b909SMatthias Ringwald #endif 370*a265b909SMatthias Ringwald #endif 371*a265b909SMatthias Ringwald 372*a265b909SMatthias Ringwald #ifdef MAX_NR_BNEP_CHANNELS 373*a265b909SMatthias Ringwald #if MAX_NR_BNEP_CHANNELS > 0 374*a265b909SMatthias 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 403*a265b909SMatthias Ringwald #if !defined(HAVE_MALLOC) && !defined(MAX_NR_HFP_CONNECTIONS) 404*a265b909SMatthias Ringwald #if defined(MAX_NO_HFP_CONNECTIONS) 405*a265b909SMatthias 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" 406*a265b909SMatthias Ringwald #else 407*a265b909SMatthias Ringwald #define MAX_NR_HFP_CONNECTIONS 0 408*a265b909SMatthias Ringwald #endif 409*a265b909SMatthias Ringwald #endif 410*a265b909SMatthias Ringwald 411*a265b909SMatthias Ringwald #ifdef MAX_NR_HFP_CONNECTIONS 412*a265b909SMatthias Ringwald #if MAX_NR_HFP_CONNECTIONS > 0 413*a265b909SMatthias 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 442*a265b909SMatthias Ringwald #if !defined(HAVE_MALLOC) && !defined(MAX_NR_SERVICE_RECORD_ITEMS) 443*a265b909SMatthias Ringwald #if defined(MAX_NO_SERVICE_RECORD_ITEMS) 444*a265b909SMatthias 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" 445*a265b909SMatthias Ringwald #else 446*a265b909SMatthias Ringwald #define MAX_NR_SERVICE_RECORD_ITEMS 0 447*a265b909SMatthias Ringwald #endif 448*a265b909SMatthias Ringwald #endif 449*a265b909SMatthias Ringwald 450*a265b909SMatthias Ringwald #ifdef MAX_NR_SERVICE_RECORD_ITEMS 451*a265b909SMatthias Ringwald #if MAX_NR_SERVICE_RECORD_ITEMS > 0 452*a265b909SMatthias 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 479a9a4c409SMatthias Ringwald #ifdef ENABLE_BLE 4802e97c149S[email protected] 4812e97c149S[email protected] // MARK: gatt_client_t 482*a265b909SMatthias Ringwald #if !defined(HAVE_MALLOC) && !defined(MAX_NR_GATT_CLIENTS) 483*a265b909SMatthias Ringwald #if defined(MAX_NO_GATT_CLIENTS) 484*a265b909SMatthias 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" 485*a265b909SMatthias Ringwald #else 486*a265b909SMatthias Ringwald #define MAX_NR_GATT_CLIENTS 0 487*a265b909SMatthias Ringwald #endif 488*a265b909SMatthias Ringwald #endif 489*a265b909SMatthias Ringwald 490*a265b909SMatthias Ringwald #ifdef MAX_NR_GATT_CLIENTS 491*a265b909SMatthias Ringwald #if MAX_NR_GATT_CLIENTS > 0 492*a265b909SMatthias Ringwald static gatt_client_t gatt_client_storage[MAX_NR_GATT_CLIENTS]; 49329d0c4f7SMatthias Ringwald static btstack_memory_pool_t gatt_client_pool; 494d0fdae3cS[email protected] gatt_client_t * btstack_memory_gatt_client_get(void){ 49529d0c4f7SMatthias Ringwald return (gatt_client_t *) btstack_memory_pool_get(&gatt_client_pool); 496d0fdae3cS[email protected] } 497d0fdae3cS[email protected] void btstack_memory_gatt_client_free(gatt_client_t *gatt_client){ 49829d0c4f7SMatthias Ringwald btstack_memory_pool_free(&gatt_client_pool, gatt_client); 499d0fdae3cS[email protected] } 500d0fdae3cS[email protected] #else 501d0fdae3cS[email protected] gatt_client_t * btstack_memory_gatt_client_get(void){ 502d0fdae3cS[email protected] return NULL; 503d0fdae3cS[email protected] } 504d0fdae3cS[email protected] void btstack_memory_gatt_client_free(gatt_client_t *gatt_client){ 5056f7ecb09S[email protected] // silence compiler warning about unused parameter in a portable way 5066f7ecb09S[email protected] (void) gatt_client; 507d0fdae3cS[email protected] }; 508d0fdae3cS[email protected] #endif 509d0fdae3cS[email protected] #elif defined(HAVE_MALLOC) 510d0fdae3cS[email protected] gatt_client_t * btstack_memory_gatt_client_get(void){ 511d0fdae3cS[email protected] return (gatt_client_t*) malloc(sizeof(gatt_client_t)); 512d0fdae3cS[email protected] } 513d0fdae3cS[email protected] void btstack_memory_gatt_client_free(gatt_client_t *gatt_client){ 514d0fdae3cS[email protected] free(gatt_client); 515d0fdae3cS[email protected] } 516d0fdae3cS[email protected] #endif 5172e97c149S[email protected] 5182e97c149S[email protected] 519656bec4fSMatthias Ringwald // MARK: whitelist_entry_t 520*a265b909SMatthias Ringwald #if !defined(HAVE_MALLOC) && !defined(MAX_NR_WHITELIST_ENTRIES) 521*a265b909SMatthias Ringwald #if defined(MAX_NO_WHITELIST_ENTRIES) 522*a265b909SMatthias 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" 523*a265b909SMatthias Ringwald #else 524*a265b909SMatthias Ringwald #define MAX_NR_WHITELIST_ENTRIES 0 525*a265b909SMatthias Ringwald #endif 526*a265b909SMatthias Ringwald #endif 527*a265b909SMatthias Ringwald 528*a265b909SMatthias Ringwald #ifdef MAX_NR_WHITELIST_ENTRIES 529*a265b909SMatthias Ringwald #if MAX_NR_WHITELIST_ENTRIES > 0 530*a265b909SMatthias Ringwald static whitelist_entry_t whitelist_entry_storage[MAX_NR_WHITELIST_ENTRIES]; 53129d0c4f7SMatthias Ringwald static btstack_memory_pool_t whitelist_entry_pool; 532656bec4fSMatthias Ringwald whitelist_entry_t * btstack_memory_whitelist_entry_get(void){ 53329d0c4f7SMatthias Ringwald return (whitelist_entry_t *) btstack_memory_pool_get(&whitelist_entry_pool); 534656bec4fSMatthias Ringwald } 535656bec4fSMatthias Ringwald void btstack_memory_whitelist_entry_free(whitelist_entry_t *whitelist_entry){ 53629d0c4f7SMatthias Ringwald btstack_memory_pool_free(&whitelist_entry_pool, whitelist_entry); 537656bec4fSMatthias Ringwald } 538656bec4fSMatthias Ringwald #else 539656bec4fSMatthias Ringwald whitelist_entry_t * btstack_memory_whitelist_entry_get(void){ 540656bec4fSMatthias Ringwald return NULL; 541656bec4fSMatthias Ringwald } 542656bec4fSMatthias Ringwald void btstack_memory_whitelist_entry_free(whitelist_entry_t *whitelist_entry){ 543656bec4fSMatthias Ringwald // silence compiler warning about unused parameter in a portable way 544656bec4fSMatthias Ringwald (void) whitelist_entry; 545656bec4fSMatthias Ringwald }; 546656bec4fSMatthias Ringwald #endif 547656bec4fSMatthias Ringwald #elif defined(HAVE_MALLOC) 548656bec4fSMatthias Ringwald whitelist_entry_t * btstack_memory_whitelist_entry_get(void){ 549656bec4fSMatthias Ringwald return (whitelist_entry_t*) malloc(sizeof(whitelist_entry_t)); 550656bec4fSMatthias Ringwald } 551656bec4fSMatthias Ringwald void btstack_memory_whitelist_entry_free(whitelist_entry_t *whitelist_entry){ 552656bec4fSMatthias Ringwald free(whitelist_entry); 553656bec4fSMatthias Ringwald } 554656bec4fSMatthias Ringwald #endif 555656bec4fSMatthias Ringwald 556656bec4fSMatthias Ringwald 557cf49570bSMatthias Ringwald // MARK: sm_lookup_entry_t 558*a265b909SMatthias Ringwald #if !defined(HAVE_MALLOC) && !defined(MAX_NR_SM_LOOKUP_ENTRIES) 559*a265b909SMatthias Ringwald #if defined(MAX_NO_SM_LOOKUP_ENTRIES) 560*a265b909SMatthias 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" 561*a265b909SMatthias Ringwald #else 562*a265b909SMatthias Ringwald #define MAX_NR_SM_LOOKUP_ENTRIES 0 563*a265b909SMatthias Ringwald #endif 564*a265b909SMatthias Ringwald #endif 565*a265b909SMatthias Ringwald 566*a265b909SMatthias Ringwald #ifdef MAX_NR_SM_LOOKUP_ENTRIES 567*a265b909SMatthias Ringwald #if MAX_NR_SM_LOOKUP_ENTRIES > 0 568*a265b909SMatthias Ringwald static sm_lookup_entry_t sm_lookup_entry_storage[MAX_NR_SM_LOOKUP_ENTRIES]; 56929d0c4f7SMatthias Ringwald static btstack_memory_pool_t sm_lookup_entry_pool; 570cf49570bSMatthias Ringwald sm_lookup_entry_t * btstack_memory_sm_lookup_entry_get(void){ 57129d0c4f7SMatthias Ringwald return (sm_lookup_entry_t *) btstack_memory_pool_get(&sm_lookup_entry_pool); 572cf49570bSMatthias Ringwald } 573cf49570bSMatthias Ringwald void btstack_memory_sm_lookup_entry_free(sm_lookup_entry_t *sm_lookup_entry){ 57429d0c4f7SMatthias Ringwald btstack_memory_pool_free(&sm_lookup_entry_pool, sm_lookup_entry); 575cf49570bSMatthias Ringwald } 576cf49570bSMatthias Ringwald #else 577cf49570bSMatthias Ringwald sm_lookup_entry_t * btstack_memory_sm_lookup_entry_get(void){ 578cf49570bSMatthias Ringwald return NULL; 579cf49570bSMatthias Ringwald } 580cf49570bSMatthias Ringwald void btstack_memory_sm_lookup_entry_free(sm_lookup_entry_t *sm_lookup_entry){ 581cf49570bSMatthias Ringwald // silence compiler warning about unused parameter in a portable way 582cf49570bSMatthias Ringwald (void) sm_lookup_entry; 583cf49570bSMatthias Ringwald }; 584cf49570bSMatthias Ringwald #endif 585cf49570bSMatthias Ringwald #elif defined(HAVE_MALLOC) 586cf49570bSMatthias Ringwald sm_lookup_entry_t * btstack_memory_sm_lookup_entry_get(void){ 587cf49570bSMatthias Ringwald return (sm_lookup_entry_t*) malloc(sizeof(sm_lookup_entry_t)); 588cf49570bSMatthias Ringwald } 589cf49570bSMatthias Ringwald void btstack_memory_sm_lookup_entry_free(sm_lookup_entry_t *sm_lookup_entry){ 590cf49570bSMatthias Ringwald free(sm_lookup_entry); 591cf49570bSMatthias Ringwald } 592cf49570bSMatthias Ringwald #endif 593cf49570bSMatthias Ringwald 594cf49570bSMatthias Ringwald 5952e97c149S[email protected] #endif 596a3b02b71Smatthias.ringwald // init 597a3b02b71Smatthias.ringwald void btstack_memory_init(void){ 598*a265b909SMatthias Ringwald #if MAX_NR_HCI_CONNECTIONS > 0 599*a265b909SMatthias Ringwald btstack_memory_pool_create(&hci_connection_pool, hci_connection_storage, MAX_NR_HCI_CONNECTIONS, sizeof(hci_connection_t)); 600a3b02b71Smatthias.ringwald #endif 601*a265b909SMatthias Ringwald #if MAX_NR_L2CAP_SERVICES > 0 602*a265b909SMatthias Ringwald btstack_memory_pool_create(&l2cap_service_pool, l2cap_service_storage, MAX_NR_L2CAP_SERVICES, sizeof(l2cap_service_t)); 603a3b02b71Smatthias.ringwald #endif 604*a265b909SMatthias Ringwald #if MAX_NR_L2CAP_CHANNELS > 0 605*a265b909SMatthias Ringwald btstack_memory_pool_create(&l2cap_channel_pool, l2cap_channel_storage, MAX_NR_L2CAP_CHANNELS, sizeof(l2cap_channel_t)); 606a3b02b71Smatthias.ringwald #endif 607*a265b909SMatthias Ringwald #if MAX_NR_RFCOMM_MULTIPLEXERS > 0 608*a265b909SMatthias Ringwald btstack_memory_pool_create(&rfcomm_multiplexer_pool, rfcomm_multiplexer_storage, MAX_NR_RFCOMM_MULTIPLEXERS, sizeof(rfcomm_multiplexer_t)); 609a3b02b71Smatthias.ringwald #endif 610*a265b909SMatthias Ringwald #if MAX_NR_RFCOMM_SERVICES > 0 611*a265b909SMatthias Ringwald btstack_memory_pool_create(&rfcomm_service_pool, rfcomm_service_storage, MAX_NR_RFCOMM_SERVICES, sizeof(rfcomm_service_t)); 612a3b02b71Smatthias.ringwald #endif 613*a265b909SMatthias Ringwald #if MAX_NR_RFCOMM_CHANNELS > 0 614*a265b909SMatthias Ringwald btstack_memory_pool_create(&rfcomm_channel_pool, rfcomm_channel_storage, MAX_NR_RFCOMM_CHANNELS, sizeof(rfcomm_channel_t)); 615a3b02b71Smatthias.ringwald #endif 616*a265b909SMatthias Ringwald #if MAX_NR_BTSTACK_LINK_KEY_DB_MEMORY_ENTRIES > 0 617*a265b909SMatthias 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)); 6181801b596Smatthias.ringwald #endif 619*a265b909SMatthias Ringwald #if MAX_NR_BNEP_SERVICES > 0 620*a265b909SMatthias Ringwald btstack_memory_pool_create(&bnep_service_pool, bnep_service_storage, MAX_NR_BNEP_SERVICES, sizeof(bnep_service_t)); 6212e97c149S[email protected] #endif 622*a265b909SMatthias Ringwald #if MAX_NR_BNEP_CHANNELS > 0 623*a265b909SMatthias Ringwald btstack_memory_pool_create(&bnep_channel_pool, bnep_channel_storage, MAX_NR_BNEP_CHANNELS, sizeof(bnep_channel_t)); 6242e97c149S[email protected] #endif 625*a265b909SMatthias Ringwald #if MAX_NR_HFP_CONNECTIONS > 0 626*a265b909SMatthias Ringwald btstack_memory_pool_create(&hfp_connection_pool, hfp_connection_storage, MAX_NR_HFP_CONNECTIONS, sizeof(hfp_connection_t)); 627ea5029c9SMilanka Ringwald #endif 628*a265b909SMatthias Ringwald #if MAX_NR_SERVICE_RECORD_ITEMS > 0 629*a265b909SMatthias Ringwald btstack_memory_pool_create(&service_record_item_pool, service_record_item_storage, MAX_NR_SERVICE_RECORD_ITEMS, sizeof(service_record_item_t)); 630cd9ee144SMatthias Ringwald #endif 631a9a4c409SMatthias Ringwald #ifdef ENABLE_BLE 632*a265b909SMatthias Ringwald #if MAX_NR_GATT_CLIENTS > 0 633*a265b909SMatthias Ringwald btstack_memory_pool_create(&gatt_client_pool, gatt_client_storage, MAX_NR_GATT_CLIENTS, sizeof(gatt_client_t)); 634d0fdae3cS[email protected] #endif 635*a265b909SMatthias Ringwald #if MAX_NR_WHITELIST_ENTRIES > 0 636*a265b909SMatthias Ringwald btstack_memory_pool_create(&whitelist_entry_pool, whitelist_entry_storage, MAX_NR_WHITELIST_ENTRIES, sizeof(whitelist_entry_t)); 637656bec4fSMatthias Ringwald #endif 638*a265b909SMatthias Ringwald #if MAX_NR_SM_LOOKUP_ENTRIES > 0 639*a265b909SMatthias Ringwald btstack_memory_pool_create(&sm_lookup_entry_pool, sm_lookup_entry_storage, MAX_NR_SM_LOOKUP_ENTRIES, sizeof(sm_lookup_entry_t)); 640cf49570bSMatthias Ringwald #endif 641a7d12effS[email protected] #endif 642a3b02b71Smatthias.ringwald } 643