xref: /btstack/src/btstack_memory.c (revision a9a4c409241c41c1d2c83251f00751c1b79514af)
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 /*
40a3b02b71Smatthias.ringwald  *  btstsack_memory.h
41a3b02b71Smatthias.ringwald  *
42a3b02b71Smatthias.ringwald  *  @brief BTstack memory management via configurable memory pools
43a3b02b71Smatthias.ringwald  *
446f7ecb09S[email protected]  *  @note code semi-atuomatically generated by tools/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
56a3b02b71Smatthias.ringwald #ifdef MAX_NO_HCI_CONNECTIONS
57c4d3f927Smatthias.ringwald #if MAX_NO_HCI_CONNECTIONS > 0
58a3b02b71Smatthias.ringwald static hci_connection_t hci_connection_storage[MAX_NO_HCI_CONNECTIONS];
5929d0c4f7SMatthias Ringwald static btstack_memory_pool_t hci_connection_pool;
606527a633S[email protected] hci_connection_t * btstack_memory_hci_connection_get(void){
6129d0c4f7SMatthias Ringwald     return (hci_connection_t *) btstack_memory_pool_get(&hci_connection_pool);
62a3b02b71Smatthias.ringwald }
636527a633S[email protected] void btstack_memory_hci_connection_free(hci_connection_t *hci_connection){
6429d0c4f7SMatthias Ringwald     btstack_memory_pool_free(&hci_connection_pool, hci_connection);
65a3b02b71Smatthias.ringwald }
66c4d3f927Smatthias.ringwald #else
676527a633S[email protected] hci_connection_t * btstack_memory_hci_connection_get(void){
68c4d3f927Smatthias.ringwald     return NULL;
69c4d3f927Smatthias.ringwald }
706527a633S[email protected] void btstack_memory_hci_connection_free(hci_connection_t *hci_connection){
716f7ecb09S[email protected]     // silence compiler warning about unused parameter in a portable way
722e97c149S[email protected]     (void) hci_connection;
73c4d3f927Smatthias.ringwald };
74c4d3f927Smatthias.ringwald #endif
75a3b02b71Smatthias.ringwald #elif defined(HAVE_MALLOC)
766527a633S[email protected] hci_connection_t * btstack_memory_hci_connection_get(void){
776527a633S[email protected]     return (hci_connection_t*) malloc(sizeof(hci_connection_t));
78a3b02b71Smatthias.ringwald }
796527a633S[email protected] void btstack_memory_hci_connection_free(hci_connection_t *hci_connection){
80a3b02b71Smatthias.ringwald     free(hci_connection);
81a3b02b71Smatthias.ringwald }
82e045abdeSmatthias.ringwald #else
836527a633S[email protected] #error "Neither HAVE_MALLOC nor MAX_NO_HCI_CONNECTIONS for struct hci_connection is defined. Please, edit the config file."
84a3b02b71Smatthias.ringwald #endif
85a3b02b71Smatthias.ringwald 
86a3b02b71Smatthias.ringwald 
872e97c149S[email protected] 
88a3b02b71Smatthias.ringwald // MARK: l2cap_service_t
89a3b02b71Smatthias.ringwald #ifdef MAX_NO_L2CAP_SERVICES
90c4d3f927Smatthias.ringwald #if MAX_NO_L2CAP_SERVICES > 0
91a3b02b71Smatthias.ringwald static l2cap_service_t l2cap_service_storage[MAX_NO_L2CAP_SERVICES];
9229d0c4f7SMatthias Ringwald static btstack_memory_pool_t l2cap_service_pool;
936527a633S[email protected] l2cap_service_t * btstack_memory_l2cap_service_get(void){
9429d0c4f7SMatthias Ringwald     return (l2cap_service_t *) btstack_memory_pool_get(&l2cap_service_pool);
95a3b02b71Smatthias.ringwald }
966527a633S[email protected] void btstack_memory_l2cap_service_free(l2cap_service_t *l2cap_service){
9729d0c4f7SMatthias Ringwald     btstack_memory_pool_free(&l2cap_service_pool, l2cap_service);
98a3b02b71Smatthias.ringwald }
99c4d3f927Smatthias.ringwald #else
1006527a633S[email protected] l2cap_service_t * btstack_memory_l2cap_service_get(void){
101c4d3f927Smatthias.ringwald     return NULL;
102c4d3f927Smatthias.ringwald }
1036527a633S[email protected] void btstack_memory_l2cap_service_free(l2cap_service_t *l2cap_service){
1046f7ecb09S[email protected]     // silence compiler warning about unused parameter in a portable way
1056f7ecb09S[email protected]     (void) l2cap_service;
106c4d3f927Smatthias.ringwald };
107c4d3f927Smatthias.ringwald #endif
108a3b02b71Smatthias.ringwald #elif defined(HAVE_MALLOC)
1096527a633S[email protected] l2cap_service_t * btstack_memory_l2cap_service_get(void){
1106527a633S[email protected]     return (l2cap_service_t*) malloc(sizeof(l2cap_service_t));
111a3b02b71Smatthias.ringwald }
1126527a633S[email protected] void btstack_memory_l2cap_service_free(l2cap_service_t *l2cap_service){
113a3b02b71Smatthias.ringwald     free(l2cap_service);
114a3b02b71Smatthias.ringwald }
115e045abdeSmatthias.ringwald #else
1166527a633S[email protected] #error "Neither HAVE_MALLOC nor MAX_NO_L2CAP_SERVICES for struct l2cap_service is defined. Please, edit the config file."
117a3b02b71Smatthias.ringwald #endif
118a3b02b71Smatthias.ringwald 
119a3b02b71Smatthias.ringwald 
120a3b02b71Smatthias.ringwald // MARK: l2cap_channel_t
121a3b02b71Smatthias.ringwald #ifdef MAX_NO_L2CAP_CHANNELS
122c4d3f927Smatthias.ringwald #if MAX_NO_L2CAP_CHANNELS > 0
123a3b02b71Smatthias.ringwald static l2cap_channel_t l2cap_channel_storage[MAX_NO_L2CAP_CHANNELS];
12429d0c4f7SMatthias Ringwald static btstack_memory_pool_t l2cap_channel_pool;
1256527a633S[email protected] l2cap_channel_t * btstack_memory_l2cap_channel_get(void){
12629d0c4f7SMatthias Ringwald     return (l2cap_channel_t *) btstack_memory_pool_get(&l2cap_channel_pool);
127a3b02b71Smatthias.ringwald }
1286527a633S[email protected] void btstack_memory_l2cap_channel_free(l2cap_channel_t *l2cap_channel){
12929d0c4f7SMatthias Ringwald     btstack_memory_pool_free(&l2cap_channel_pool, l2cap_channel);
130a3b02b71Smatthias.ringwald }
131c4d3f927Smatthias.ringwald #else
1326527a633S[email protected] l2cap_channel_t * btstack_memory_l2cap_channel_get(void){
133c4d3f927Smatthias.ringwald     return NULL;
134c4d3f927Smatthias.ringwald }
1356527a633S[email protected] void btstack_memory_l2cap_channel_free(l2cap_channel_t *l2cap_channel){
1366f7ecb09S[email protected]     // silence compiler warning about unused parameter in a portable way
1376f7ecb09S[email protected]     (void) l2cap_channel;
138c4d3f927Smatthias.ringwald };
139c4d3f927Smatthias.ringwald #endif
140a3b02b71Smatthias.ringwald #elif defined(HAVE_MALLOC)
1416527a633S[email protected] l2cap_channel_t * btstack_memory_l2cap_channel_get(void){
1426527a633S[email protected]     return (l2cap_channel_t*) malloc(sizeof(l2cap_channel_t));
143a3b02b71Smatthias.ringwald }
1446527a633S[email protected] void btstack_memory_l2cap_channel_free(l2cap_channel_t *l2cap_channel){
145a3b02b71Smatthias.ringwald     free(l2cap_channel);
146a3b02b71Smatthias.ringwald }
147e045abdeSmatthias.ringwald #else
1486527a633S[email protected] #error "Neither HAVE_MALLOC nor MAX_NO_L2CAP_CHANNELS for struct l2cap_channel is defined. Please, edit the config file."
149a3b02b71Smatthias.ringwald #endif
150a3b02b71Smatthias.ringwald 
151a3b02b71Smatthias.ringwald 
1522e97c149S[email protected] 
153a3b02b71Smatthias.ringwald // MARK: rfcomm_multiplexer_t
154a3b02b71Smatthias.ringwald #ifdef MAX_NO_RFCOMM_MULTIPLEXERS
155c4d3f927Smatthias.ringwald #if MAX_NO_RFCOMM_MULTIPLEXERS > 0
156a3b02b71Smatthias.ringwald static rfcomm_multiplexer_t rfcomm_multiplexer_storage[MAX_NO_RFCOMM_MULTIPLEXERS];
15729d0c4f7SMatthias Ringwald static btstack_memory_pool_t rfcomm_multiplexer_pool;
1586527a633S[email protected] rfcomm_multiplexer_t * btstack_memory_rfcomm_multiplexer_get(void){
15929d0c4f7SMatthias Ringwald     return (rfcomm_multiplexer_t *) btstack_memory_pool_get(&rfcomm_multiplexer_pool);
160a3b02b71Smatthias.ringwald }
1616527a633S[email protected] void btstack_memory_rfcomm_multiplexer_free(rfcomm_multiplexer_t *rfcomm_multiplexer){
16229d0c4f7SMatthias Ringwald     btstack_memory_pool_free(&rfcomm_multiplexer_pool, rfcomm_multiplexer);
163a3b02b71Smatthias.ringwald }
164c4d3f927Smatthias.ringwald #else
1656527a633S[email protected] rfcomm_multiplexer_t * btstack_memory_rfcomm_multiplexer_get(void){
166c4d3f927Smatthias.ringwald     return NULL;
167c4d3f927Smatthias.ringwald }
1686527a633S[email protected] void btstack_memory_rfcomm_multiplexer_free(rfcomm_multiplexer_t *rfcomm_multiplexer){
1696f7ecb09S[email protected]     // silence compiler warning about unused parameter in a portable way
1706f7ecb09S[email protected]     (void) rfcomm_multiplexer;
171c4d3f927Smatthias.ringwald };
172c4d3f927Smatthias.ringwald #endif
173a3b02b71Smatthias.ringwald #elif defined(HAVE_MALLOC)
1746527a633S[email protected] rfcomm_multiplexer_t * btstack_memory_rfcomm_multiplexer_get(void){
1756527a633S[email protected]     return (rfcomm_multiplexer_t*) malloc(sizeof(rfcomm_multiplexer_t));
176a3b02b71Smatthias.ringwald }
1776527a633S[email protected] void btstack_memory_rfcomm_multiplexer_free(rfcomm_multiplexer_t *rfcomm_multiplexer){
178a3b02b71Smatthias.ringwald     free(rfcomm_multiplexer);
179a3b02b71Smatthias.ringwald }
180e045abdeSmatthias.ringwald #else
1816527a633S[email protected] #error "Neither HAVE_MALLOC nor MAX_NO_RFCOMM_MULTIPLEXERS for struct rfcomm_multiplexer is defined. Please, edit the config file."
182a3b02b71Smatthias.ringwald #endif
183a3b02b71Smatthias.ringwald 
184a3b02b71Smatthias.ringwald 
185a3b02b71Smatthias.ringwald // MARK: rfcomm_service_t
186a3b02b71Smatthias.ringwald #ifdef MAX_NO_RFCOMM_SERVICES
187c4d3f927Smatthias.ringwald #if MAX_NO_RFCOMM_SERVICES > 0
188a3b02b71Smatthias.ringwald static rfcomm_service_t rfcomm_service_storage[MAX_NO_RFCOMM_SERVICES];
18929d0c4f7SMatthias Ringwald static btstack_memory_pool_t rfcomm_service_pool;
1906527a633S[email protected] rfcomm_service_t * btstack_memory_rfcomm_service_get(void){
19129d0c4f7SMatthias Ringwald     return (rfcomm_service_t *) btstack_memory_pool_get(&rfcomm_service_pool);
192a3b02b71Smatthias.ringwald }
1936527a633S[email protected] void btstack_memory_rfcomm_service_free(rfcomm_service_t *rfcomm_service){
19429d0c4f7SMatthias Ringwald     btstack_memory_pool_free(&rfcomm_service_pool, rfcomm_service);
195a3b02b71Smatthias.ringwald }
196c4d3f927Smatthias.ringwald #else
1976527a633S[email protected] rfcomm_service_t * btstack_memory_rfcomm_service_get(void){
198c4d3f927Smatthias.ringwald     return NULL;
199c4d3f927Smatthias.ringwald }
2006527a633S[email protected] void btstack_memory_rfcomm_service_free(rfcomm_service_t *rfcomm_service){
2016f7ecb09S[email protected]     // silence compiler warning about unused parameter in a portable way
2026f7ecb09S[email protected]     (void) rfcomm_service;
203c4d3f927Smatthias.ringwald };
204c4d3f927Smatthias.ringwald #endif
205a3b02b71Smatthias.ringwald #elif defined(HAVE_MALLOC)
2066527a633S[email protected] rfcomm_service_t * btstack_memory_rfcomm_service_get(void){
2076527a633S[email protected]     return (rfcomm_service_t*) malloc(sizeof(rfcomm_service_t));
208a3b02b71Smatthias.ringwald }
2096527a633S[email protected] void btstack_memory_rfcomm_service_free(rfcomm_service_t *rfcomm_service){
210a3b02b71Smatthias.ringwald     free(rfcomm_service);
211a3b02b71Smatthias.ringwald }
212e045abdeSmatthias.ringwald #else
2136527a633S[email protected] #error "Neither HAVE_MALLOC nor MAX_NO_RFCOMM_SERVICES for struct rfcomm_service is defined. Please, edit the config file."
214a3b02b71Smatthias.ringwald #endif
215a3b02b71Smatthias.ringwald 
216a3b02b71Smatthias.ringwald 
217a3b02b71Smatthias.ringwald // MARK: rfcomm_channel_t
218a3b02b71Smatthias.ringwald #ifdef MAX_NO_RFCOMM_CHANNELS
219c4d3f927Smatthias.ringwald #if MAX_NO_RFCOMM_CHANNELS > 0
220a3b02b71Smatthias.ringwald static rfcomm_channel_t rfcomm_channel_storage[MAX_NO_RFCOMM_CHANNELS];
22129d0c4f7SMatthias Ringwald static btstack_memory_pool_t rfcomm_channel_pool;
2226527a633S[email protected] rfcomm_channel_t * btstack_memory_rfcomm_channel_get(void){
22329d0c4f7SMatthias Ringwald     return (rfcomm_channel_t *) btstack_memory_pool_get(&rfcomm_channel_pool);
224a3b02b71Smatthias.ringwald }
2256527a633S[email protected] void btstack_memory_rfcomm_channel_free(rfcomm_channel_t *rfcomm_channel){
22629d0c4f7SMatthias Ringwald     btstack_memory_pool_free(&rfcomm_channel_pool, rfcomm_channel);
227a3b02b71Smatthias.ringwald }
228c4d3f927Smatthias.ringwald #else
2296527a633S[email protected] rfcomm_channel_t * btstack_memory_rfcomm_channel_get(void){
230c4d3f927Smatthias.ringwald     return NULL;
231c4d3f927Smatthias.ringwald }
2326527a633S[email protected] void btstack_memory_rfcomm_channel_free(rfcomm_channel_t *rfcomm_channel){
2336f7ecb09S[email protected]     // silence compiler warning about unused parameter in a portable way
2346f7ecb09S[email protected]     (void) rfcomm_channel;
235c4d3f927Smatthias.ringwald };
236c4d3f927Smatthias.ringwald #endif
237a3b02b71Smatthias.ringwald #elif defined(HAVE_MALLOC)
2386527a633S[email protected] rfcomm_channel_t * btstack_memory_rfcomm_channel_get(void){
2396527a633S[email protected]     return (rfcomm_channel_t*) malloc(sizeof(rfcomm_channel_t));
240a3b02b71Smatthias.ringwald }
2416527a633S[email protected] void btstack_memory_rfcomm_channel_free(rfcomm_channel_t *rfcomm_channel){
242a3b02b71Smatthias.ringwald     free(rfcomm_channel);
243a3b02b71Smatthias.ringwald }
244e045abdeSmatthias.ringwald #else
2456527a633S[email protected] #error "Neither HAVE_MALLOC nor MAX_NO_RFCOMM_CHANNELS for struct rfcomm_channel is defined. Please, edit the config file."
246a3b02b71Smatthias.ringwald #endif
247a3b02b71Smatthias.ringwald 
248fdb398c2S[email protected] 
249e0e5e285Smatthias.ringwald 
250e0e5e285Smatthias.ringwald // MARK: db_mem_device_name_t
251e0e5e285Smatthias.ringwald #ifdef MAX_NO_DB_MEM_DEVICE_NAMES
252c4d3f927Smatthias.ringwald #if MAX_NO_DB_MEM_DEVICE_NAMES > 0
253e0e5e285Smatthias.ringwald static db_mem_device_name_t db_mem_device_name_storage[MAX_NO_DB_MEM_DEVICE_NAMES];
25429d0c4f7SMatthias Ringwald static btstack_memory_pool_t db_mem_device_name_pool;
2556527a633S[email protected] db_mem_device_name_t * btstack_memory_db_mem_device_name_get(void){
25629d0c4f7SMatthias Ringwald     return (db_mem_device_name_t *) btstack_memory_pool_get(&db_mem_device_name_pool);
2571801b596Smatthias.ringwald }
2586527a633S[email protected] void btstack_memory_db_mem_device_name_free(db_mem_device_name_t *db_mem_device_name){
25929d0c4f7SMatthias Ringwald     btstack_memory_pool_free(&db_mem_device_name_pool, db_mem_device_name);
2601801b596Smatthias.ringwald }
261c4d3f927Smatthias.ringwald #else
2626527a633S[email protected] db_mem_device_name_t * btstack_memory_db_mem_device_name_get(void){
263c4d3f927Smatthias.ringwald     return NULL;
264c4d3f927Smatthias.ringwald }
2656527a633S[email protected] void btstack_memory_db_mem_device_name_free(db_mem_device_name_t *db_mem_device_name){
2666f7ecb09S[email protected]     // silence compiler warning about unused parameter in a portable way
2676f7ecb09S[email protected]     (void) db_mem_device_name;
268c4d3f927Smatthias.ringwald };
269c4d3f927Smatthias.ringwald #endif
2701801b596Smatthias.ringwald #elif defined(HAVE_MALLOC)
2716527a633S[email protected] db_mem_device_name_t * btstack_memory_db_mem_device_name_get(void){
2726527a633S[email protected]     return (db_mem_device_name_t*) malloc(sizeof(db_mem_device_name_t));
2731801b596Smatthias.ringwald }
2746527a633S[email protected] void btstack_memory_db_mem_device_name_free(db_mem_device_name_t *db_mem_device_name){
275e0e5e285Smatthias.ringwald     free(db_mem_device_name);
276e0e5e285Smatthias.ringwald }
277e045abdeSmatthias.ringwald #else
2786527a633S[email protected] #error "Neither HAVE_MALLOC nor MAX_NO_DB_MEM_DEVICE_NAMES for struct db_mem_device_name is defined. Please, edit the config file."
279e0e5e285Smatthias.ringwald #endif
280e0e5e285Smatthias.ringwald 
281e0e5e285Smatthias.ringwald 
282e0e5e285Smatthias.ringwald // MARK: db_mem_device_link_key_t
283e0e5e285Smatthias.ringwald #ifdef MAX_NO_DB_MEM_DEVICE_LINK_KEYS
284c4d3f927Smatthias.ringwald #if MAX_NO_DB_MEM_DEVICE_LINK_KEYS > 0
285e0e5e285Smatthias.ringwald static db_mem_device_link_key_t db_mem_device_link_key_storage[MAX_NO_DB_MEM_DEVICE_LINK_KEYS];
28629d0c4f7SMatthias Ringwald static btstack_memory_pool_t db_mem_device_link_key_pool;
2876527a633S[email protected] db_mem_device_link_key_t * btstack_memory_db_mem_device_link_key_get(void){
28829d0c4f7SMatthias Ringwald     return (db_mem_device_link_key_t *) btstack_memory_pool_get(&db_mem_device_link_key_pool);
289e0e5e285Smatthias.ringwald }
2906527a633S[email protected] void btstack_memory_db_mem_device_link_key_free(db_mem_device_link_key_t *db_mem_device_link_key){
29129d0c4f7SMatthias Ringwald     btstack_memory_pool_free(&db_mem_device_link_key_pool, db_mem_device_link_key);
292e0e5e285Smatthias.ringwald }
293c4d3f927Smatthias.ringwald #else
2946527a633S[email protected] db_mem_device_link_key_t * btstack_memory_db_mem_device_link_key_get(void){
295c4d3f927Smatthias.ringwald     return NULL;
296c4d3f927Smatthias.ringwald }
2976527a633S[email protected] void btstack_memory_db_mem_device_link_key_free(db_mem_device_link_key_t *db_mem_device_link_key){
2986f7ecb09S[email protected]     // silence compiler warning about unused parameter in a portable way
2996f7ecb09S[email protected]     (void) db_mem_device_link_key;
300c4d3f927Smatthias.ringwald };
301c4d3f927Smatthias.ringwald #endif
302e0e5e285Smatthias.ringwald #elif defined(HAVE_MALLOC)
3036527a633S[email protected] db_mem_device_link_key_t * btstack_memory_db_mem_device_link_key_get(void){
3046527a633S[email protected]     return (db_mem_device_link_key_t*) malloc(sizeof(db_mem_device_link_key_t));
305e0e5e285Smatthias.ringwald }
3066527a633S[email protected] void btstack_memory_db_mem_device_link_key_free(db_mem_device_link_key_t *db_mem_device_link_key){
307e0e5e285Smatthias.ringwald     free(db_mem_device_link_key);
3081801b596Smatthias.ringwald }
309e045abdeSmatthias.ringwald #else
3106527a633S[email protected] #error "Neither HAVE_MALLOC nor MAX_NO_DB_MEM_DEVICE_LINK_KEYS for struct db_mem_device_link_key is defined. Please, edit the config file."
3111801b596Smatthias.ringwald #endif
3121801b596Smatthias.ringwald 
3131801b596Smatthias.ringwald 
3141801b596Smatthias.ringwald // MARK: db_mem_service_t
3151801b596Smatthias.ringwald #ifdef MAX_NO_DB_MEM_SERVICES
316c4d3f927Smatthias.ringwald #if MAX_NO_DB_MEM_SERVICES > 0
3171801b596Smatthias.ringwald static db_mem_service_t db_mem_service_storage[MAX_NO_DB_MEM_SERVICES];
31829d0c4f7SMatthias Ringwald static btstack_memory_pool_t db_mem_service_pool;
3196527a633S[email protected] db_mem_service_t * btstack_memory_db_mem_service_get(void){
32029d0c4f7SMatthias Ringwald     return (db_mem_service_t *) btstack_memory_pool_get(&db_mem_service_pool);
3211801b596Smatthias.ringwald }
3226527a633S[email protected] void btstack_memory_db_mem_service_free(db_mem_service_t *db_mem_service){
32329d0c4f7SMatthias Ringwald     btstack_memory_pool_free(&db_mem_service_pool, db_mem_service);
3241801b596Smatthias.ringwald }
325c4d3f927Smatthias.ringwald #else
3266527a633S[email protected] db_mem_service_t * btstack_memory_db_mem_service_get(void){
327c4d3f927Smatthias.ringwald     return NULL;
328c4d3f927Smatthias.ringwald }
3296527a633S[email protected] void btstack_memory_db_mem_service_free(db_mem_service_t *db_mem_service){
3306f7ecb09S[email protected]     // silence compiler warning about unused parameter in a portable way
3316f7ecb09S[email protected]     (void) db_mem_service;
332c4d3f927Smatthias.ringwald };
333c4d3f927Smatthias.ringwald #endif
3341801b596Smatthias.ringwald #elif defined(HAVE_MALLOC)
3356527a633S[email protected] db_mem_service_t * btstack_memory_db_mem_service_get(void){
3366527a633S[email protected]     return (db_mem_service_t*) malloc(sizeof(db_mem_service_t));
3371801b596Smatthias.ringwald }
3386527a633S[email protected] void btstack_memory_db_mem_service_free(db_mem_service_t *db_mem_service){
3391801b596Smatthias.ringwald     free(db_mem_service);
3401801b596Smatthias.ringwald }
341e045abdeSmatthias.ringwald #else
3426527a633S[email protected] #error "Neither HAVE_MALLOC nor MAX_NO_DB_MEM_SERVICES for struct db_mem_service is defined. Please, edit the config file."
3431801b596Smatthias.ringwald #endif
3441801b596Smatthias.ringwald 
3452e97c149S[email protected] 
3462e97c149S[email protected] 
3472e97c149S[email protected] // MARK: bnep_service_t
3482e97c149S[email protected] #ifdef MAX_NO_BNEP_SERVICES
3492e97c149S[email protected] #if MAX_NO_BNEP_SERVICES > 0
3502e97c149S[email protected] static bnep_service_t bnep_service_storage[MAX_NO_BNEP_SERVICES];
35129d0c4f7SMatthias Ringwald static btstack_memory_pool_t bnep_service_pool;
3522e97c149S[email protected] bnep_service_t * btstack_memory_bnep_service_get(void){
35329d0c4f7SMatthias Ringwald     return (bnep_service_t *) btstack_memory_pool_get(&bnep_service_pool);
3542e97c149S[email protected] }
3552e97c149S[email protected] void btstack_memory_bnep_service_free(bnep_service_t *bnep_service){
35629d0c4f7SMatthias Ringwald     btstack_memory_pool_free(&bnep_service_pool, bnep_service);
3572e97c149S[email protected] }
3582e97c149S[email protected] #else
3592e97c149S[email protected] bnep_service_t * btstack_memory_bnep_service_get(void){
3602e97c149S[email protected]     return NULL;
3612e97c149S[email protected] }
3622e97c149S[email protected] void btstack_memory_bnep_service_free(bnep_service_t *bnep_service){
3632e97c149S[email protected]     // silence compiler warning about unused parameter in a portable way
3642e97c149S[email protected]     (void) bnep_service;
3652e97c149S[email protected] };
3662e97c149S[email protected] #endif
3672e97c149S[email protected] #elif defined(HAVE_MALLOC)
3682e97c149S[email protected] bnep_service_t * btstack_memory_bnep_service_get(void){
3692e97c149S[email protected]     return (bnep_service_t*) malloc(sizeof(bnep_service_t));
3702e97c149S[email protected] }
3712e97c149S[email protected] void btstack_memory_bnep_service_free(bnep_service_t *bnep_service){
3722e97c149S[email protected]     free(bnep_service);
3732e97c149S[email protected] }
3742e97c149S[email protected] #else
3752e97c149S[email protected] #error "Neither HAVE_MALLOC nor MAX_NO_BNEP_SERVICES for struct bnep_service is defined. Please, edit the config file."
3762e97c149S[email protected] #endif
3772e97c149S[email protected] 
3782e97c149S[email protected] 
3792e97c149S[email protected] // MARK: bnep_channel_t
3802e97c149S[email protected] #ifdef MAX_NO_BNEP_CHANNELS
3812e97c149S[email protected] #if MAX_NO_BNEP_CHANNELS > 0
3822e97c149S[email protected] static bnep_channel_t bnep_channel_storage[MAX_NO_BNEP_CHANNELS];
38329d0c4f7SMatthias Ringwald static btstack_memory_pool_t bnep_channel_pool;
3842e97c149S[email protected] bnep_channel_t * btstack_memory_bnep_channel_get(void){
38529d0c4f7SMatthias Ringwald     return (bnep_channel_t *) btstack_memory_pool_get(&bnep_channel_pool);
3862e97c149S[email protected] }
3872e97c149S[email protected] void btstack_memory_bnep_channel_free(bnep_channel_t *bnep_channel){
38829d0c4f7SMatthias Ringwald     btstack_memory_pool_free(&bnep_channel_pool, bnep_channel);
3892e97c149S[email protected] }
3902e97c149S[email protected] #else
3912e97c149S[email protected] bnep_channel_t * btstack_memory_bnep_channel_get(void){
3922e97c149S[email protected]     return NULL;
3932e97c149S[email protected] }
3942e97c149S[email protected] void btstack_memory_bnep_channel_free(bnep_channel_t *bnep_channel){
3952e97c149S[email protected]     // silence compiler warning about unused parameter in a portable way
3962e97c149S[email protected]     (void) bnep_channel;
3972e97c149S[email protected] };
3982e97c149S[email protected] #endif
3992e97c149S[email protected] #elif defined(HAVE_MALLOC)
4002e97c149S[email protected] bnep_channel_t * btstack_memory_bnep_channel_get(void){
4012e97c149S[email protected]     return (bnep_channel_t*) malloc(sizeof(bnep_channel_t));
4022e97c149S[email protected] }
4032e97c149S[email protected] void btstack_memory_bnep_channel_free(bnep_channel_t *bnep_channel){
4042e97c149S[email protected]     free(bnep_channel);
4052e97c149S[email protected] }
4062e97c149S[email protected] #else
4072e97c149S[email protected] #error "Neither HAVE_MALLOC nor MAX_NO_BNEP_CHANNELS for struct bnep_channel is defined. Please, edit the config file."
4082e97c149S[email protected] #endif
4092e97c149S[email protected] 
4102e97c149S[email protected] 
411ea5029c9SMilanka Ringwald 
412ea5029c9SMilanka Ringwald // MARK: hfp_connection_t
413ea5029c9SMilanka Ringwald #ifdef MAX_NO_HFP_CONNECTIONS
414ea5029c9SMilanka Ringwald #if MAX_NO_HFP_CONNECTIONS > 0
415ea5029c9SMilanka Ringwald static hfp_connection_t hfp_connection_storage[MAX_NO_HFP_CONNECTIONS];
41629d0c4f7SMatthias Ringwald static btstack_memory_pool_t hfp_connection_pool;
417ea5029c9SMilanka Ringwald hfp_connection_t * btstack_memory_hfp_connection_get(void){
41829d0c4f7SMatthias Ringwald     return (hfp_connection_t *) btstack_memory_pool_get(&hfp_connection_pool);
419ea5029c9SMilanka Ringwald }
420ea5029c9SMilanka Ringwald void btstack_memory_hfp_connection_free(hfp_connection_t *hfp_connection){
42129d0c4f7SMatthias Ringwald     btstack_memory_pool_free(&hfp_connection_pool, hfp_connection);
422ea5029c9SMilanka Ringwald }
423ea5029c9SMilanka Ringwald #else
424ea5029c9SMilanka Ringwald hfp_connection_t * btstack_memory_hfp_connection_get(void){
425ea5029c9SMilanka Ringwald     return NULL;
426ea5029c9SMilanka Ringwald }
427ea5029c9SMilanka Ringwald void btstack_memory_hfp_connection_free(hfp_connection_t *hfp_connection){
428ea5029c9SMilanka Ringwald     // silence compiler warning about unused parameter in a portable way
429ea5029c9SMilanka Ringwald     (void) hfp_connection;
430ea5029c9SMilanka Ringwald };
431ea5029c9SMilanka Ringwald #endif
432ea5029c9SMilanka Ringwald #elif defined(HAVE_MALLOC)
433ea5029c9SMilanka Ringwald hfp_connection_t * btstack_memory_hfp_connection_get(void){
434ea5029c9SMilanka Ringwald     return (hfp_connection_t*) malloc(sizeof(hfp_connection_t));
435ea5029c9SMilanka Ringwald }
436ea5029c9SMilanka Ringwald void btstack_memory_hfp_connection_free(hfp_connection_t *hfp_connection){
437ea5029c9SMilanka Ringwald     free(hfp_connection);
438ea5029c9SMilanka Ringwald }
439ea5029c9SMilanka Ringwald #else
440ea5029c9SMilanka Ringwald #error "Neither HAVE_MALLOC nor MAX_NO_HFP_CONNECTIONS for struct hfp_connection is defined. Please, edit the config file."
441ea5029c9SMilanka Ringwald #endif
442ea5029c9SMilanka Ringwald 
443ea5029c9SMilanka Ringwald 
444cd9ee144SMatthias Ringwald 
445cd9ee144SMatthias Ringwald // MARK: service_record_item_t
446cd9ee144SMatthias Ringwald #ifdef MAX_NO_SERVICE_RECORD_ITEMS
447cd9ee144SMatthias Ringwald #if MAX_NO_SERVICE_RECORD_ITEMS > 0
448cd9ee144SMatthias Ringwald static service_record_item_t service_record_item_storage[MAX_NO_SERVICE_RECORD_ITEMS];
44929d0c4f7SMatthias Ringwald static btstack_memory_pool_t service_record_item_pool;
450cd9ee144SMatthias Ringwald service_record_item_t * btstack_memory_service_record_item_get(void){
45129d0c4f7SMatthias Ringwald     return (service_record_item_t *) btstack_memory_pool_get(&service_record_item_pool);
452cd9ee144SMatthias Ringwald }
453cd9ee144SMatthias Ringwald void btstack_memory_service_record_item_free(service_record_item_t *service_record_item){
45429d0c4f7SMatthias Ringwald     btstack_memory_pool_free(&service_record_item_pool, service_record_item);
455cd9ee144SMatthias Ringwald }
456cd9ee144SMatthias Ringwald #else
457cd9ee144SMatthias Ringwald service_record_item_t * btstack_memory_service_record_item_get(void){
458cd9ee144SMatthias Ringwald     return NULL;
459cd9ee144SMatthias Ringwald }
460cd9ee144SMatthias Ringwald void btstack_memory_service_record_item_free(service_record_item_t *service_record_item){
461cd9ee144SMatthias Ringwald     // silence compiler warning about unused parameter in a portable way
462cd9ee144SMatthias Ringwald     (void) service_record_item;
463cd9ee144SMatthias Ringwald };
464cd9ee144SMatthias Ringwald #endif
465cd9ee144SMatthias Ringwald #elif defined(HAVE_MALLOC)
466cd9ee144SMatthias Ringwald service_record_item_t * btstack_memory_service_record_item_get(void){
467cd9ee144SMatthias Ringwald     return (service_record_item_t*) malloc(sizeof(service_record_item_t));
468cd9ee144SMatthias Ringwald }
469cd9ee144SMatthias Ringwald void btstack_memory_service_record_item_free(service_record_item_t *service_record_item){
470cd9ee144SMatthias Ringwald     free(service_record_item);
471cd9ee144SMatthias Ringwald }
472cd9ee144SMatthias Ringwald #else
473cd9ee144SMatthias Ringwald #error "Neither HAVE_MALLOC nor MAX_NO_SERVICE_RECORD_ITEMS for struct service_record_item is defined. Please, edit the config file."
474cd9ee144SMatthias Ringwald #endif
475cd9ee144SMatthias Ringwald 
476cd9ee144SMatthias Ringwald 
477*a9a4c409SMatthias Ringwald #ifdef ENABLE_BLE
4782e97c149S[email protected] 
4792e97c149S[email protected] // MARK: gatt_client_t
480d0fdae3cS[email protected] #ifdef MAX_NO_GATT_CLIENTS
481d0fdae3cS[email protected] #if MAX_NO_GATT_CLIENTS > 0
482d0fdae3cS[email protected] static gatt_client_t gatt_client_storage[MAX_NO_GATT_CLIENTS];
48329d0c4f7SMatthias Ringwald static btstack_memory_pool_t gatt_client_pool;
484d0fdae3cS[email protected] gatt_client_t * btstack_memory_gatt_client_get(void){
48529d0c4f7SMatthias Ringwald     return (gatt_client_t *) btstack_memory_pool_get(&gatt_client_pool);
486d0fdae3cS[email protected] }
487d0fdae3cS[email protected] void btstack_memory_gatt_client_free(gatt_client_t *gatt_client){
48829d0c4f7SMatthias Ringwald     btstack_memory_pool_free(&gatt_client_pool, gatt_client);
489d0fdae3cS[email protected] }
490d0fdae3cS[email protected] #else
491d0fdae3cS[email protected] gatt_client_t * btstack_memory_gatt_client_get(void){
492d0fdae3cS[email protected]     return NULL;
493d0fdae3cS[email protected] }
494d0fdae3cS[email protected] void btstack_memory_gatt_client_free(gatt_client_t *gatt_client){
4956f7ecb09S[email protected]     // silence compiler warning about unused parameter in a portable way
4966f7ecb09S[email protected]     (void) gatt_client;
497d0fdae3cS[email protected] };
498d0fdae3cS[email protected] #endif
499d0fdae3cS[email protected] #elif defined(HAVE_MALLOC)
500d0fdae3cS[email protected] gatt_client_t * btstack_memory_gatt_client_get(void){
501d0fdae3cS[email protected]     return (gatt_client_t*) malloc(sizeof(gatt_client_t));
502d0fdae3cS[email protected] }
503d0fdae3cS[email protected] void btstack_memory_gatt_client_free(gatt_client_t *gatt_client){
504d0fdae3cS[email protected]     free(gatt_client);
505d0fdae3cS[email protected] }
506d0fdae3cS[email protected] #else
507d0fdae3cS[email protected] #error "Neither HAVE_MALLOC nor MAX_NO_GATT_CLIENTS for struct gatt_client is defined. Please, edit the config file."
508d0fdae3cS[email protected] #endif
5092e97c149S[email protected] 
5102e97c149S[email protected] 
5112e97c149S[email protected] // MARK: gatt_subclient_t
5122e97c149S[email protected] #ifdef MAX_NO_GATT_SUBCLIENTS
5132e97c149S[email protected] #if MAX_NO_GATT_SUBCLIENTS > 0
5142e97c149S[email protected] static gatt_subclient_t gatt_subclient_storage[MAX_NO_GATT_SUBCLIENTS];
51529d0c4f7SMatthias Ringwald static btstack_memory_pool_t gatt_subclient_pool;
5162e97c149S[email protected] gatt_subclient_t * btstack_memory_gatt_subclient_get(void){
51729d0c4f7SMatthias Ringwald     return (gatt_subclient_t *) btstack_memory_pool_get(&gatt_subclient_pool);
5182e97c149S[email protected] }
5192e97c149S[email protected] void btstack_memory_gatt_subclient_free(gatt_subclient_t *gatt_subclient){
52029d0c4f7SMatthias Ringwald     btstack_memory_pool_free(&gatt_subclient_pool, gatt_subclient);
5212e97c149S[email protected] }
5222e97c149S[email protected] #else
5232e97c149S[email protected] gatt_subclient_t * btstack_memory_gatt_subclient_get(void){
5242e97c149S[email protected]     return NULL;
5252e97c149S[email protected] }
5262e97c149S[email protected] void btstack_memory_gatt_subclient_free(gatt_subclient_t *gatt_subclient){
5272e97c149S[email protected]     // silence compiler warning about unused parameter in a portable way
5282e97c149S[email protected]     (void) gatt_subclient;
5292e97c149S[email protected] };
5302e97c149S[email protected] #endif
5312e97c149S[email protected] #elif defined(HAVE_MALLOC)
5322e97c149S[email protected] gatt_subclient_t * btstack_memory_gatt_subclient_get(void){
5332e97c149S[email protected]     return (gatt_subclient_t*) malloc(sizeof(gatt_subclient_t));
5342e97c149S[email protected] }
5352e97c149S[email protected] void btstack_memory_gatt_subclient_free(gatt_subclient_t *gatt_subclient){
5362e97c149S[email protected]     free(gatt_subclient);
5372e97c149S[email protected] }
5382e97c149S[email protected] #else
5392e97c149S[email protected] #error "Neither HAVE_MALLOC nor MAX_NO_GATT_SUBCLIENTS for struct gatt_subclient is defined. Please, edit the config file."
540d0fdae3cS[email protected] #endif
541fdb398c2S[email protected] 
5422e97c149S[email protected] 
543656bec4fSMatthias Ringwald // MARK: whitelist_entry_t
544656bec4fSMatthias Ringwald #ifdef MAX_NO_WHITELIST_ENTRIES
545656bec4fSMatthias Ringwald #if MAX_NO_WHITELIST_ENTRIES > 0
546656bec4fSMatthias Ringwald static whitelist_entry_t whitelist_entry_storage[MAX_NO_WHITELIST_ENTRIES];
54729d0c4f7SMatthias Ringwald static btstack_memory_pool_t whitelist_entry_pool;
548656bec4fSMatthias Ringwald whitelist_entry_t * btstack_memory_whitelist_entry_get(void){
54929d0c4f7SMatthias Ringwald     return (whitelist_entry_t *) btstack_memory_pool_get(&whitelist_entry_pool);
550656bec4fSMatthias Ringwald }
551656bec4fSMatthias Ringwald void btstack_memory_whitelist_entry_free(whitelist_entry_t *whitelist_entry){
55229d0c4f7SMatthias Ringwald     btstack_memory_pool_free(&whitelist_entry_pool, whitelist_entry);
553656bec4fSMatthias Ringwald }
554656bec4fSMatthias Ringwald #else
555656bec4fSMatthias Ringwald whitelist_entry_t * btstack_memory_whitelist_entry_get(void){
556656bec4fSMatthias Ringwald     return NULL;
557656bec4fSMatthias Ringwald }
558656bec4fSMatthias Ringwald void btstack_memory_whitelist_entry_free(whitelist_entry_t *whitelist_entry){
559656bec4fSMatthias Ringwald     // silence compiler warning about unused parameter in a portable way
560656bec4fSMatthias Ringwald     (void) whitelist_entry;
561656bec4fSMatthias Ringwald };
562656bec4fSMatthias Ringwald #endif
563656bec4fSMatthias Ringwald #elif defined(HAVE_MALLOC)
564656bec4fSMatthias Ringwald whitelist_entry_t * btstack_memory_whitelist_entry_get(void){
565656bec4fSMatthias Ringwald     return (whitelist_entry_t*) malloc(sizeof(whitelist_entry_t));
566656bec4fSMatthias Ringwald }
567656bec4fSMatthias Ringwald void btstack_memory_whitelist_entry_free(whitelist_entry_t *whitelist_entry){
568656bec4fSMatthias Ringwald     free(whitelist_entry);
569656bec4fSMatthias Ringwald }
570656bec4fSMatthias Ringwald #else
571656bec4fSMatthias Ringwald #error "Neither HAVE_MALLOC nor MAX_NO_WHITELIST_ENTRIES for struct whitelist_entry is defined. Please, edit the config file."
572656bec4fSMatthias Ringwald #endif
573656bec4fSMatthias Ringwald 
574656bec4fSMatthias Ringwald 
575cf49570bSMatthias Ringwald // MARK: sm_lookup_entry_t
576cf49570bSMatthias Ringwald #ifdef MAX_NO_SM_LOOKUP_ENTRIES
577cf49570bSMatthias Ringwald #if MAX_NO_SM_LOOKUP_ENTRIES > 0
578cf49570bSMatthias Ringwald static sm_lookup_entry_t sm_lookup_entry_storage[MAX_NO_SM_LOOKUP_ENTRIES];
57929d0c4f7SMatthias Ringwald static btstack_memory_pool_t sm_lookup_entry_pool;
580cf49570bSMatthias Ringwald sm_lookup_entry_t * btstack_memory_sm_lookup_entry_get(void){
58129d0c4f7SMatthias Ringwald     return (sm_lookup_entry_t *) btstack_memory_pool_get(&sm_lookup_entry_pool);
582cf49570bSMatthias Ringwald }
583cf49570bSMatthias Ringwald void btstack_memory_sm_lookup_entry_free(sm_lookup_entry_t *sm_lookup_entry){
58429d0c4f7SMatthias Ringwald     btstack_memory_pool_free(&sm_lookup_entry_pool, sm_lookup_entry);
585cf49570bSMatthias Ringwald }
586cf49570bSMatthias Ringwald #else
587cf49570bSMatthias Ringwald sm_lookup_entry_t * btstack_memory_sm_lookup_entry_get(void){
588cf49570bSMatthias Ringwald     return NULL;
589cf49570bSMatthias Ringwald }
590cf49570bSMatthias Ringwald void btstack_memory_sm_lookup_entry_free(sm_lookup_entry_t *sm_lookup_entry){
591cf49570bSMatthias Ringwald     // silence compiler warning about unused parameter in a portable way
592cf49570bSMatthias Ringwald     (void) sm_lookup_entry;
593cf49570bSMatthias Ringwald };
594cf49570bSMatthias Ringwald #endif
595cf49570bSMatthias Ringwald #elif defined(HAVE_MALLOC)
596cf49570bSMatthias Ringwald sm_lookup_entry_t * btstack_memory_sm_lookup_entry_get(void){
597cf49570bSMatthias Ringwald     return (sm_lookup_entry_t*) malloc(sizeof(sm_lookup_entry_t));
598cf49570bSMatthias Ringwald }
599cf49570bSMatthias Ringwald void btstack_memory_sm_lookup_entry_free(sm_lookup_entry_t *sm_lookup_entry){
600cf49570bSMatthias Ringwald     free(sm_lookup_entry);
601cf49570bSMatthias Ringwald }
602cf49570bSMatthias Ringwald #else
603cf49570bSMatthias Ringwald #error "Neither HAVE_MALLOC nor MAX_NO_SM_LOOKUP_ENTRIES for struct sm_lookup_entry is defined. Please, edit the config file."
604cf49570bSMatthias Ringwald #endif
605cf49570bSMatthias Ringwald 
606cf49570bSMatthias Ringwald 
6072e97c149S[email protected] #endif
608a3b02b71Smatthias.ringwald // init
609a3b02b71Smatthias.ringwald void btstack_memory_init(void){
610c4d3f927Smatthias.ringwald #if MAX_NO_HCI_CONNECTIONS > 0
61129d0c4f7SMatthias Ringwald     btstack_memory_pool_create(&hci_connection_pool, hci_connection_storage, MAX_NO_HCI_CONNECTIONS, sizeof(hci_connection_t));
612a3b02b71Smatthias.ringwald #endif
613c4d3f927Smatthias.ringwald #if MAX_NO_L2CAP_SERVICES > 0
61429d0c4f7SMatthias Ringwald     btstack_memory_pool_create(&l2cap_service_pool, l2cap_service_storage, MAX_NO_L2CAP_SERVICES, sizeof(l2cap_service_t));
615a3b02b71Smatthias.ringwald #endif
616c4d3f927Smatthias.ringwald #if MAX_NO_L2CAP_CHANNELS > 0
61729d0c4f7SMatthias Ringwald     btstack_memory_pool_create(&l2cap_channel_pool, l2cap_channel_storage, MAX_NO_L2CAP_CHANNELS, sizeof(l2cap_channel_t));
618a3b02b71Smatthias.ringwald #endif
619c4d3f927Smatthias.ringwald #if MAX_NO_RFCOMM_MULTIPLEXERS > 0
62029d0c4f7SMatthias Ringwald     btstack_memory_pool_create(&rfcomm_multiplexer_pool, rfcomm_multiplexer_storage, MAX_NO_RFCOMM_MULTIPLEXERS, sizeof(rfcomm_multiplexer_t));
621a3b02b71Smatthias.ringwald #endif
622c4d3f927Smatthias.ringwald #if MAX_NO_RFCOMM_SERVICES > 0
62329d0c4f7SMatthias Ringwald     btstack_memory_pool_create(&rfcomm_service_pool, rfcomm_service_storage, MAX_NO_RFCOMM_SERVICES, sizeof(rfcomm_service_t));
624a3b02b71Smatthias.ringwald #endif
625c4d3f927Smatthias.ringwald #if MAX_NO_RFCOMM_CHANNELS > 0
62629d0c4f7SMatthias Ringwald     btstack_memory_pool_create(&rfcomm_channel_pool, rfcomm_channel_storage, MAX_NO_RFCOMM_CHANNELS, sizeof(rfcomm_channel_t));
627a3b02b71Smatthias.ringwald #endif
628c4d3f927Smatthias.ringwald #if MAX_NO_DB_MEM_DEVICE_NAMES > 0
62929d0c4f7SMatthias Ringwald     btstack_memory_pool_create(&db_mem_device_name_pool, db_mem_device_name_storage, MAX_NO_DB_MEM_DEVICE_NAMES, sizeof(db_mem_device_name_t));
630e0e5e285Smatthias.ringwald #endif
631c4d3f927Smatthias.ringwald #if MAX_NO_DB_MEM_DEVICE_LINK_KEYS > 0
63229d0c4f7SMatthias Ringwald     btstack_memory_pool_create(&db_mem_device_link_key_pool, db_mem_device_link_key_storage, MAX_NO_DB_MEM_DEVICE_LINK_KEYS, sizeof(db_mem_device_link_key_t));
6331801b596Smatthias.ringwald #endif
634c4d3f927Smatthias.ringwald #if MAX_NO_DB_MEM_SERVICES > 0
63529d0c4f7SMatthias Ringwald     btstack_memory_pool_create(&db_mem_service_pool, db_mem_service_storage, MAX_NO_DB_MEM_SERVICES, sizeof(db_mem_service_t));
6361801b596Smatthias.ringwald #endif
6372e97c149S[email protected] #if MAX_NO_BNEP_SERVICES > 0
63829d0c4f7SMatthias Ringwald     btstack_memory_pool_create(&bnep_service_pool, bnep_service_storage, MAX_NO_BNEP_SERVICES, sizeof(bnep_service_t));
6392e97c149S[email protected] #endif
6402e97c149S[email protected] #if MAX_NO_BNEP_CHANNELS > 0
64129d0c4f7SMatthias Ringwald     btstack_memory_pool_create(&bnep_channel_pool, bnep_channel_storage, MAX_NO_BNEP_CHANNELS, sizeof(bnep_channel_t));
6422e97c149S[email protected] #endif
643ea5029c9SMilanka Ringwald #if MAX_NO_HFP_CONNECTIONS > 0
64429d0c4f7SMatthias Ringwald     btstack_memory_pool_create(&hfp_connection_pool, hfp_connection_storage, MAX_NO_HFP_CONNECTIONS, sizeof(hfp_connection_t));
645ea5029c9SMilanka Ringwald #endif
646cd9ee144SMatthias Ringwald #if MAX_NO_SERVICE_RECORD_ITEMS > 0
64729d0c4f7SMatthias Ringwald     btstack_memory_pool_create(&service_record_item_pool, service_record_item_storage, MAX_NO_SERVICE_RECORD_ITEMS, sizeof(service_record_item_t));
648cd9ee144SMatthias Ringwald #endif
649*a9a4c409SMatthias Ringwald #ifdef ENABLE_BLE
650d0fdae3cS[email protected] #if MAX_NO_GATT_CLIENTS > 0
65129d0c4f7SMatthias Ringwald     btstack_memory_pool_create(&gatt_client_pool, gatt_client_storage, MAX_NO_GATT_CLIENTS, sizeof(gatt_client_t));
652d0fdae3cS[email protected] #endif
6532e97c149S[email protected] #if MAX_NO_GATT_SUBCLIENTS > 0
65429d0c4f7SMatthias Ringwald     btstack_memory_pool_create(&gatt_subclient_pool, gatt_subclient_storage, MAX_NO_GATT_SUBCLIENTS, sizeof(gatt_subclient_t));
6552e97c149S[email protected] #endif
656656bec4fSMatthias Ringwald #if MAX_NO_WHITELIST_ENTRIES > 0
65729d0c4f7SMatthias Ringwald     btstack_memory_pool_create(&whitelist_entry_pool, whitelist_entry_storage, MAX_NO_WHITELIST_ENTRIES, sizeof(whitelist_entry_t));
658656bec4fSMatthias Ringwald #endif
659cf49570bSMatthias Ringwald #if MAX_NO_SM_LOOKUP_ENTRIES > 0
66029d0c4f7SMatthias Ringwald     btstack_memory_pool_create(&sm_lookup_entry_pool, sm_lookup_entry_storage, MAX_NO_SM_LOOKUP_ENTRIES, sizeof(sm_lookup_entry_t));
661cf49570bSMatthias Ringwald #endif
662a7d12effS[email protected] #endif
663a3b02b71Smatthias.ringwald }
664