xref: /btstack/src/btstack_memory.c (revision c4d3f927d003818bf61c8d0f619289b13e531c47)
1a3b02b71Smatthias.ringwald /*
26b64433eSmatthias.ringwald  * Copyright (C) 2009-2012 by Matthias Ringwald
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  *
20a3b02b71Smatthias.ringwald  * THIS SOFTWARE IS PROVIDED BY MATTHIAS RINGWALD 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  *
336b64433eSmatthias.ringwald  * Please inquire about commercial licensing options at [email protected]
346b64433eSmatthias.ringwald  *
35a3b02b71Smatthias.ringwald  */
36a3b02b71Smatthias.ringwald 
37a3b02b71Smatthias.ringwald /*
38a3b02b71Smatthias.ringwald  *  btstsack_memory.h
39a3b02b71Smatthias.ringwald  *
40a3b02b71Smatthias.ringwald  *  @brief BTstack memory management via configurable memory pools
41a3b02b71Smatthias.ringwald  *
42e0e5e285Smatthias.ringwald  *  @note code semi-atuomatically generated by btstack_memory_generator.py
43a3b02b71Smatthias.ringwald  *
44a3b02b71Smatthias.ringwald  */
45a3b02b71Smatthias.ringwald 
46a3b02b71Smatthias.ringwald #include "btstack_memory.h"
47a3b02b71Smatthias.ringwald #include <btstack/memory_pool.h>
48a3b02b71Smatthias.ringwald 
49a3b02b71Smatthias.ringwald #include <stdlib.h>
50a3b02b71Smatthias.ringwald 
51c8901d41Smatthias.ringwald #include "config.h"
52a3b02b71Smatthias.ringwald #include "hci.h"
53a3b02b71Smatthias.ringwald #include "l2cap.h"
54a3b02b71Smatthias.ringwald #include "rfcomm.h"
55a3b02b71Smatthias.ringwald 
56a3b02b71Smatthias.ringwald // MARK: hci_connection_t
57a3b02b71Smatthias.ringwald #ifdef MAX_NO_HCI_CONNECTIONS
58*c4d3f927Smatthias.ringwald #if MAX_NO_HCI_CONNECTIONS > 0
59a3b02b71Smatthias.ringwald static hci_connection_t hci_connection_storage[MAX_NO_HCI_CONNECTIONS];
60a3b02b71Smatthias.ringwald static memory_pool_t hci_connection_pool;
61a3b02b71Smatthias.ringwald void * btstack_memory_hci_connection_get(void){
62a3b02b71Smatthias.ringwald     return memory_pool_get(&hci_connection_pool);
63a3b02b71Smatthias.ringwald }
64a3b02b71Smatthias.ringwald void btstack_memory_hci_connection_free(void *hci_connection){
65a3b02b71Smatthias.ringwald     memory_pool_free(&hci_connection_pool, hci_connection);
66a3b02b71Smatthias.ringwald }
67*c4d3f927Smatthias.ringwald #else
68*c4d3f927Smatthias.ringwald void * btstack_memory_hci_connection_get(void){
69*c4d3f927Smatthias.ringwald     return NULL;
70*c4d3f927Smatthias.ringwald }
71*c4d3f927Smatthias.ringwald void btstack_memory_hci_connection_free(void *hci_connection){
72*c4d3f927Smatthias.ringwald };
73*c4d3f927Smatthias.ringwald #endif
74a3b02b71Smatthias.ringwald #elif defined(HAVE_MALLOC)
75a3b02b71Smatthias.ringwald void * btstack_memory_hci_connection_get(void){
76a3b02b71Smatthias.ringwald     return malloc(sizeof(hci_connection_t));
77a3b02b71Smatthias.ringwald }
78a3b02b71Smatthias.ringwald void  btstack_memory_hci_connection_free(void *hci_connection){
79a3b02b71Smatthias.ringwald     free(hci_connection);
80a3b02b71Smatthias.ringwald }
81a3b02b71Smatthias.ringwald #endif
82a3b02b71Smatthias.ringwald 
83a3b02b71Smatthias.ringwald 
84a3b02b71Smatthias.ringwald // MARK: l2cap_service_t
85a3b02b71Smatthias.ringwald #ifdef MAX_NO_L2CAP_SERVICES
86*c4d3f927Smatthias.ringwald #if MAX_NO_L2CAP_SERVICES > 0
87a3b02b71Smatthias.ringwald static l2cap_service_t l2cap_service_storage[MAX_NO_L2CAP_SERVICES];
88a3b02b71Smatthias.ringwald static memory_pool_t l2cap_service_pool;
89a3b02b71Smatthias.ringwald void * btstack_memory_l2cap_service_get(void){
90a3b02b71Smatthias.ringwald     return memory_pool_get(&l2cap_service_pool);
91a3b02b71Smatthias.ringwald }
92a3b02b71Smatthias.ringwald void btstack_memory_l2cap_service_free(void *l2cap_service){
93a3b02b71Smatthias.ringwald     memory_pool_free(&l2cap_service_pool, l2cap_service);
94a3b02b71Smatthias.ringwald }
95*c4d3f927Smatthias.ringwald #else
96*c4d3f927Smatthias.ringwald void * btstack_memory_l2cap_service_get(void){
97*c4d3f927Smatthias.ringwald     return NULL;
98*c4d3f927Smatthias.ringwald }
99*c4d3f927Smatthias.ringwald void btstack_memory_l2cap_service_free(void *l2cap_service){
100*c4d3f927Smatthias.ringwald };
101*c4d3f927Smatthias.ringwald #endif
102a3b02b71Smatthias.ringwald #elif defined(HAVE_MALLOC)
103a3b02b71Smatthias.ringwald void * btstack_memory_l2cap_service_get(void){
104a3b02b71Smatthias.ringwald     return malloc(sizeof(l2cap_service_t));
105a3b02b71Smatthias.ringwald }
106a3b02b71Smatthias.ringwald void  btstack_memory_l2cap_service_free(void *l2cap_service){
107a3b02b71Smatthias.ringwald     free(l2cap_service);
108a3b02b71Smatthias.ringwald }
109a3b02b71Smatthias.ringwald #endif
110a3b02b71Smatthias.ringwald 
111a3b02b71Smatthias.ringwald 
112a3b02b71Smatthias.ringwald // MARK: l2cap_channel_t
113a3b02b71Smatthias.ringwald #ifdef MAX_NO_L2CAP_CHANNELS
114*c4d3f927Smatthias.ringwald #if MAX_NO_L2CAP_CHANNELS > 0
115a3b02b71Smatthias.ringwald static l2cap_channel_t l2cap_channel_storage[MAX_NO_L2CAP_CHANNELS];
116a3b02b71Smatthias.ringwald static memory_pool_t l2cap_channel_pool;
117a3b02b71Smatthias.ringwald void * btstack_memory_l2cap_channel_get(void){
118a3b02b71Smatthias.ringwald     return memory_pool_get(&l2cap_channel_pool);
119a3b02b71Smatthias.ringwald }
120a3b02b71Smatthias.ringwald void btstack_memory_l2cap_channel_free(void *l2cap_channel){
121a3b02b71Smatthias.ringwald     memory_pool_free(&l2cap_channel_pool, l2cap_channel);
122a3b02b71Smatthias.ringwald }
123*c4d3f927Smatthias.ringwald #else
124*c4d3f927Smatthias.ringwald void * btstack_memory_l2cap_channel_get(void){
125*c4d3f927Smatthias.ringwald     return NULL;
126*c4d3f927Smatthias.ringwald }
127*c4d3f927Smatthias.ringwald void btstack_memory_l2cap_channel_free(void *l2cap_channel){
128*c4d3f927Smatthias.ringwald };
129*c4d3f927Smatthias.ringwald #endif
130a3b02b71Smatthias.ringwald #elif defined(HAVE_MALLOC)
131a3b02b71Smatthias.ringwald void * btstack_memory_l2cap_channel_get(void){
132a3b02b71Smatthias.ringwald     return malloc(sizeof(l2cap_channel_t));
133a3b02b71Smatthias.ringwald }
134a3b02b71Smatthias.ringwald void  btstack_memory_l2cap_channel_free(void *l2cap_channel){
135a3b02b71Smatthias.ringwald     free(l2cap_channel);
136a3b02b71Smatthias.ringwald }
137a3b02b71Smatthias.ringwald #endif
138a3b02b71Smatthias.ringwald 
139a3b02b71Smatthias.ringwald 
140a3b02b71Smatthias.ringwald // MARK: rfcomm_multiplexer_t
141a3b02b71Smatthias.ringwald #ifdef MAX_NO_RFCOMM_MULTIPLEXERS
142*c4d3f927Smatthias.ringwald #if MAX_NO_RFCOMM_MULTIPLEXERS > 0
143a3b02b71Smatthias.ringwald static rfcomm_multiplexer_t rfcomm_multiplexer_storage[MAX_NO_RFCOMM_MULTIPLEXERS];
144a3b02b71Smatthias.ringwald static memory_pool_t rfcomm_multiplexer_pool;
145a3b02b71Smatthias.ringwald void * btstack_memory_rfcomm_multiplexer_get(void){
146a3b02b71Smatthias.ringwald     return memory_pool_get(&rfcomm_multiplexer_pool);
147a3b02b71Smatthias.ringwald }
148a3b02b71Smatthias.ringwald void btstack_memory_rfcomm_multiplexer_free(void *rfcomm_multiplexer){
149a3b02b71Smatthias.ringwald     memory_pool_free(&rfcomm_multiplexer_pool, rfcomm_multiplexer);
150a3b02b71Smatthias.ringwald }
151*c4d3f927Smatthias.ringwald #else
152*c4d3f927Smatthias.ringwald void * btstack_memory_rfcomm_multiplexer_get(void){
153*c4d3f927Smatthias.ringwald     return NULL;
154*c4d3f927Smatthias.ringwald }
155*c4d3f927Smatthias.ringwald void btstack_memory_rfcomm_multiplexer_free(void *rfcomm_multiplexer){
156*c4d3f927Smatthias.ringwald };
157*c4d3f927Smatthias.ringwald #endif
158a3b02b71Smatthias.ringwald #elif defined(HAVE_MALLOC)
159a3b02b71Smatthias.ringwald void * btstack_memory_rfcomm_multiplexer_get(void){
160a3b02b71Smatthias.ringwald     return malloc(sizeof(rfcomm_multiplexer_t));
161a3b02b71Smatthias.ringwald }
162a3b02b71Smatthias.ringwald void  btstack_memory_rfcomm_multiplexer_free(void *rfcomm_multiplexer){
163a3b02b71Smatthias.ringwald     free(rfcomm_multiplexer);
164a3b02b71Smatthias.ringwald }
165a3b02b71Smatthias.ringwald #endif
166a3b02b71Smatthias.ringwald 
167a3b02b71Smatthias.ringwald 
168a3b02b71Smatthias.ringwald // MARK: rfcomm_service_t
169a3b02b71Smatthias.ringwald #ifdef MAX_NO_RFCOMM_SERVICES
170*c4d3f927Smatthias.ringwald #if MAX_NO_RFCOMM_SERVICES > 0
171a3b02b71Smatthias.ringwald static rfcomm_service_t rfcomm_service_storage[MAX_NO_RFCOMM_SERVICES];
172a3b02b71Smatthias.ringwald static memory_pool_t rfcomm_service_pool;
173a3b02b71Smatthias.ringwald void * btstack_memory_rfcomm_service_get(void){
174a3b02b71Smatthias.ringwald     return memory_pool_get(&rfcomm_service_pool);
175a3b02b71Smatthias.ringwald }
176a3b02b71Smatthias.ringwald void btstack_memory_rfcomm_service_free(void *rfcomm_service){
177a3b02b71Smatthias.ringwald     memory_pool_free(&rfcomm_service_pool, rfcomm_service);
178a3b02b71Smatthias.ringwald }
179*c4d3f927Smatthias.ringwald #else
180*c4d3f927Smatthias.ringwald void * btstack_memory_rfcomm_service_get(void){
181*c4d3f927Smatthias.ringwald     return NULL;
182*c4d3f927Smatthias.ringwald }
183*c4d3f927Smatthias.ringwald void btstack_memory_rfcomm_service_free(void *rfcomm_service){
184*c4d3f927Smatthias.ringwald };
185*c4d3f927Smatthias.ringwald #endif
186a3b02b71Smatthias.ringwald #elif defined(HAVE_MALLOC)
187a3b02b71Smatthias.ringwald void * btstack_memory_rfcomm_service_get(void){
188a3b02b71Smatthias.ringwald     return malloc(sizeof(rfcomm_service_t));
189a3b02b71Smatthias.ringwald }
190a3b02b71Smatthias.ringwald void  btstack_memory_rfcomm_service_free(void *rfcomm_service){
191a3b02b71Smatthias.ringwald     free(rfcomm_service);
192a3b02b71Smatthias.ringwald }
193a3b02b71Smatthias.ringwald #endif
194a3b02b71Smatthias.ringwald 
195a3b02b71Smatthias.ringwald 
196a3b02b71Smatthias.ringwald // MARK: rfcomm_channel_t
197a3b02b71Smatthias.ringwald #ifdef MAX_NO_RFCOMM_CHANNELS
198*c4d3f927Smatthias.ringwald #if MAX_NO_RFCOMM_CHANNELS > 0
199a3b02b71Smatthias.ringwald static rfcomm_channel_t rfcomm_channel_storage[MAX_NO_RFCOMM_CHANNELS];
200a3b02b71Smatthias.ringwald static memory_pool_t rfcomm_channel_pool;
201a3b02b71Smatthias.ringwald void * btstack_memory_rfcomm_channel_get(void){
202a3b02b71Smatthias.ringwald     return memory_pool_get(&rfcomm_channel_pool);
203a3b02b71Smatthias.ringwald }
204a3b02b71Smatthias.ringwald void btstack_memory_rfcomm_channel_free(void *rfcomm_channel){
205a3b02b71Smatthias.ringwald     memory_pool_free(&rfcomm_channel_pool, rfcomm_channel);
206a3b02b71Smatthias.ringwald }
207*c4d3f927Smatthias.ringwald #else
208*c4d3f927Smatthias.ringwald void * btstack_memory_rfcomm_channel_get(void){
209*c4d3f927Smatthias.ringwald     return NULL;
210*c4d3f927Smatthias.ringwald }
211*c4d3f927Smatthias.ringwald void btstack_memory_rfcomm_channel_free(void *rfcomm_channel){
212*c4d3f927Smatthias.ringwald };
213*c4d3f927Smatthias.ringwald #endif
214a3b02b71Smatthias.ringwald #elif defined(HAVE_MALLOC)
215a3b02b71Smatthias.ringwald void * btstack_memory_rfcomm_channel_get(void){
216a3b02b71Smatthias.ringwald     return malloc(sizeof(rfcomm_channel_t));
217a3b02b71Smatthias.ringwald }
218a3b02b71Smatthias.ringwald void  btstack_memory_rfcomm_channel_free(void *rfcomm_channel){
219a3b02b71Smatthias.ringwald     free(rfcomm_channel);
220a3b02b71Smatthias.ringwald }
221a3b02b71Smatthias.ringwald #endif
222a3b02b71Smatthias.ringwald 
223e0e5e285Smatthias.ringwald 
224e0e5e285Smatthias.ringwald // MARK: db_mem_device_name_t
225e0e5e285Smatthias.ringwald #ifdef MAX_NO_DB_MEM_DEVICE_NAMES
226*c4d3f927Smatthias.ringwald #if MAX_NO_DB_MEM_DEVICE_NAMES > 0
227e0e5e285Smatthias.ringwald static db_mem_device_name_t db_mem_device_name_storage[MAX_NO_DB_MEM_DEVICE_NAMES];
228e0e5e285Smatthias.ringwald static memory_pool_t db_mem_device_name_pool;
229e0e5e285Smatthias.ringwald void * btstack_memory_db_mem_device_name_get(void){
230e0e5e285Smatthias.ringwald     return memory_pool_get(&db_mem_device_name_pool);
2311801b596Smatthias.ringwald }
232e0e5e285Smatthias.ringwald void btstack_memory_db_mem_device_name_free(void *db_mem_device_name){
233e0e5e285Smatthias.ringwald     memory_pool_free(&db_mem_device_name_pool, db_mem_device_name);
2341801b596Smatthias.ringwald }
235*c4d3f927Smatthias.ringwald #else
236*c4d3f927Smatthias.ringwald void * btstack_memory_db_mem_device_name_get(void){
237*c4d3f927Smatthias.ringwald     return NULL;
238*c4d3f927Smatthias.ringwald }
239*c4d3f927Smatthias.ringwald void btstack_memory_db_mem_device_name_free(void *db_mem_device_name){
240*c4d3f927Smatthias.ringwald };
241*c4d3f927Smatthias.ringwald #endif
2421801b596Smatthias.ringwald #elif defined(HAVE_MALLOC)
243e0e5e285Smatthias.ringwald void * btstack_memory_db_mem_device_name_get(void){
244e0e5e285Smatthias.ringwald     return malloc(sizeof(db_mem_device_name_t));
2451801b596Smatthias.ringwald }
246e0e5e285Smatthias.ringwald void  btstack_memory_db_mem_device_name_free(void *db_mem_device_name){
247e0e5e285Smatthias.ringwald     free(db_mem_device_name);
248e0e5e285Smatthias.ringwald }
249e0e5e285Smatthias.ringwald #endif
250e0e5e285Smatthias.ringwald 
251e0e5e285Smatthias.ringwald 
252e0e5e285Smatthias.ringwald // MARK: db_mem_device_link_key_t
253e0e5e285Smatthias.ringwald #ifdef MAX_NO_DB_MEM_DEVICE_LINK_KEYS
254*c4d3f927Smatthias.ringwald #if MAX_NO_DB_MEM_DEVICE_LINK_KEYS > 0
255e0e5e285Smatthias.ringwald static db_mem_device_link_key_t db_mem_device_link_key_storage[MAX_NO_DB_MEM_DEVICE_LINK_KEYS];
256e0e5e285Smatthias.ringwald static memory_pool_t db_mem_device_link_key_pool;
257e0e5e285Smatthias.ringwald void * btstack_memory_db_mem_device_link_key_get(void){
258e0e5e285Smatthias.ringwald     return memory_pool_get(&db_mem_device_link_key_pool);
259e0e5e285Smatthias.ringwald }
260e0e5e285Smatthias.ringwald void btstack_memory_db_mem_device_link_key_free(void *db_mem_device_link_key){
261e0e5e285Smatthias.ringwald     memory_pool_free(&db_mem_device_link_key_pool, db_mem_device_link_key);
262e0e5e285Smatthias.ringwald }
263*c4d3f927Smatthias.ringwald #else
264*c4d3f927Smatthias.ringwald void * btstack_memory_db_mem_device_link_key_get(void){
265*c4d3f927Smatthias.ringwald     return NULL;
266*c4d3f927Smatthias.ringwald }
267*c4d3f927Smatthias.ringwald void btstack_memory_db_mem_device_link_key_free(void *db_mem_device_link_key){
268*c4d3f927Smatthias.ringwald };
269*c4d3f927Smatthias.ringwald #endif
270e0e5e285Smatthias.ringwald #elif defined(HAVE_MALLOC)
271e0e5e285Smatthias.ringwald void * btstack_memory_db_mem_device_link_key_get(void){
272e0e5e285Smatthias.ringwald     return malloc(sizeof(db_mem_device_link_key_t));
273e0e5e285Smatthias.ringwald }
274e0e5e285Smatthias.ringwald void  btstack_memory_db_mem_device_link_key_free(void *db_mem_device_link_key){
275e0e5e285Smatthias.ringwald     free(db_mem_device_link_key);
2761801b596Smatthias.ringwald }
2771801b596Smatthias.ringwald #endif
2781801b596Smatthias.ringwald 
2791801b596Smatthias.ringwald 
2801801b596Smatthias.ringwald // MARK: db_mem_service_t
2811801b596Smatthias.ringwald #ifdef MAX_NO_DB_MEM_SERVICES
282*c4d3f927Smatthias.ringwald #if MAX_NO_DB_MEM_SERVICES > 0
2831801b596Smatthias.ringwald static db_mem_service_t db_mem_service_storage[MAX_NO_DB_MEM_SERVICES];
2841801b596Smatthias.ringwald static memory_pool_t db_mem_service_pool;
2851801b596Smatthias.ringwald void * btstack_memory_db_mem_service_get(void){
2861801b596Smatthias.ringwald     return memory_pool_get(&db_mem_service_pool);
2871801b596Smatthias.ringwald }
2881801b596Smatthias.ringwald void btstack_memory_db_mem_service_free(void *db_mem_service){
2891801b596Smatthias.ringwald     memory_pool_free(&db_mem_service_pool, db_mem_service);
2901801b596Smatthias.ringwald }
291*c4d3f927Smatthias.ringwald #else
292*c4d3f927Smatthias.ringwald void * btstack_memory_db_mem_service_get(void){
293*c4d3f927Smatthias.ringwald     return NULL;
294*c4d3f927Smatthias.ringwald }
295*c4d3f927Smatthias.ringwald void btstack_memory_db_mem_service_free(void *db_mem_service){
296*c4d3f927Smatthias.ringwald };
297*c4d3f927Smatthias.ringwald #endif
2981801b596Smatthias.ringwald #elif defined(HAVE_MALLOC)
2991801b596Smatthias.ringwald void * btstack_memory_db_mem_service_get(void){
3001801b596Smatthias.ringwald     return malloc(sizeof(db_mem_service_t));
3011801b596Smatthias.ringwald }
3021801b596Smatthias.ringwald void  btstack_memory_db_mem_service_free(void *db_mem_service){
3031801b596Smatthias.ringwald     free(db_mem_service);
3041801b596Smatthias.ringwald }
3051801b596Smatthias.ringwald #endif
3061801b596Smatthias.ringwald 
307a3b02b71Smatthias.ringwald // init
308a3b02b71Smatthias.ringwald void btstack_memory_init(void){
309*c4d3f927Smatthias.ringwald #if MAX_NO_HCI_CONNECTIONS > 0
310a3b02b71Smatthias.ringwald     memory_pool_create(&hci_connection_pool, hci_connection_storage, MAX_NO_HCI_CONNECTIONS, sizeof(hci_connection_t));
311a3b02b71Smatthias.ringwald #endif
312*c4d3f927Smatthias.ringwald #if MAX_NO_L2CAP_SERVICES > 0
313a3b02b71Smatthias.ringwald     memory_pool_create(&l2cap_service_pool, l2cap_service_storage, MAX_NO_L2CAP_SERVICES, sizeof(l2cap_service_t));
314a3b02b71Smatthias.ringwald #endif
315*c4d3f927Smatthias.ringwald #if MAX_NO_L2CAP_CHANNELS > 0
316a3b02b71Smatthias.ringwald     memory_pool_create(&l2cap_channel_pool, l2cap_channel_storage, MAX_NO_L2CAP_CHANNELS, sizeof(l2cap_channel_t));
317a3b02b71Smatthias.ringwald #endif
318*c4d3f927Smatthias.ringwald #if MAX_NO_RFCOMM_MULTIPLEXERS > 0
319a3b02b71Smatthias.ringwald     memory_pool_create(&rfcomm_multiplexer_pool, rfcomm_multiplexer_storage, MAX_NO_RFCOMM_MULTIPLEXERS, sizeof(rfcomm_multiplexer_t));
320a3b02b71Smatthias.ringwald #endif
321*c4d3f927Smatthias.ringwald #if MAX_NO_RFCOMM_SERVICES > 0
322a3b02b71Smatthias.ringwald     memory_pool_create(&rfcomm_service_pool, rfcomm_service_storage, MAX_NO_RFCOMM_SERVICES, sizeof(rfcomm_service_t));
323a3b02b71Smatthias.ringwald #endif
324*c4d3f927Smatthias.ringwald #if MAX_NO_RFCOMM_CHANNELS > 0
325a3b02b71Smatthias.ringwald     memory_pool_create(&rfcomm_channel_pool, rfcomm_channel_storage, MAX_NO_RFCOMM_CHANNELS, sizeof(rfcomm_channel_t));
326a3b02b71Smatthias.ringwald #endif
327*c4d3f927Smatthias.ringwald #if MAX_NO_DB_MEM_DEVICE_NAMES > 0
328e0e5e285Smatthias.ringwald     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));
329e0e5e285Smatthias.ringwald #endif
330*c4d3f927Smatthias.ringwald #if MAX_NO_DB_MEM_DEVICE_LINK_KEYS > 0
331e0e5e285Smatthias.ringwald     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));
3321801b596Smatthias.ringwald #endif
333*c4d3f927Smatthias.ringwald #if MAX_NO_DB_MEM_SERVICES > 0
3341801b596Smatthias.ringwald     memory_pool_create(&db_mem_service_pool, db_mem_service_storage, MAX_NO_DB_MEM_SERVICES, sizeof(db_mem_service_t));
3351801b596Smatthias.ringwald #endif
336a3b02b71Smatthias.ringwald }
337