1 /*
2 * Copyright (C) 2014 BlueKitchen GmbH
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
6 * are met:
7 *
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
13 * 3. Neither the name of the copyright holders nor the names of
14 * contributors may be used to endorse or promote products derived
15 * from this software without specific prior written permission.
16 * 4. Any redistribution, use, or modification is done solely for
17 * personal benefit and not for any commercial purpose or for
18 * monetary gain.
19 *
20 * THIS SOFTWARE IS PROVIDED BY BLUEKITCHEN GMBH AND CONTRIBUTORS
21 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
23 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BLUEKITCHEN
24 * GMBH OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
25 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
26 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
27 * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
28 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
29 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
30 * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31 * SUCH DAMAGE.
32 *
33 * Please inquire about commercial licensing options at
34 * [email protected]
35 *
36 */
37
38
39 #define BTSTACK_FILE__ "btstack_memory.c"
40
41
42 /*
43 * btstack_memory.c
44 *
45 * @brief BTstack memory management via configurable memory pools
46 *
47 * @note code generated by tool/btstack_memory_generator.py
48 * @note returnes buffers are initialized with 0
49 *
50 */
51
52 #include "btstack_memory.h"
53 #include "btstack_memory_pool.h"
54 #include "btstack_debug.h"
55
56 #include <stdlib.h>
57
58 #ifdef ENABLE_MALLOC_TEST
59 void * test_malloc(size_t size);
60 #define malloc test_malloc
61 #endif
62
63 #ifdef HAVE_MALLOC
64 typedef struct btstack_memory_buffer {
65 struct btstack_memory_buffer * next;
66 struct btstack_memory_buffer * prev;
67 } btstack_memory_buffer_t;
68
69 typedef struct {
70 btstack_memory_buffer_t tracking;
71 void * pointer;
72 } test_buffer_t;
73
74 static btstack_memory_buffer_t * btstack_memory_malloc_buffers;
75 static uint32_t btstack_memory_malloc_counter;
76
btstack_memory_tracking_add(btstack_memory_buffer_t * buffer)77 static void btstack_memory_tracking_add(btstack_memory_buffer_t * buffer){
78 btstack_assert(buffer != NULL);
79 if (btstack_memory_malloc_buffers != NULL) {
80 // let current first item prev point to new first item
81 btstack_memory_malloc_buffers->prev = buffer;
82 }
83 buffer->prev = NULL;
84 buffer->next = btstack_memory_malloc_buffers;
85 btstack_memory_malloc_buffers = buffer;
86
87 btstack_memory_malloc_counter++;
88 }
89
btstack_memory_tracking_remove(btstack_memory_buffer_t * buffer)90 static void btstack_memory_tracking_remove(btstack_memory_buffer_t * buffer){
91 btstack_assert(buffer != NULL);
92 if (buffer->prev == NULL){
93 // first item
94 btstack_memory_malloc_buffers = buffer->next;
95 } else {
96 buffer->prev->next = buffer->next;
97 }
98 if (buffer->next != NULL){
99 buffer->next->prev = buffer->prev;
100 }
101
102 btstack_memory_malloc_counter--;
103 }
104 #endif
105
btstack_memory_deinit(void)106 void btstack_memory_deinit(void){
107 #ifdef HAVE_MALLOC
108 while (btstack_memory_malloc_buffers != NULL){
109 btstack_memory_buffer_t * buffer = btstack_memory_malloc_buffers;
110 btstack_memory_malloc_buffers = buffer->next;
111 free(buffer);
112 btstack_memory_malloc_counter--;
113 }
114 btstack_assert(btstack_memory_malloc_counter == 0);
115 #endif
116 }
117
118
119 // MARK: hci_connection_t
120 #if !defined(HAVE_MALLOC) && !defined(MAX_NR_HCI_CONNECTIONS)
121 #if defined(MAX_NO_HCI_CONNECTIONS)
122 #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."
123 #else
124 #define MAX_NR_HCI_CONNECTIONS 0
125 #endif
126 #endif
127
128 #ifdef MAX_NR_HCI_CONNECTIONS
129 #if MAX_NR_HCI_CONNECTIONS > 0
130 static hci_connection_t hci_connection_storage[MAX_NR_HCI_CONNECTIONS];
131 static btstack_memory_pool_t hci_connection_pool;
btstack_memory_hci_connection_get(void)132 hci_connection_t * btstack_memory_hci_connection_get(void){
133 void * buffer = btstack_memory_pool_get(&hci_connection_pool);
134 if (buffer){
135 memset(buffer, 0, sizeof(hci_connection_t));
136 }
137 return (hci_connection_t *) buffer;
138 }
btstack_memory_hci_connection_free(hci_connection_t * hci_connection)139 void btstack_memory_hci_connection_free(hci_connection_t *hci_connection){
140 btstack_memory_pool_free(&hci_connection_pool, hci_connection);
141 }
142 #else
btstack_memory_hci_connection_get(void)143 hci_connection_t * btstack_memory_hci_connection_get(void){
144 return NULL;
145 }
btstack_memory_hci_connection_free(hci_connection_t * hci_connection)146 void btstack_memory_hci_connection_free(hci_connection_t *hci_connection){
147 UNUSED(hci_connection);
148 }
149 #endif
150 #elif defined(HAVE_MALLOC)
151
152 typedef struct {
153 btstack_memory_buffer_t tracking;
154 hci_connection_t data;
155 } btstack_memory_hci_connection_t;
156
btstack_memory_hci_connection_get(void)157 hci_connection_t * btstack_memory_hci_connection_get(void){
158 btstack_memory_hci_connection_t * buffer = (btstack_memory_hci_connection_t *) malloc(sizeof(btstack_memory_hci_connection_t));
159 if (buffer){
160 memset(buffer, 0, sizeof(btstack_memory_hci_connection_t));
161 btstack_memory_tracking_add(&buffer->tracking);
162 return &buffer->data;
163 } else {
164 return NULL;
165 }
166 }
btstack_memory_hci_connection_free(hci_connection_t * hci_connection)167 void btstack_memory_hci_connection_free(hci_connection_t *hci_connection){
168 // reconstruct buffer start
169 btstack_memory_buffer_t * buffer = &((btstack_memory_buffer_t *) hci_connection)[-1];
170 btstack_memory_tracking_remove(buffer);
171 free(buffer);
172 }
173 #endif
174
175
176
177 // MARK: l2cap_service_t
178 #if !defined(HAVE_MALLOC) && !defined(MAX_NR_L2CAP_SERVICES)
179 #if defined(MAX_NO_L2CAP_SERVICES)
180 #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."
181 #else
182 #define MAX_NR_L2CAP_SERVICES 0
183 #endif
184 #endif
185
186 #ifdef MAX_NR_L2CAP_SERVICES
187 #if MAX_NR_L2CAP_SERVICES > 0
188 static l2cap_service_t l2cap_service_storage[MAX_NR_L2CAP_SERVICES];
189 static btstack_memory_pool_t l2cap_service_pool;
btstack_memory_l2cap_service_get(void)190 l2cap_service_t * btstack_memory_l2cap_service_get(void){
191 void * buffer = btstack_memory_pool_get(&l2cap_service_pool);
192 if (buffer){
193 memset(buffer, 0, sizeof(l2cap_service_t));
194 }
195 return (l2cap_service_t *) buffer;
196 }
btstack_memory_l2cap_service_free(l2cap_service_t * l2cap_service)197 void btstack_memory_l2cap_service_free(l2cap_service_t *l2cap_service){
198 btstack_memory_pool_free(&l2cap_service_pool, l2cap_service);
199 }
200 #else
btstack_memory_l2cap_service_get(void)201 l2cap_service_t * btstack_memory_l2cap_service_get(void){
202 return NULL;
203 }
btstack_memory_l2cap_service_free(l2cap_service_t * l2cap_service)204 void btstack_memory_l2cap_service_free(l2cap_service_t *l2cap_service){
205 UNUSED(l2cap_service);
206 }
207 #endif
208 #elif defined(HAVE_MALLOC)
209
210 typedef struct {
211 btstack_memory_buffer_t tracking;
212 l2cap_service_t data;
213 } btstack_memory_l2cap_service_t;
214
btstack_memory_l2cap_service_get(void)215 l2cap_service_t * btstack_memory_l2cap_service_get(void){
216 btstack_memory_l2cap_service_t * buffer = (btstack_memory_l2cap_service_t *) malloc(sizeof(btstack_memory_l2cap_service_t));
217 if (buffer){
218 memset(buffer, 0, sizeof(btstack_memory_l2cap_service_t));
219 btstack_memory_tracking_add(&buffer->tracking);
220 return &buffer->data;
221 } else {
222 return NULL;
223 }
224 }
btstack_memory_l2cap_service_free(l2cap_service_t * l2cap_service)225 void btstack_memory_l2cap_service_free(l2cap_service_t *l2cap_service){
226 // reconstruct buffer start
227 btstack_memory_buffer_t * buffer = &((btstack_memory_buffer_t *) l2cap_service)[-1];
228 btstack_memory_tracking_remove(buffer);
229 free(buffer);
230 }
231 #endif
232
233
234 // MARK: l2cap_channel_t
235 #if !defined(HAVE_MALLOC) && !defined(MAX_NR_L2CAP_CHANNELS)
236 #if defined(MAX_NO_L2CAP_CHANNELS)
237 #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."
238 #else
239 #define MAX_NR_L2CAP_CHANNELS 0
240 #endif
241 #endif
242
243 #ifdef MAX_NR_L2CAP_CHANNELS
244 #if MAX_NR_L2CAP_CHANNELS > 0
245 static l2cap_channel_t l2cap_channel_storage[MAX_NR_L2CAP_CHANNELS];
246 static btstack_memory_pool_t l2cap_channel_pool;
btstack_memory_l2cap_channel_get(void)247 l2cap_channel_t * btstack_memory_l2cap_channel_get(void){
248 void * buffer = btstack_memory_pool_get(&l2cap_channel_pool);
249 if (buffer){
250 memset(buffer, 0, sizeof(l2cap_channel_t));
251 }
252 return (l2cap_channel_t *) buffer;
253 }
btstack_memory_l2cap_channel_free(l2cap_channel_t * l2cap_channel)254 void btstack_memory_l2cap_channel_free(l2cap_channel_t *l2cap_channel){
255 btstack_memory_pool_free(&l2cap_channel_pool, l2cap_channel);
256 }
257 #else
btstack_memory_l2cap_channel_get(void)258 l2cap_channel_t * btstack_memory_l2cap_channel_get(void){
259 return NULL;
260 }
btstack_memory_l2cap_channel_free(l2cap_channel_t * l2cap_channel)261 void btstack_memory_l2cap_channel_free(l2cap_channel_t *l2cap_channel){
262 UNUSED(l2cap_channel);
263 }
264 #endif
265 #elif defined(HAVE_MALLOC)
266
267 typedef struct {
268 btstack_memory_buffer_t tracking;
269 l2cap_channel_t data;
270 } btstack_memory_l2cap_channel_t;
271
btstack_memory_l2cap_channel_get(void)272 l2cap_channel_t * btstack_memory_l2cap_channel_get(void){
273 btstack_memory_l2cap_channel_t * buffer = (btstack_memory_l2cap_channel_t *) malloc(sizeof(btstack_memory_l2cap_channel_t));
274 if (buffer){
275 memset(buffer, 0, sizeof(btstack_memory_l2cap_channel_t));
276 btstack_memory_tracking_add(&buffer->tracking);
277 return &buffer->data;
278 } else {
279 return NULL;
280 }
281 }
btstack_memory_l2cap_channel_free(l2cap_channel_t * l2cap_channel)282 void btstack_memory_l2cap_channel_free(l2cap_channel_t *l2cap_channel){
283 // reconstruct buffer start
284 btstack_memory_buffer_t * buffer = &((btstack_memory_buffer_t *) l2cap_channel)[-1];
285 btstack_memory_tracking_remove(buffer);
286 free(buffer);
287 }
288 #endif
289
290
291 #ifdef ENABLE_CLASSIC
292
293 // MARK: rfcomm_multiplexer_t
294 #if !defined(HAVE_MALLOC) && !defined(MAX_NR_RFCOMM_MULTIPLEXERS)
295 #if defined(MAX_NO_RFCOMM_MULTIPLEXERS)
296 #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."
297 #else
298 #define MAX_NR_RFCOMM_MULTIPLEXERS 0
299 #endif
300 #endif
301
302 #ifdef MAX_NR_RFCOMM_MULTIPLEXERS
303 #if MAX_NR_RFCOMM_MULTIPLEXERS > 0
304 static rfcomm_multiplexer_t rfcomm_multiplexer_storage[MAX_NR_RFCOMM_MULTIPLEXERS];
305 static btstack_memory_pool_t rfcomm_multiplexer_pool;
btstack_memory_rfcomm_multiplexer_get(void)306 rfcomm_multiplexer_t * btstack_memory_rfcomm_multiplexer_get(void){
307 void * buffer = btstack_memory_pool_get(&rfcomm_multiplexer_pool);
308 if (buffer){
309 memset(buffer, 0, sizeof(rfcomm_multiplexer_t));
310 }
311 return (rfcomm_multiplexer_t *) buffer;
312 }
btstack_memory_rfcomm_multiplexer_free(rfcomm_multiplexer_t * rfcomm_multiplexer)313 void btstack_memory_rfcomm_multiplexer_free(rfcomm_multiplexer_t *rfcomm_multiplexer){
314 btstack_memory_pool_free(&rfcomm_multiplexer_pool, rfcomm_multiplexer);
315 }
316 #else
btstack_memory_rfcomm_multiplexer_get(void)317 rfcomm_multiplexer_t * btstack_memory_rfcomm_multiplexer_get(void){
318 return NULL;
319 }
btstack_memory_rfcomm_multiplexer_free(rfcomm_multiplexer_t * rfcomm_multiplexer)320 void btstack_memory_rfcomm_multiplexer_free(rfcomm_multiplexer_t *rfcomm_multiplexer){
321 UNUSED(rfcomm_multiplexer);
322 }
323 #endif
324 #elif defined(HAVE_MALLOC)
325
326 typedef struct {
327 btstack_memory_buffer_t tracking;
328 rfcomm_multiplexer_t data;
329 } btstack_memory_rfcomm_multiplexer_t;
330
btstack_memory_rfcomm_multiplexer_get(void)331 rfcomm_multiplexer_t * btstack_memory_rfcomm_multiplexer_get(void){
332 btstack_memory_rfcomm_multiplexer_t * buffer = (btstack_memory_rfcomm_multiplexer_t *) malloc(sizeof(btstack_memory_rfcomm_multiplexer_t));
333 if (buffer){
334 memset(buffer, 0, sizeof(btstack_memory_rfcomm_multiplexer_t));
335 btstack_memory_tracking_add(&buffer->tracking);
336 return &buffer->data;
337 } else {
338 return NULL;
339 }
340 }
btstack_memory_rfcomm_multiplexer_free(rfcomm_multiplexer_t * rfcomm_multiplexer)341 void btstack_memory_rfcomm_multiplexer_free(rfcomm_multiplexer_t *rfcomm_multiplexer){
342 // reconstruct buffer start
343 btstack_memory_buffer_t * buffer = &((btstack_memory_buffer_t *) rfcomm_multiplexer)[-1];
344 btstack_memory_tracking_remove(buffer);
345 free(buffer);
346 }
347 #endif
348
349
350 // MARK: rfcomm_service_t
351 #if !defined(HAVE_MALLOC) && !defined(MAX_NR_RFCOMM_SERVICES)
352 #if defined(MAX_NO_RFCOMM_SERVICES)
353 #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."
354 #else
355 #define MAX_NR_RFCOMM_SERVICES 0
356 #endif
357 #endif
358
359 #ifdef MAX_NR_RFCOMM_SERVICES
360 #if MAX_NR_RFCOMM_SERVICES > 0
361 static rfcomm_service_t rfcomm_service_storage[MAX_NR_RFCOMM_SERVICES];
362 static btstack_memory_pool_t rfcomm_service_pool;
btstack_memory_rfcomm_service_get(void)363 rfcomm_service_t * btstack_memory_rfcomm_service_get(void){
364 void * buffer = btstack_memory_pool_get(&rfcomm_service_pool);
365 if (buffer){
366 memset(buffer, 0, sizeof(rfcomm_service_t));
367 }
368 return (rfcomm_service_t *) buffer;
369 }
btstack_memory_rfcomm_service_free(rfcomm_service_t * rfcomm_service)370 void btstack_memory_rfcomm_service_free(rfcomm_service_t *rfcomm_service){
371 btstack_memory_pool_free(&rfcomm_service_pool, rfcomm_service);
372 }
373 #else
btstack_memory_rfcomm_service_get(void)374 rfcomm_service_t * btstack_memory_rfcomm_service_get(void){
375 return NULL;
376 }
btstack_memory_rfcomm_service_free(rfcomm_service_t * rfcomm_service)377 void btstack_memory_rfcomm_service_free(rfcomm_service_t *rfcomm_service){
378 UNUSED(rfcomm_service);
379 }
380 #endif
381 #elif defined(HAVE_MALLOC)
382
383 typedef struct {
384 btstack_memory_buffer_t tracking;
385 rfcomm_service_t data;
386 } btstack_memory_rfcomm_service_t;
387
btstack_memory_rfcomm_service_get(void)388 rfcomm_service_t * btstack_memory_rfcomm_service_get(void){
389 btstack_memory_rfcomm_service_t * buffer = (btstack_memory_rfcomm_service_t *) malloc(sizeof(btstack_memory_rfcomm_service_t));
390 if (buffer){
391 memset(buffer, 0, sizeof(btstack_memory_rfcomm_service_t));
392 btstack_memory_tracking_add(&buffer->tracking);
393 return &buffer->data;
394 } else {
395 return NULL;
396 }
397 }
btstack_memory_rfcomm_service_free(rfcomm_service_t * rfcomm_service)398 void btstack_memory_rfcomm_service_free(rfcomm_service_t *rfcomm_service){
399 // reconstruct buffer start
400 btstack_memory_buffer_t * buffer = &((btstack_memory_buffer_t *) rfcomm_service)[-1];
401 btstack_memory_tracking_remove(buffer);
402 free(buffer);
403 }
404 #endif
405
406
407 // MARK: rfcomm_channel_t
408 #if !defined(HAVE_MALLOC) && !defined(MAX_NR_RFCOMM_CHANNELS)
409 #if defined(MAX_NO_RFCOMM_CHANNELS)
410 #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."
411 #else
412 #define MAX_NR_RFCOMM_CHANNELS 0
413 #endif
414 #endif
415
416 #ifdef MAX_NR_RFCOMM_CHANNELS
417 #if MAX_NR_RFCOMM_CHANNELS > 0
418 static rfcomm_channel_t rfcomm_channel_storage[MAX_NR_RFCOMM_CHANNELS];
419 static btstack_memory_pool_t rfcomm_channel_pool;
btstack_memory_rfcomm_channel_get(void)420 rfcomm_channel_t * btstack_memory_rfcomm_channel_get(void){
421 void * buffer = btstack_memory_pool_get(&rfcomm_channel_pool);
422 if (buffer){
423 memset(buffer, 0, sizeof(rfcomm_channel_t));
424 }
425 return (rfcomm_channel_t *) buffer;
426 }
btstack_memory_rfcomm_channel_free(rfcomm_channel_t * rfcomm_channel)427 void btstack_memory_rfcomm_channel_free(rfcomm_channel_t *rfcomm_channel){
428 btstack_memory_pool_free(&rfcomm_channel_pool, rfcomm_channel);
429 }
430 #else
btstack_memory_rfcomm_channel_get(void)431 rfcomm_channel_t * btstack_memory_rfcomm_channel_get(void){
432 return NULL;
433 }
btstack_memory_rfcomm_channel_free(rfcomm_channel_t * rfcomm_channel)434 void btstack_memory_rfcomm_channel_free(rfcomm_channel_t *rfcomm_channel){
435 UNUSED(rfcomm_channel);
436 }
437 #endif
438 #elif defined(HAVE_MALLOC)
439
440 typedef struct {
441 btstack_memory_buffer_t tracking;
442 rfcomm_channel_t data;
443 } btstack_memory_rfcomm_channel_t;
444
btstack_memory_rfcomm_channel_get(void)445 rfcomm_channel_t * btstack_memory_rfcomm_channel_get(void){
446 btstack_memory_rfcomm_channel_t * buffer = (btstack_memory_rfcomm_channel_t *) malloc(sizeof(btstack_memory_rfcomm_channel_t));
447 if (buffer){
448 memset(buffer, 0, sizeof(btstack_memory_rfcomm_channel_t));
449 btstack_memory_tracking_add(&buffer->tracking);
450 return &buffer->data;
451 } else {
452 return NULL;
453 }
454 }
btstack_memory_rfcomm_channel_free(rfcomm_channel_t * rfcomm_channel)455 void btstack_memory_rfcomm_channel_free(rfcomm_channel_t *rfcomm_channel){
456 // reconstruct buffer start
457 btstack_memory_buffer_t * buffer = &((btstack_memory_buffer_t *) rfcomm_channel)[-1];
458 btstack_memory_tracking_remove(buffer);
459 free(buffer);
460 }
461 #endif
462
463
464
465 // MARK: btstack_link_key_db_memory_entry_t
466 #if !defined(HAVE_MALLOC) && !defined(MAX_NR_BTSTACK_LINK_KEY_DB_MEMORY_ENTRIES)
467 #if defined(MAX_NO_BTSTACK_LINK_KEY_DB_MEMORY_ENTRIES)
468 #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."
469 #else
470 #define MAX_NR_BTSTACK_LINK_KEY_DB_MEMORY_ENTRIES 0
471 #endif
472 #endif
473
474 #ifdef MAX_NR_BTSTACK_LINK_KEY_DB_MEMORY_ENTRIES
475 #if MAX_NR_BTSTACK_LINK_KEY_DB_MEMORY_ENTRIES > 0
476 static btstack_link_key_db_memory_entry_t btstack_link_key_db_memory_entry_storage[MAX_NR_BTSTACK_LINK_KEY_DB_MEMORY_ENTRIES];
477 static btstack_memory_pool_t btstack_link_key_db_memory_entry_pool;
btstack_memory_btstack_link_key_db_memory_entry_get(void)478 btstack_link_key_db_memory_entry_t * btstack_memory_btstack_link_key_db_memory_entry_get(void){
479 void * buffer = btstack_memory_pool_get(&btstack_link_key_db_memory_entry_pool);
480 if (buffer){
481 memset(buffer, 0, sizeof(btstack_link_key_db_memory_entry_t));
482 }
483 return (btstack_link_key_db_memory_entry_t *) buffer;
484 }
btstack_memory_btstack_link_key_db_memory_entry_free(btstack_link_key_db_memory_entry_t * btstack_link_key_db_memory_entry)485 void btstack_memory_btstack_link_key_db_memory_entry_free(btstack_link_key_db_memory_entry_t *btstack_link_key_db_memory_entry){
486 btstack_memory_pool_free(&btstack_link_key_db_memory_entry_pool, btstack_link_key_db_memory_entry);
487 }
488 #else
btstack_memory_btstack_link_key_db_memory_entry_get(void)489 btstack_link_key_db_memory_entry_t * btstack_memory_btstack_link_key_db_memory_entry_get(void){
490 return NULL;
491 }
btstack_memory_btstack_link_key_db_memory_entry_free(btstack_link_key_db_memory_entry_t * btstack_link_key_db_memory_entry)492 void btstack_memory_btstack_link_key_db_memory_entry_free(btstack_link_key_db_memory_entry_t *btstack_link_key_db_memory_entry){
493 UNUSED(btstack_link_key_db_memory_entry);
494 }
495 #endif
496 #elif defined(HAVE_MALLOC)
497
498 typedef struct {
499 btstack_memory_buffer_t tracking;
500 btstack_link_key_db_memory_entry_t data;
501 } btstack_memory_btstack_link_key_db_memory_entry_t;
502
btstack_memory_btstack_link_key_db_memory_entry_get(void)503 btstack_link_key_db_memory_entry_t * btstack_memory_btstack_link_key_db_memory_entry_get(void){
504 btstack_memory_btstack_link_key_db_memory_entry_t * buffer = (btstack_memory_btstack_link_key_db_memory_entry_t *) malloc(sizeof(btstack_memory_btstack_link_key_db_memory_entry_t));
505 if (buffer){
506 memset(buffer, 0, sizeof(btstack_memory_btstack_link_key_db_memory_entry_t));
507 btstack_memory_tracking_add(&buffer->tracking);
508 return &buffer->data;
509 } else {
510 return NULL;
511 }
512 }
btstack_memory_btstack_link_key_db_memory_entry_free(btstack_link_key_db_memory_entry_t * btstack_link_key_db_memory_entry)513 void btstack_memory_btstack_link_key_db_memory_entry_free(btstack_link_key_db_memory_entry_t *btstack_link_key_db_memory_entry){
514 // reconstruct buffer start
515 btstack_memory_buffer_t * buffer = &((btstack_memory_buffer_t *) btstack_link_key_db_memory_entry)[-1];
516 btstack_memory_tracking_remove(buffer);
517 free(buffer);
518 }
519 #endif
520
521
522
523 // MARK: bnep_service_t
524 #if !defined(HAVE_MALLOC) && !defined(MAX_NR_BNEP_SERVICES)
525 #if defined(MAX_NO_BNEP_SERVICES)
526 #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."
527 #else
528 #define MAX_NR_BNEP_SERVICES 0
529 #endif
530 #endif
531
532 #ifdef MAX_NR_BNEP_SERVICES
533 #if MAX_NR_BNEP_SERVICES > 0
534 static bnep_service_t bnep_service_storage[MAX_NR_BNEP_SERVICES];
535 static btstack_memory_pool_t bnep_service_pool;
btstack_memory_bnep_service_get(void)536 bnep_service_t * btstack_memory_bnep_service_get(void){
537 void * buffer = btstack_memory_pool_get(&bnep_service_pool);
538 if (buffer){
539 memset(buffer, 0, sizeof(bnep_service_t));
540 }
541 return (bnep_service_t *) buffer;
542 }
btstack_memory_bnep_service_free(bnep_service_t * bnep_service)543 void btstack_memory_bnep_service_free(bnep_service_t *bnep_service){
544 btstack_memory_pool_free(&bnep_service_pool, bnep_service);
545 }
546 #else
btstack_memory_bnep_service_get(void)547 bnep_service_t * btstack_memory_bnep_service_get(void){
548 return NULL;
549 }
btstack_memory_bnep_service_free(bnep_service_t * bnep_service)550 void btstack_memory_bnep_service_free(bnep_service_t *bnep_service){
551 UNUSED(bnep_service);
552 }
553 #endif
554 #elif defined(HAVE_MALLOC)
555
556 typedef struct {
557 btstack_memory_buffer_t tracking;
558 bnep_service_t data;
559 } btstack_memory_bnep_service_t;
560
btstack_memory_bnep_service_get(void)561 bnep_service_t * btstack_memory_bnep_service_get(void){
562 btstack_memory_bnep_service_t * buffer = (btstack_memory_bnep_service_t *) malloc(sizeof(btstack_memory_bnep_service_t));
563 if (buffer){
564 memset(buffer, 0, sizeof(btstack_memory_bnep_service_t));
565 btstack_memory_tracking_add(&buffer->tracking);
566 return &buffer->data;
567 } else {
568 return NULL;
569 }
570 }
btstack_memory_bnep_service_free(bnep_service_t * bnep_service)571 void btstack_memory_bnep_service_free(bnep_service_t *bnep_service){
572 // reconstruct buffer start
573 btstack_memory_buffer_t * buffer = &((btstack_memory_buffer_t *) bnep_service)[-1];
574 btstack_memory_tracking_remove(buffer);
575 free(buffer);
576 }
577 #endif
578
579
580 // MARK: bnep_channel_t
581 #if !defined(HAVE_MALLOC) && !defined(MAX_NR_BNEP_CHANNELS)
582 #if defined(MAX_NO_BNEP_CHANNELS)
583 #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."
584 #else
585 #define MAX_NR_BNEP_CHANNELS 0
586 #endif
587 #endif
588
589 #ifdef MAX_NR_BNEP_CHANNELS
590 #if MAX_NR_BNEP_CHANNELS > 0
591 static bnep_channel_t bnep_channel_storage[MAX_NR_BNEP_CHANNELS];
592 static btstack_memory_pool_t bnep_channel_pool;
btstack_memory_bnep_channel_get(void)593 bnep_channel_t * btstack_memory_bnep_channel_get(void){
594 void * buffer = btstack_memory_pool_get(&bnep_channel_pool);
595 if (buffer){
596 memset(buffer, 0, sizeof(bnep_channel_t));
597 }
598 return (bnep_channel_t *) buffer;
599 }
btstack_memory_bnep_channel_free(bnep_channel_t * bnep_channel)600 void btstack_memory_bnep_channel_free(bnep_channel_t *bnep_channel){
601 btstack_memory_pool_free(&bnep_channel_pool, bnep_channel);
602 }
603 #else
btstack_memory_bnep_channel_get(void)604 bnep_channel_t * btstack_memory_bnep_channel_get(void){
605 return NULL;
606 }
btstack_memory_bnep_channel_free(bnep_channel_t * bnep_channel)607 void btstack_memory_bnep_channel_free(bnep_channel_t *bnep_channel){
608 UNUSED(bnep_channel);
609 }
610 #endif
611 #elif defined(HAVE_MALLOC)
612
613 typedef struct {
614 btstack_memory_buffer_t tracking;
615 bnep_channel_t data;
616 } btstack_memory_bnep_channel_t;
617
btstack_memory_bnep_channel_get(void)618 bnep_channel_t * btstack_memory_bnep_channel_get(void){
619 btstack_memory_bnep_channel_t * buffer = (btstack_memory_bnep_channel_t *) malloc(sizeof(btstack_memory_bnep_channel_t));
620 if (buffer){
621 memset(buffer, 0, sizeof(btstack_memory_bnep_channel_t));
622 btstack_memory_tracking_add(&buffer->tracking);
623 return &buffer->data;
624 } else {
625 return NULL;
626 }
627 }
btstack_memory_bnep_channel_free(bnep_channel_t * bnep_channel)628 void btstack_memory_bnep_channel_free(bnep_channel_t *bnep_channel){
629 // reconstruct buffer start
630 btstack_memory_buffer_t * buffer = &((btstack_memory_buffer_t *) bnep_channel)[-1];
631 btstack_memory_tracking_remove(buffer);
632 free(buffer);
633 }
634 #endif
635
636
637
638 // MARK: goep_server_service_t
639 #if !defined(HAVE_MALLOC) && !defined(MAX_NR_GOEP_SERVER_SERVICES)
640 #if defined(MAX_NO_GOEP_SERVER_SERVICES)
641 #error "Deprecated MAX_NO_GOEP_SERVER_SERVICES defined instead of MAX_NR_GOEP_SERVER_SERVICES. Please update your btstack_config.h to use MAX_NR_GOEP_SERVER_SERVICES."
642 #else
643 #define MAX_NR_GOEP_SERVER_SERVICES 0
644 #endif
645 #endif
646
647 #ifdef MAX_NR_GOEP_SERVER_SERVICES
648 #if MAX_NR_GOEP_SERVER_SERVICES > 0
649 static goep_server_service_t goep_server_service_storage[MAX_NR_GOEP_SERVER_SERVICES];
650 static btstack_memory_pool_t goep_server_service_pool;
btstack_memory_goep_server_service_get(void)651 goep_server_service_t * btstack_memory_goep_server_service_get(void){
652 void * buffer = btstack_memory_pool_get(&goep_server_service_pool);
653 if (buffer){
654 memset(buffer, 0, sizeof(goep_server_service_t));
655 }
656 return (goep_server_service_t *) buffer;
657 }
btstack_memory_goep_server_service_free(goep_server_service_t * goep_server_service)658 void btstack_memory_goep_server_service_free(goep_server_service_t *goep_server_service){
659 btstack_memory_pool_free(&goep_server_service_pool, goep_server_service);
660 }
661 #else
btstack_memory_goep_server_service_get(void)662 goep_server_service_t * btstack_memory_goep_server_service_get(void){
663 return NULL;
664 }
btstack_memory_goep_server_service_free(goep_server_service_t * goep_server_service)665 void btstack_memory_goep_server_service_free(goep_server_service_t *goep_server_service){
666 UNUSED(goep_server_service);
667 }
668 #endif
669 #elif defined(HAVE_MALLOC)
670
671 typedef struct {
672 btstack_memory_buffer_t tracking;
673 goep_server_service_t data;
674 } btstack_memory_goep_server_service_t;
675
btstack_memory_goep_server_service_get(void)676 goep_server_service_t * btstack_memory_goep_server_service_get(void){
677 btstack_memory_goep_server_service_t * buffer = (btstack_memory_goep_server_service_t *) malloc(sizeof(btstack_memory_goep_server_service_t));
678 if (buffer){
679 memset(buffer, 0, sizeof(btstack_memory_goep_server_service_t));
680 btstack_memory_tracking_add(&buffer->tracking);
681 return &buffer->data;
682 } else {
683 return NULL;
684 }
685 }
btstack_memory_goep_server_service_free(goep_server_service_t * goep_server_service)686 void btstack_memory_goep_server_service_free(goep_server_service_t *goep_server_service){
687 // reconstruct buffer start
688 btstack_memory_buffer_t * buffer = &((btstack_memory_buffer_t *) goep_server_service)[-1];
689 btstack_memory_tracking_remove(buffer);
690 free(buffer);
691 }
692 #endif
693
694
695 // MARK: goep_server_connection_t
696 #if !defined(HAVE_MALLOC) && !defined(MAX_NR_GOEP_SERVER_CONNECTIONS)
697 #if defined(MAX_NO_GOEP_SERVER_CONNECTIONS)
698 #error "Deprecated MAX_NO_GOEP_SERVER_CONNECTIONS defined instead of MAX_NR_GOEP_SERVER_CONNECTIONS. Please update your btstack_config.h to use MAX_NR_GOEP_SERVER_CONNECTIONS."
699 #else
700 #define MAX_NR_GOEP_SERVER_CONNECTIONS 0
701 #endif
702 #endif
703
704 #ifdef MAX_NR_GOEP_SERVER_CONNECTIONS
705 #if MAX_NR_GOEP_SERVER_CONNECTIONS > 0
706 static goep_server_connection_t goep_server_connection_storage[MAX_NR_GOEP_SERVER_CONNECTIONS];
707 static btstack_memory_pool_t goep_server_connection_pool;
btstack_memory_goep_server_connection_get(void)708 goep_server_connection_t * btstack_memory_goep_server_connection_get(void){
709 void * buffer = btstack_memory_pool_get(&goep_server_connection_pool);
710 if (buffer){
711 memset(buffer, 0, sizeof(goep_server_connection_t));
712 }
713 return (goep_server_connection_t *) buffer;
714 }
btstack_memory_goep_server_connection_free(goep_server_connection_t * goep_server_connection)715 void btstack_memory_goep_server_connection_free(goep_server_connection_t *goep_server_connection){
716 btstack_memory_pool_free(&goep_server_connection_pool, goep_server_connection);
717 }
718 #else
btstack_memory_goep_server_connection_get(void)719 goep_server_connection_t * btstack_memory_goep_server_connection_get(void){
720 return NULL;
721 }
btstack_memory_goep_server_connection_free(goep_server_connection_t * goep_server_connection)722 void btstack_memory_goep_server_connection_free(goep_server_connection_t *goep_server_connection){
723 UNUSED(goep_server_connection);
724 }
725 #endif
726 #elif defined(HAVE_MALLOC)
727
728 typedef struct {
729 btstack_memory_buffer_t tracking;
730 goep_server_connection_t data;
731 } btstack_memory_goep_server_connection_t;
732
btstack_memory_goep_server_connection_get(void)733 goep_server_connection_t * btstack_memory_goep_server_connection_get(void){
734 btstack_memory_goep_server_connection_t * buffer = (btstack_memory_goep_server_connection_t *) malloc(sizeof(btstack_memory_goep_server_connection_t));
735 if (buffer){
736 memset(buffer, 0, sizeof(btstack_memory_goep_server_connection_t));
737 btstack_memory_tracking_add(&buffer->tracking);
738 return &buffer->data;
739 } else {
740 return NULL;
741 }
742 }
btstack_memory_goep_server_connection_free(goep_server_connection_t * goep_server_connection)743 void btstack_memory_goep_server_connection_free(goep_server_connection_t *goep_server_connection){
744 // reconstruct buffer start
745 btstack_memory_buffer_t * buffer = &((btstack_memory_buffer_t *) goep_server_connection)[-1];
746 btstack_memory_tracking_remove(buffer);
747 free(buffer);
748 }
749 #endif
750
751
752
753 // MARK: hfp_connection_t
754 #if !defined(HAVE_MALLOC) && !defined(MAX_NR_HFP_CONNECTIONS)
755 #if defined(MAX_NO_HFP_CONNECTIONS)
756 #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."
757 #else
758 #define MAX_NR_HFP_CONNECTIONS 0
759 #endif
760 #endif
761
762 #ifdef MAX_NR_HFP_CONNECTIONS
763 #if MAX_NR_HFP_CONNECTIONS > 0
764 static hfp_connection_t hfp_connection_storage[MAX_NR_HFP_CONNECTIONS];
765 static btstack_memory_pool_t hfp_connection_pool;
btstack_memory_hfp_connection_get(void)766 hfp_connection_t * btstack_memory_hfp_connection_get(void){
767 void * buffer = btstack_memory_pool_get(&hfp_connection_pool);
768 if (buffer){
769 memset(buffer, 0, sizeof(hfp_connection_t));
770 }
771 return (hfp_connection_t *) buffer;
772 }
btstack_memory_hfp_connection_free(hfp_connection_t * hfp_connection)773 void btstack_memory_hfp_connection_free(hfp_connection_t *hfp_connection){
774 btstack_memory_pool_free(&hfp_connection_pool, hfp_connection);
775 }
776 #else
btstack_memory_hfp_connection_get(void)777 hfp_connection_t * btstack_memory_hfp_connection_get(void){
778 return NULL;
779 }
btstack_memory_hfp_connection_free(hfp_connection_t * hfp_connection)780 void btstack_memory_hfp_connection_free(hfp_connection_t *hfp_connection){
781 UNUSED(hfp_connection);
782 }
783 #endif
784 #elif defined(HAVE_MALLOC)
785
786 typedef struct {
787 btstack_memory_buffer_t tracking;
788 hfp_connection_t data;
789 } btstack_memory_hfp_connection_t;
790
btstack_memory_hfp_connection_get(void)791 hfp_connection_t * btstack_memory_hfp_connection_get(void){
792 btstack_memory_hfp_connection_t * buffer = (btstack_memory_hfp_connection_t *) malloc(sizeof(btstack_memory_hfp_connection_t));
793 if (buffer){
794 memset(buffer, 0, sizeof(btstack_memory_hfp_connection_t));
795 btstack_memory_tracking_add(&buffer->tracking);
796 return &buffer->data;
797 } else {
798 return NULL;
799 }
800 }
btstack_memory_hfp_connection_free(hfp_connection_t * hfp_connection)801 void btstack_memory_hfp_connection_free(hfp_connection_t *hfp_connection){
802 // reconstruct buffer start
803 btstack_memory_buffer_t * buffer = &((btstack_memory_buffer_t *) hfp_connection)[-1];
804 btstack_memory_tracking_remove(buffer);
805 free(buffer);
806 }
807 #endif
808
809
810
811 // MARK: hid_host_connection_t
812 #if !defined(HAVE_MALLOC) && !defined(MAX_NR_HID_HOST_CONNECTIONS)
813 #if defined(MAX_NO_HID_HOST_CONNECTIONS)
814 #error "Deprecated MAX_NO_HID_HOST_CONNECTIONS defined instead of MAX_NR_HID_HOST_CONNECTIONS. Please update your btstack_config.h to use MAX_NR_HID_HOST_CONNECTIONS."
815 #else
816 #define MAX_NR_HID_HOST_CONNECTIONS 0
817 #endif
818 #endif
819
820 #ifdef MAX_NR_HID_HOST_CONNECTIONS
821 #if MAX_NR_HID_HOST_CONNECTIONS > 0
822 static hid_host_connection_t hid_host_connection_storage[MAX_NR_HID_HOST_CONNECTIONS];
823 static btstack_memory_pool_t hid_host_connection_pool;
btstack_memory_hid_host_connection_get(void)824 hid_host_connection_t * btstack_memory_hid_host_connection_get(void){
825 void * buffer = btstack_memory_pool_get(&hid_host_connection_pool);
826 if (buffer){
827 memset(buffer, 0, sizeof(hid_host_connection_t));
828 }
829 return (hid_host_connection_t *) buffer;
830 }
btstack_memory_hid_host_connection_free(hid_host_connection_t * hid_host_connection)831 void btstack_memory_hid_host_connection_free(hid_host_connection_t *hid_host_connection){
832 btstack_memory_pool_free(&hid_host_connection_pool, hid_host_connection);
833 }
834 #else
btstack_memory_hid_host_connection_get(void)835 hid_host_connection_t * btstack_memory_hid_host_connection_get(void){
836 return NULL;
837 }
btstack_memory_hid_host_connection_free(hid_host_connection_t * hid_host_connection)838 void btstack_memory_hid_host_connection_free(hid_host_connection_t *hid_host_connection){
839 UNUSED(hid_host_connection);
840 }
841 #endif
842 #elif defined(HAVE_MALLOC)
843
844 typedef struct {
845 btstack_memory_buffer_t tracking;
846 hid_host_connection_t data;
847 } btstack_memory_hid_host_connection_t;
848
btstack_memory_hid_host_connection_get(void)849 hid_host_connection_t * btstack_memory_hid_host_connection_get(void){
850 btstack_memory_hid_host_connection_t * buffer = (btstack_memory_hid_host_connection_t *) malloc(sizeof(btstack_memory_hid_host_connection_t));
851 if (buffer){
852 memset(buffer, 0, sizeof(btstack_memory_hid_host_connection_t));
853 btstack_memory_tracking_add(&buffer->tracking);
854 return &buffer->data;
855 } else {
856 return NULL;
857 }
858 }
btstack_memory_hid_host_connection_free(hid_host_connection_t * hid_host_connection)859 void btstack_memory_hid_host_connection_free(hid_host_connection_t *hid_host_connection){
860 // reconstruct buffer start
861 btstack_memory_buffer_t * buffer = &((btstack_memory_buffer_t *) hid_host_connection)[-1];
862 btstack_memory_tracking_remove(buffer);
863 free(buffer);
864 }
865 #endif
866
867
868
869 // MARK: service_record_item_t
870 #if !defined(HAVE_MALLOC) && !defined(MAX_NR_SERVICE_RECORD_ITEMS)
871 #if defined(MAX_NO_SERVICE_RECORD_ITEMS)
872 #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."
873 #else
874 #define MAX_NR_SERVICE_RECORD_ITEMS 0
875 #endif
876 #endif
877
878 #ifdef MAX_NR_SERVICE_RECORD_ITEMS
879 #if MAX_NR_SERVICE_RECORD_ITEMS > 0
880 static service_record_item_t service_record_item_storage[MAX_NR_SERVICE_RECORD_ITEMS];
881 static btstack_memory_pool_t service_record_item_pool;
btstack_memory_service_record_item_get(void)882 service_record_item_t * btstack_memory_service_record_item_get(void){
883 void * buffer = btstack_memory_pool_get(&service_record_item_pool);
884 if (buffer){
885 memset(buffer, 0, sizeof(service_record_item_t));
886 }
887 return (service_record_item_t *) buffer;
888 }
btstack_memory_service_record_item_free(service_record_item_t * service_record_item)889 void btstack_memory_service_record_item_free(service_record_item_t *service_record_item){
890 btstack_memory_pool_free(&service_record_item_pool, service_record_item);
891 }
892 #else
btstack_memory_service_record_item_get(void)893 service_record_item_t * btstack_memory_service_record_item_get(void){
894 return NULL;
895 }
btstack_memory_service_record_item_free(service_record_item_t * service_record_item)896 void btstack_memory_service_record_item_free(service_record_item_t *service_record_item){
897 UNUSED(service_record_item);
898 }
899 #endif
900 #elif defined(HAVE_MALLOC)
901
902 typedef struct {
903 btstack_memory_buffer_t tracking;
904 service_record_item_t data;
905 } btstack_memory_service_record_item_t;
906
btstack_memory_service_record_item_get(void)907 service_record_item_t * btstack_memory_service_record_item_get(void){
908 btstack_memory_service_record_item_t * buffer = (btstack_memory_service_record_item_t *) malloc(sizeof(btstack_memory_service_record_item_t));
909 if (buffer){
910 memset(buffer, 0, sizeof(btstack_memory_service_record_item_t));
911 btstack_memory_tracking_add(&buffer->tracking);
912 return &buffer->data;
913 } else {
914 return NULL;
915 }
916 }
btstack_memory_service_record_item_free(service_record_item_t * service_record_item)917 void btstack_memory_service_record_item_free(service_record_item_t *service_record_item){
918 // reconstruct buffer start
919 btstack_memory_buffer_t * buffer = &((btstack_memory_buffer_t *) service_record_item)[-1];
920 btstack_memory_tracking_remove(buffer);
921 free(buffer);
922 }
923 #endif
924
925
926
927 // MARK: avdtp_stream_endpoint_t
928 #if !defined(HAVE_MALLOC) && !defined(MAX_NR_AVDTP_STREAM_ENDPOINTS)
929 #if defined(MAX_NO_AVDTP_STREAM_ENDPOINTS)
930 #error "Deprecated MAX_NO_AVDTP_STREAM_ENDPOINTS defined instead of MAX_NR_AVDTP_STREAM_ENDPOINTS. Please update your btstack_config.h to use MAX_NR_AVDTP_STREAM_ENDPOINTS."
931 #else
932 #define MAX_NR_AVDTP_STREAM_ENDPOINTS 0
933 #endif
934 #endif
935
936 #ifdef MAX_NR_AVDTP_STREAM_ENDPOINTS
937 #if MAX_NR_AVDTP_STREAM_ENDPOINTS > 0
938 static avdtp_stream_endpoint_t avdtp_stream_endpoint_storage[MAX_NR_AVDTP_STREAM_ENDPOINTS];
939 static btstack_memory_pool_t avdtp_stream_endpoint_pool;
btstack_memory_avdtp_stream_endpoint_get(void)940 avdtp_stream_endpoint_t * btstack_memory_avdtp_stream_endpoint_get(void){
941 void * buffer = btstack_memory_pool_get(&avdtp_stream_endpoint_pool);
942 if (buffer){
943 memset(buffer, 0, sizeof(avdtp_stream_endpoint_t));
944 }
945 return (avdtp_stream_endpoint_t *) buffer;
946 }
btstack_memory_avdtp_stream_endpoint_free(avdtp_stream_endpoint_t * avdtp_stream_endpoint)947 void btstack_memory_avdtp_stream_endpoint_free(avdtp_stream_endpoint_t *avdtp_stream_endpoint){
948 btstack_memory_pool_free(&avdtp_stream_endpoint_pool, avdtp_stream_endpoint);
949 }
950 #else
btstack_memory_avdtp_stream_endpoint_get(void)951 avdtp_stream_endpoint_t * btstack_memory_avdtp_stream_endpoint_get(void){
952 return NULL;
953 }
btstack_memory_avdtp_stream_endpoint_free(avdtp_stream_endpoint_t * avdtp_stream_endpoint)954 void btstack_memory_avdtp_stream_endpoint_free(avdtp_stream_endpoint_t *avdtp_stream_endpoint){
955 UNUSED(avdtp_stream_endpoint);
956 }
957 #endif
958 #elif defined(HAVE_MALLOC)
959
960 typedef struct {
961 btstack_memory_buffer_t tracking;
962 avdtp_stream_endpoint_t data;
963 } btstack_memory_avdtp_stream_endpoint_t;
964
btstack_memory_avdtp_stream_endpoint_get(void)965 avdtp_stream_endpoint_t * btstack_memory_avdtp_stream_endpoint_get(void){
966 btstack_memory_avdtp_stream_endpoint_t * buffer = (btstack_memory_avdtp_stream_endpoint_t *) malloc(sizeof(btstack_memory_avdtp_stream_endpoint_t));
967 if (buffer){
968 memset(buffer, 0, sizeof(btstack_memory_avdtp_stream_endpoint_t));
969 btstack_memory_tracking_add(&buffer->tracking);
970 return &buffer->data;
971 } else {
972 return NULL;
973 }
974 }
btstack_memory_avdtp_stream_endpoint_free(avdtp_stream_endpoint_t * avdtp_stream_endpoint)975 void btstack_memory_avdtp_stream_endpoint_free(avdtp_stream_endpoint_t *avdtp_stream_endpoint){
976 // reconstruct buffer start
977 btstack_memory_buffer_t * buffer = &((btstack_memory_buffer_t *) avdtp_stream_endpoint)[-1];
978 btstack_memory_tracking_remove(buffer);
979 free(buffer);
980 }
981 #endif
982
983
984
985 // MARK: avdtp_connection_t
986 #if !defined(HAVE_MALLOC) && !defined(MAX_NR_AVDTP_CONNECTIONS)
987 #if defined(MAX_NO_AVDTP_CONNECTIONS)
988 #error "Deprecated MAX_NO_AVDTP_CONNECTIONS defined instead of MAX_NR_AVDTP_CONNECTIONS. Please update your btstack_config.h to use MAX_NR_AVDTP_CONNECTIONS."
989 #else
990 #define MAX_NR_AVDTP_CONNECTIONS 0
991 #endif
992 #endif
993
994 #ifdef MAX_NR_AVDTP_CONNECTIONS
995 #if MAX_NR_AVDTP_CONNECTIONS > 0
996 static avdtp_connection_t avdtp_connection_storage[MAX_NR_AVDTP_CONNECTIONS];
997 static btstack_memory_pool_t avdtp_connection_pool;
btstack_memory_avdtp_connection_get(void)998 avdtp_connection_t * btstack_memory_avdtp_connection_get(void){
999 void * buffer = btstack_memory_pool_get(&avdtp_connection_pool);
1000 if (buffer){
1001 memset(buffer, 0, sizeof(avdtp_connection_t));
1002 }
1003 return (avdtp_connection_t *) buffer;
1004 }
btstack_memory_avdtp_connection_free(avdtp_connection_t * avdtp_connection)1005 void btstack_memory_avdtp_connection_free(avdtp_connection_t *avdtp_connection){
1006 btstack_memory_pool_free(&avdtp_connection_pool, avdtp_connection);
1007 }
1008 #else
btstack_memory_avdtp_connection_get(void)1009 avdtp_connection_t * btstack_memory_avdtp_connection_get(void){
1010 return NULL;
1011 }
btstack_memory_avdtp_connection_free(avdtp_connection_t * avdtp_connection)1012 void btstack_memory_avdtp_connection_free(avdtp_connection_t *avdtp_connection){
1013 UNUSED(avdtp_connection);
1014 }
1015 #endif
1016 #elif defined(HAVE_MALLOC)
1017
1018 typedef struct {
1019 btstack_memory_buffer_t tracking;
1020 avdtp_connection_t data;
1021 } btstack_memory_avdtp_connection_t;
1022
btstack_memory_avdtp_connection_get(void)1023 avdtp_connection_t * btstack_memory_avdtp_connection_get(void){
1024 btstack_memory_avdtp_connection_t * buffer = (btstack_memory_avdtp_connection_t *) malloc(sizeof(btstack_memory_avdtp_connection_t));
1025 if (buffer){
1026 memset(buffer, 0, sizeof(btstack_memory_avdtp_connection_t));
1027 btstack_memory_tracking_add(&buffer->tracking);
1028 return &buffer->data;
1029 } else {
1030 return NULL;
1031 }
1032 }
btstack_memory_avdtp_connection_free(avdtp_connection_t * avdtp_connection)1033 void btstack_memory_avdtp_connection_free(avdtp_connection_t *avdtp_connection){
1034 // reconstruct buffer start
1035 btstack_memory_buffer_t * buffer = &((btstack_memory_buffer_t *) avdtp_connection)[-1];
1036 btstack_memory_tracking_remove(buffer);
1037 free(buffer);
1038 }
1039 #endif
1040
1041
1042
1043 // MARK: avrcp_connection_t
1044 #if !defined(HAVE_MALLOC) && !defined(MAX_NR_AVRCP_CONNECTIONS)
1045 #if defined(MAX_NO_AVRCP_CONNECTIONS)
1046 #error "Deprecated MAX_NO_AVRCP_CONNECTIONS defined instead of MAX_NR_AVRCP_CONNECTIONS. Please update your btstack_config.h to use MAX_NR_AVRCP_CONNECTIONS."
1047 #else
1048 #define MAX_NR_AVRCP_CONNECTIONS 0
1049 #endif
1050 #endif
1051
1052 #ifdef MAX_NR_AVRCP_CONNECTIONS
1053 #if MAX_NR_AVRCP_CONNECTIONS > 0
1054 static avrcp_connection_t avrcp_connection_storage[MAX_NR_AVRCP_CONNECTIONS];
1055 static btstack_memory_pool_t avrcp_connection_pool;
btstack_memory_avrcp_connection_get(void)1056 avrcp_connection_t * btstack_memory_avrcp_connection_get(void){
1057 void * buffer = btstack_memory_pool_get(&avrcp_connection_pool);
1058 if (buffer){
1059 memset(buffer, 0, sizeof(avrcp_connection_t));
1060 }
1061 return (avrcp_connection_t *) buffer;
1062 }
btstack_memory_avrcp_connection_free(avrcp_connection_t * avrcp_connection)1063 void btstack_memory_avrcp_connection_free(avrcp_connection_t *avrcp_connection){
1064 btstack_memory_pool_free(&avrcp_connection_pool, avrcp_connection);
1065 }
1066 #else
btstack_memory_avrcp_connection_get(void)1067 avrcp_connection_t * btstack_memory_avrcp_connection_get(void){
1068 return NULL;
1069 }
btstack_memory_avrcp_connection_free(avrcp_connection_t * avrcp_connection)1070 void btstack_memory_avrcp_connection_free(avrcp_connection_t *avrcp_connection){
1071 UNUSED(avrcp_connection);
1072 }
1073 #endif
1074 #elif defined(HAVE_MALLOC)
1075
1076 typedef struct {
1077 btstack_memory_buffer_t tracking;
1078 avrcp_connection_t data;
1079 } btstack_memory_avrcp_connection_t;
1080
btstack_memory_avrcp_connection_get(void)1081 avrcp_connection_t * btstack_memory_avrcp_connection_get(void){
1082 btstack_memory_avrcp_connection_t * buffer = (btstack_memory_avrcp_connection_t *) malloc(sizeof(btstack_memory_avrcp_connection_t));
1083 if (buffer){
1084 memset(buffer, 0, sizeof(btstack_memory_avrcp_connection_t));
1085 btstack_memory_tracking_add(&buffer->tracking);
1086 return &buffer->data;
1087 } else {
1088 return NULL;
1089 }
1090 }
btstack_memory_avrcp_connection_free(avrcp_connection_t * avrcp_connection)1091 void btstack_memory_avrcp_connection_free(avrcp_connection_t *avrcp_connection){
1092 // reconstruct buffer start
1093 btstack_memory_buffer_t * buffer = &((btstack_memory_buffer_t *) avrcp_connection)[-1];
1094 btstack_memory_tracking_remove(buffer);
1095 free(buffer);
1096 }
1097 #endif
1098
1099
1100
1101 // MARK: avrcp_browsing_connection_t
1102 #if !defined(HAVE_MALLOC) && !defined(MAX_NR_AVRCP_BROWSING_CONNECTIONS)
1103 #if defined(MAX_NO_AVRCP_BROWSING_CONNECTIONS)
1104 #error "Deprecated MAX_NO_AVRCP_BROWSING_CONNECTIONS defined instead of MAX_NR_AVRCP_BROWSING_CONNECTIONS. Please update your btstack_config.h to use MAX_NR_AVRCP_BROWSING_CONNECTIONS."
1105 #else
1106 #define MAX_NR_AVRCP_BROWSING_CONNECTIONS 0
1107 #endif
1108 #endif
1109
1110 #ifdef MAX_NR_AVRCP_BROWSING_CONNECTIONS
1111 #if MAX_NR_AVRCP_BROWSING_CONNECTIONS > 0
1112 static avrcp_browsing_connection_t avrcp_browsing_connection_storage[MAX_NR_AVRCP_BROWSING_CONNECTIONS];
1113 static btstack_memory_pool_t avrcp_browsing_connection_pool;
btstack_memory_avrcp_browsing_connection_get(void)1114 avrcp_browsing_connection_t * btstack_memory_avrcp_browsing_connection_get(void){
1115 void * buffer = btstack_memory_pool_get(&avrcp_browsing_connection_pool);
1116 if (buffer){
1117 memset(buffer, 0, sizeof(avrcp_browsing_connection_t));
1118 }
1119 return (avrcp_browsing_connection_t *) buffer;
1120 }
btstack_memory_avrcp_browsing_connection_free(avrcp_browsing_connection_t * avrcp_browsing_connection)1121 void btstack_memory_avrcp_browsing_connection_free(avrcp_browsing_connection_t *avrcp_browsing_connection){
1122 btstack_memory_pool_free(&avrcp_browsing_connection_pool, avrcp_browsing_connection);
1123 }
1124 #else
btstack_memory_avrcp_browsing_connection_get(void)1125 avrcp_browsing_connection_t * btstack_memory_avrcp_browsing_connection_get(void){
1126 return NULL;
1127 }
btstack_memory_avrcp_browsing_connection_free(avrcp_browsing_connection_t * avrcp_browsing_connection)1128 void btstack_memory_avrcp_browsing_connection_free(avrcp_browsing_connection_t *avrcp_browsing_connection){
1129 UNUSED(avrcp_browsing_connection);
1130 }
1131 #endif
1132 #elif defined(HAVE_MALLOC)
1133
1134 typedef struct {
1135 btstack_memory_buffer_t tracking;
1136 avrcp_browsing_connection_t data;
1137 } btstack_memory_avrcp_browsing_connection_t;
1138
btstack_memory_avrcp_browsing_connection_get(void)1139 avrcp_browsing_connection_t * btstack_memory_avrcp_browsing_connection_get(void){
1140 btstack_memory_avrcp_browsing_connection_t * buffer = (btstack_memory_avrcp_browsing_connection_t *) malloc(sizeof(btstack_memory_avrcp_browsing_connection_t));
1141 if (buffer){
1142 memset(buffer, 0, sizeof(btstack_memory_avrcp_browsing_connection_t));
1143 btstack_memory_tracking_add(&buffer->tracking);
1144 return &buffer->data;
1145 } else {
1146 return NULL;
1147 }
1148 }
btstack_memory_avrcp_browsing_connection_free(avrcp_browsing_connection_t * avrcp_browsing_connection)1149 void btstack_memory_avrcp_browsing_connection_free(avrcp_browsing_connection_t *avrcp_browsing_connection){
1150 // reconstruct buffer start
1151 btstack_memory_buffer_t * buffer = &((btstack_memory_buffer_t *) avrcp_browsing_connection)[-1];
1152 btstack_memory_tracking_remove(buffer);
1153 free(buffer);
1154 }
1155 #endif
1156
1157
1158 #endif
1159 #ifdef ENABLE_BLE
1160
1161 // MARK: battery_service_client_t
1162 #if !defined(HAVE_MALLOC) && !defined(MAX_NR_BATTERY_SERVICE_CLIENTS)
1163 #if defined(MAX_NO_BATTERY_SERVICE_CLIENTS)
1164 #error "Deprecated MAX_NO_BATTERY_SERVICE_CLIENTS defined instead of MAX_NR_BATTERY_SERVICE_CLIENTS. Please update your btstack_config.h to use MAX_NR_BATTERY_SERVICE_CLIENTS."
1165 #else
1166 #define MAX_NR_BATTERY_SERVICE_CLIENTS 0
1167 #endif
1168 #endif
1169
1170 #ifdef MAX_NR_BATTERY_SERVICE_CLIENTS
1171 #if MAX_NR_BATTERY_SERVICE_CLIENTS > 0
1172 static battery_service_client_t battery_service_client_storage[MAX_NR_BATTERY_SERVICE_CLIENTS];
1173 static btstack_memory_pool_t battery_service_client_pool;
btstack_memory_battery_service_client_get(void)1174 battery_service_client_t * btstack_memory_battery_service_client_get(void){
1175 void * buffer = btstack_memory_pool_get(&battery_service_client_pool);
1176 if (buffer){
1177 memset(buffer, 0, sizeof(battery_service_client_t));
1178 }
1179 return (battery_service_client_t *) buffer;
1180 }
btstack_memory_battery_service_client_free(battery_service_client_t * battery_service_client)1181 void btstack_memory_battery_service_client_free(battery_service_client_t *battery_service_client){
1182 btstack_memory_pool_free(&battery_service_client_pool, battery_service_client);
1183 }
1184 #else
btstack_memory_battery_service_client_get(void)1185 battery_service_client_t * btstack_memory_battery_service_client_get(void){
1186 return NULL;
1187 }
btstack_memory_battery_service_client_free(battery_service_client_t * battery_service_client)1188 void btstack_memory_battery_service_client_free(battery_service_client_t *battery_service_client){
1189 UNUSED(battery_service_client);
1190 }
1191 #endif
1192 #elif defined(HAVE_MALLOC)
1193
1194 typedef struct {
1195 btstack_memory_buffer_t tracking;
1196 battery_service_client_t data;
1197 } btstack_memory_battery_service_client_t;
1198
btstack_memory_battery_service_client_get(void)1199 battery_service_client_t * btstack_memory_battery_service_client_get(void){
1200 btstack_memory_battery_service_client_t * buffer = (btstack_memory_battery_service_client_t *) malloc(sizeof(btstack_memory_battery_service_client_t));
1201 if (buffer){
1202 memset(buffer, 0, sizeof(btstack_memory_battery_service_client_t));
1203 btstack_memory_tracking_add(&buffer->tracking);
1204 return &buffer->data;
1205 } else {
1206 return NULL;
1207 }
1208 }
btstack_memory_battery_service_client_free(battery_service_client_t * battery_service_client)1209 void btstack_memory_battery_service_client_free(battery_service_client_t *battery_service_client){
1210 // reconstruct buffer start
1211 btstack_memory_buffer_t * buffer = &((btstack_memory_buffer_t *) battery_service_client)[-1];
1212 btstack_memory_tracking_remove(buffer);
1213 free(buffer);
1214 }
1215 #endif
1216
1217
1218 // MARK: gatt_client_t
1219 #if !defined(HAVE_MALLOC) && !defined(MAX_NR_GATT_CLIENTS)
1220 #if defined(MAX_NO_GATT_CLIENTS)
1221 #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."
1222 #else
1223 #define MAX_NR_GATT_CLIENTS 0
1224 #endif
1225 #endif
1226
1227 #ifdef MAX_NR_GATT_CLIENTS
1228 #if MAX_NR_GATT_CLIENTS > 0
1229 static gatt_client_t gatt_client_storage[MAX_NR_GATT_CLIENTS];
1230 static btstack_memory_pool_t gatt_client_pool;
btstack_memory_gatt_client_get(void)1231 gatt_client_t * btstack_memory_gatt_client_get(void){
1232 void * buffer = btstack_memory_pool_get(&gatt_client_pool);
1233 if (buffer){
1234 memset(buffer, 0, sizeof(gatt_client_t));
1235 }
1236 return (gatt_client_t *) buffer;
1237 }
btstack_memory_gatt_client_free(gatt_client_t * gatt_client)1238 void btstack_memory_gatt_client_free(gatt_client_t *gatt_client){
1239 btstack_memory_pool_free(&gatt_client_pool, gatt_client);
1240 }
1241 #else
btstack_memory_gatt_client_get(void)1242 gatt_client_t * btstack_memory_gatt_client_get(void){
1243 return NULL;
1244 }
btstack_memory_gatt_client_free(gatt_client_t * gatt_client)1245 void btstack_memory_gatt_client_free(gatt_client_t *gatt_client){
1246 UNUSED(gatt_client);
1247 }
1248 #endif
1249 #elif defined(HAVE_MALLOC)
1250
1251 typedef struct {
1252 btstack_memory_buffer_t tracking;
1253 gatt_client_t data;
1254 } btstack_memory_gatt_client_t;
1255
btstack_memory_gatt_client_get(void)1256 gatt_client_t * btstack_memory_gatt_client_get(void){
1257 btstack_memory_gatt_client_t * buffer = (btstack_memory_gatt_client_t *) malloc(sizeof(btstack_memory_gatt_client_t));
1258 if (buffer){
1259 memset(buffer, 0, sizeof(btstack_memory_gatt_client_t));
1260 btstack_memory_tracking_add(&buffer->tracking);
1261 return &buffer->data;
1262 } else {
1263 return NULL;
1264 }
1265 }
btstack_memory_gatt_client_free(gatt_client_t * gatt_client)1266 void btstack_memory_gatt_client_free(gatt_client_t *gatt_client){
1267 // reconstruct buffer start
1268 btstack_memory_buffer_t * buffer = &((btstack_memory_buffer_t *) gatt_client)[-1];
1269 btstack_memory_tracking_remove(buffer);
1270 free(buffer);
1271 }
1272 #endif
1273
1274
1275 // MARK: hids_client_t
1276 #if !defined(HAVE_MALLOC) && !defined(MAX_NR_HIDS_CLIENTS)
1277 #if defined(MAX_NO_HIDS_CLIENTS)
1278 #error "Deprecated MAX_NO_HIDS_CLIENTS defined instead of MAX_NR_HIDS_CLIENTS. Please update your btstack_config.h to use MAX_NR_HIDS_CLIENTS."
1279 #else
1280 #define MAX_NR_HIDS_CLIENTS 0
1281 #endif
1282 #endif
1283
1284 #ifdef MAX_NR_HIDS_CLIENTS
1285 #if MAX_NR_HIDS_CLIENTS > 0
1286 static hids_client_t hids_client_storage[MAX_NR_HIDS_CLIENTS];
1287 static btstack_memory_pool_t hids_client_pool;
btstack_memory_hids_client_get(void)1288 hids_client_t * btstack_memory_hids_client_get(void){
1289 void * buffer = btstack_memory_pool_get(&hids_client_pool);
1290 if (buffer){
1291 memset(buffer, 0, sizeof(hids_client_t));
1292 }
1293 return (hids_client_t *) buffer;
1294 }
btstack_memory_hids_client_free(hids_client_t * hids_client)1295 void btstack_memory_hids_client_free(hids_client_t *hids_client){
1296 btstack_memory_pool_free(&hids_client_pool, hids_client);
1297 }
1298 #else
btstack_memory_hids_client_get(void)1299 hids_client_t * btstack_memory_hids_client_get(void){
1300 return NULL;
1301 }
btstack_memory_hids_client_free(hids_client_t * hids_client)1302 void btstack_memory_hids_client_free(hids_client_t *hids_client){
1303 UNUSED(hids_client);
1304 }
1305 #endif
1306 #elif defined(HAVE_MALLOC)
1307
1308 typedef struct {
1309 btstack_memory_buffer_t tracking;
1310 hids_client_t data;
1311 } btstack_memory_hids_client_t;
1312
btstack_memory_hids_client_get(void)1313 hids_client_t * btstack_memory_hids_client_get(void){
1314 btstack_memory_hids_client_t * buffer = (btstack_memory_hids_client_t *) malloc(sizeof(btstack_memory_hids_client_t));
1315 if (buffer){
1316 memset(buffer, 0, sizeof(btstack_memory_hids_client_t));
1317 btstack_memory_tracking_add(&buffer->tracking);
1318 return &buffer->data;
1319 } else {
1320 return NULL;
1321 }
1322 }
btstack_memory_hids_client_free(hids_client_t * hids_client)1323 void btstack_memory_hids_client_free(hids_client_t *hids_client){
1324 // reconstruct buffer start
1325 btstack_memory_buffer_t * buffer = &((btstack_memory_buffer_t *) hids_client)[-1];
1326 btstack_memory_tracking_remove(buffer);
1327 free(buffer);
1328 }
1329 #endif
1330
1331
1332 // MARK: scan_parameters_service_client_t
1333 #if !defined(HAVE_MALLOC) && !defined(MAX_NR_SCAN_PARAMETERS_SERVICE_CLIENTS)
1334 #if defined(MAX_NO_SCAN_PARAMETERS_SERVICE_CLIENTS)
1335 #error "Deprecated MAX_NO_SCAN_PARAMETERS_SERVICE_CLIENTS defined instead of MAX_NR_SCAN_PARAMETERS_SERVICE_CLIENTS. Please update your btstack_config.h to use MAX_NR_SCAN_PARAMETERS_SERVICE_CLIENTS."
1336 #else
1337 #define MAX_NR_SCAN_PARAMETERS_SERVICE_CLIENTS 0
1338 #endif
1339 #endif
1340
1341 #ifdef MAX_NR_SCAN_PARAMETERS_SERVICE_CLIENTS
1342 #if MAX_NR_SCAN_PARAMETERS_SERVICE_CLIENTS > 0
1343 static scan_parameters_service_client_t scan_parameters_service_client_storage[MAX_NR_SCAN_PARAMETERS_SERVICE_CLIENTS];
1344 static btstack_memory_pool_t scan_parameters_service_client_pool;
btstack_memory_scan_parameters_service_client_get(void)1345 scan_parameters_service_client_t * btstack_memory_scan_parameters_service_client_get(void){
1346 void * buffer = btstack_memory_pool_get(&scan_parameters_service_client_pool);
1347 if (buffer){
1348 memset(buffer, 0, sizeof(scan_parameters_service_client_t));
1349 }
1350 return (scan_parameters_service_client_t *) buffer;
1351 }
btstack_memory_scan_parameters_service_client_free(scan_parameters_service_client_t * scan_parameters_service_client)1352 void btstack_memory_scan_parameters_service_client_free(scan_parameters_service_client_t *scan_parameters_service_client){
1353 btstack_memory_pool_free(&scan_parameters_service_client_pool, scan_parameters_service_client);
1354 }
1355 #else
btstack_memory_scan_parameters_service_client_get(void)1356 scan_parameters_service_client_t * btstack_memory_scan_parameters_service_client_get(void){
1357 return NULL;
1358 }
btstack_memory_scan_parameters_service_client_free(scan_parameters_service_client_t * scan_parameters_service_client)1359 void btstack_memory_scan_parameters_service_client_free(scan_parameters_service_client_t *scan_parameters_service_client){
1360 UNUSED(scan_parameters_service_client);
1361 }
1362 #endif
1363 #elif defined(HAVE_MALLOC)
1364
1365 typedef struct {
1366 btstack_memory_buffer_t tracking;
1367 scan_parameters_service_client_t data;
1368 } btstack_memory_scan_parameters_service_client_t;
1369
btstack_memory_scan_parameters_service_client_get(void)1370 scan_parameters_service_client_t * btstack_memory_scan_parameters_service_client_get(void){
1371 btstack_memory_scan_parameters_service_client_t * buffer = (btstack_memory_scan_parameters_service_client_t *) malloc(sizeof(btstack_memory_scan_parameters_service_client_t));
1372 if (buffer){
1373 memset(buffer, 0, sizeof(btstack_memory_scan_parameters_service_client_t));
1374 btstack_memory_tracking_add(&buffer->tracking);
1375 return &buffer->data;
1376 } else {
1377 return NULL;
1378 }
1379 }
btstack_memory_scan_parameters_service_client_free(scan_parameters_service_client_t * scan_parameters_service_client)1380 void btstack_memory_scan_parameters_service_client_free(scan_parameters_service_client_t *scan_parameters_service_client){
1381 // reconstruct buffer start
1382 btstack_memory_buffer_t * buffer = &((btstack_memory_buffer_t *) scan_parameters_service_client)[-1];
1383 btstack_memory_tracking_remove(buffer);
1384 free(buffer);
1385 }
1386 #endif
1387
1388
1389 // MARK: sm_lookup_entry_t
1390 #if !defined(HAVE_MALLOC) && !defined(MAX_NR_SM_LOOKUP_ENTRIES)
1391 #if defined(MAX_NO_SM_LOOKUP_ENTRIES)
1392 #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."
1393 #else
1394 #define MAX_NR_SM_LOOKUP_ENTRIES 0
1395 #endif
1396 #endif
1397
1398 #ifdef MAX_NR_SM_LOOKUP_ENTRIES
1399 #if MAX_NR_SM_LOOKUP_ENTRIES > 0
1400 static sm_lookup_entry_t sm_lookup_entry_storage[MAX_NR_SM_LOOKUP_ENTRIES];
1401 static btstack_memory_pool_t sm_lookup_entry_pool;
btstack_memory_sm_lookup_entry_get(void)1402 sm_lookup_entry_t * btstack_memory_sm_lookup_entry_get(void){
1403 void * buffer = btstack_memory_pool_get(&sm_lookup_entry_pool);
1404 if (buffer){
1405 memset(buffer, 0, sizeof(sm_lookup_entry_t));
1406 }
1407 return (sm_lookup_entry_t *) buffer;
1408 }
btstack_memory_sm_lookup_entry_free(sm_lookup_entry_t * sm_lookup_entry)1409 void btstack_memory_sm_lookup_entry_free(sm_lookup_entry_t *sm_lookup_entry){
1410 btstack_memory_pool_free(&sm_lookup_entry_pool, sm_lookup_entry);
1411 }
1412 #else
btstack_memory_sm_lookup_entry_get(void)1413 sm_lookup_entry_t * btstack_memory_sm_lookup_entry_get(void){
1414 return NULL;
1415 }
btstack_memory_sm_lookup_entry_free(sm_lookup_entry_t * sm_lookup_entry)1416 void btstack_memory_sm_lookup_entry_free(sm_lookup_entry_t *sm_lookup_entry){
1417 UNUSED(sm_lookup_entry);
1418 }
1419 #endif
1420 #elif defined(HAVE_MALLOC)
1421
1422 typedef struct {
1423 btstack_memory_buffer_t tracking;
1424 sm_lookup_entry_t data;
1425 } btstack_memory_sm_lookup_entry_t;
1426
btstack_memory_sm_lookup_entry_get(void)1427 sm_lookup_entry_t * btstack_memory_sm_lookup_entry_get(void){
1428 btstack_memory_sm_lookup_entry_t * buffer = (btstack_memory_sm_lookup_entry_t *) malloc(sizeof(btstack_memory_sm_lookup_entry_t));
1429 if (buffer){
1430 memset(buffer, 0, sizeof(btstack_memory_sm_lookup_entry_t));
1431 btstack_memory_tracking_add(&buffer->tracking);
1432 return &buffer->data;
1433 } else {
1434 return NULL;
1435 }
1436 }
btstack_memory_sm_lookup_entry_free(sm_lookup_entry_t * sm_lookup_entry)1437 void btstack_memory_sm_lookup_entry_free(sm_lookup_entry_t *sm_lookup_entry){
1438 // reconstruct buffer start
1439 btstack_memory_buffer_t * buffer = &((btstack_memory_buffer_t *) sm_lookup_entry)[-1];
1440 btstack_memory_tracking_remove(buffer);
1441 free(buffer);
1442 }
1443 #endif
1444
1445
1446 // MARK: whitelist_entry_t
1447 #if !defined(HAVE_MALLOC) && !defined(MAX_NR_WHITELIST_ENTRIES)
1448 #if defined(MAX_NO_WHITELIST_ENTRIES)
1449 #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."
1450 #else
1451 #define MAX_NR_WHITELIST_ENTRIES 0
1452 #endif
1453 #endif
1454
1455 #ifdef MAX_NR_WHITELIST_ENTRIES
1456 #if MAX_NR_WHITELIST_ENTRIES > 0
1457 static whitelist_entry_t whitelist_entry_storage[MAX_NR_WHITELIST_ENTRIES];
1458 static btstack_memory_pool_t whitelist_entry_pool;
btstack_memory_whitelist_entry_get(void)1459 whitelist_entry_t * btstack_memory_whitelist_entry_get(void){
1460 void * buffer = btstack_memory_pool_get(&whitelist_entry_pool);
1461 if (buffer){
1462 memset(buffer, 0, sizeof(whitelist_entry_t));
1463 }
1464 return (whitelist_entry_t *) buffer;
1465 }
btstack_memory_whitelist_entry_free(whitelist_entry_t * whitelist_entry)1466 void btstack_memory_whitelist_entry_free(whitelist_entry_t *whitelist_entry){
1467 btstack_memory_pool_free(&whitelist_entry_pool, whitelist_entry);
1468 }
1469 #else
btstack_memory_whitelist_entry_get(void)1470 whitelist_entry_t * btstack_memory_whitelist_entry_get(void){
1471 return NULL;
1472 }
btstack_memory_whitelist_entry_free(whitelist_entry_t * whitelist_entry)1473 void btstack_memory_whitelist_entry_free(whitelist_entry_t *whitelist_entry){
1474 UNUSED(whitelist_entry);
1475 }
1476 #endif
1477 #elif defined(HAVE_MALLOC)
1478
1479 typedef struct {
1480 btstack_memory_buffer_t tracking;
1481 whitelist_entry_t data;
1482 } btstack_memory_whitelist_entry_t;
1483
btstack_memory_whitelist_entry_get(void)1484 whitelist_entry_t * btstack_memory_whitelist_entry_get(void){
1485 btstack_memory_whitelist_entry_t * buffer = (btstack_memory_whitelist_entry_t *) malloc(sizeof(btstack_memory_whitelist_entry_t));
1486 if (buffer){
1487 memset(buffer, 0, sizeof(btstack_memory_whitelist_entry_t));
1488 btstack_memory_tracking_add(&buffer->tracking);
1489 return &buffer->data;
1490 } else {
1491 return NULL;
1492 }
1493 }
btstack_memory_whitelist_entry_free(whitelist_entry_t * whitelist_entry)1494 void btstack_memory_whitelist_entry_free(whitelist_entry_t *whitelist_entry){
1495 // reconstruct buffer start
1496 btstack_memory_buffer_t * buffer = &((btstack_memory_buffer_t *) whitelist_entry)[-1];
1497 btstack_memory_tracking_remove(buffer);
1498 free(buffer);
1499 }
1500 #endif
1501
1502
1503 // MARK: periodic_advertiser_list_entry_t
1504 #if !defined(HAVE_MALLOC) && !defined(MAX_NR_PERIODIC_ADVERTISER_LIST_ENTRIES)
1505 #if defined(MAX_NO_PERIODIC_ADVERTISER_LIST_ENTRIES)
1506 #error "Deprecated MAX_NO_PERIODIC_ADVERTISER_LIST_ENTRIES defined instead of MAX_NR_PERIODIC_ADVERTISER_LIST_ENTRIES. Please update your btstack_config.h to use MAX_NR_PERIODIC_ADVERTISER_LIST_ENTRIES."
1507 #else
1508 #define MAX_NR_PERIODIC_ADVERTISER_LIST_ENTRIES 0
1509 #endif
1510 #endif
1511
1512 #ifdef MAX_NR_PERIODIC_ADVERTISER_LIST_ENTRIES
1513 #if MAX_NR_PERIODIC_ADVERTISER_LIST_ENTRIES > 0
1514 static periodic_advertiser_list_entry_t periodic_advertiser_list_entry_storage[MAX_NR_PERIODIC_ADVERTISER_LIST_ENTRIES];
1515 static btstack_memory_pool_t periodic_advertiser_list_entry_pool;
btstack_memory_periodic_advertiser_list_entry_get(void)1516 periodic_advertiser_list_entry_t * btstack_memory_periodic_advertiser_list_entry_get(void){
1517 void * buffer = btstack_memory_pool_get(&periodic_advertiser_list_entry_pool);
1518 if (buffer){
1519 memset(buffer, 0, sizeof(periodic_advertiser_list_entry_t));
1520 }
1521 return (periodic_advertiser_list_entry_t *) buffer;
1522 }
btstack_memory_periodic_advertiser_list_entry_free(periodic_advertiser_list_entry_t * periodic_advertiser_list_entry)1523 void btstack_memory_periodic_advertiser_list_entry_free(periodic_advertiser_list_entry_t *periodic_advertiser_list_entry){
1524 btstack_memory_pool_free(&periodic_advertiser_list_entry_pool, periodic_advertiser_list_entry);
1525 }
1526 #else
btstack_memory_periodic_advertiser_list_entry_get(void)1527 periodic_advertiser_list_entry_t * btstack_memory_periodic_advertiser_list_entry_get(void){
1528 return NULL;
1529 }
btstack_memory_periodic_advertiser_list_entry_free(periodic_advertiser_list_entry_t * periodic_advertiser_list_entry)1530 void btstack_memory_periodic_advertiser_list_entry_free(periodic_advertiser_list_entry_t *periodic_advertiser_list_entry){
1531 UNUSED(periodic_advertiser_list_entry);
1532 }
1533 #endif
1534 #elif defined(HAVE_MALLOC)
1535
1536 typedef struct {
1537 btstack_memory_buffer_t tracking;
1538 periodic_advertiser_list_entry_t data;
1539 } btstack_memory_periodic_advertiser_list_entry_t;
1540
btstack_memory_periodic_advertiser_list_entry_get(void)1541 periodic_advertiser_list_entry_t * btstack_memory_periodic_advertiser_list_entry_get(void){
1542 btstack_memory_periodic_advertiser_list_entry_t * buffer = (btstack_memory_periodic_advertiser_list_entry_t *) malloc(sizeof(btstack_memory_periodic_advertiser_list_entry_t));
1543 if (buffer){
1544 memset(buffer, 0, sizeof(btstack_memory_periodic_advertiser_list_entry_t));
1545 btstack_memory_tracking_add(&buffer->tracking);
1546 return &buffer->data;
1547 } else {
1548 return NULL;
1549 }
1550 }
btstack_memory_periodic_advertiser_list_entry_free(periodic_advertiser_list_entry_t * periodic_advertiser_list_entry)1551 void btstack_memory_periodic_advertiser_list_entry_free(periodic_advertiser_list_entry_t *periodic_advertiser_list_entry){
1552 // reconstruct buffer start
1553 btstack_memory_buffer_t * buffer = &((btstack_memory_buffer_t *) periodic_advertiser_list_entry)[-1];
1554 btstack_memory_tracking_remove(buffer);
1555 free(buffer);
1556 }
1557 #endif
1558
1559
1560 #endif
1561 #ifdef ENABLE_MESH
1562
1563 // MARK: mesh_network_pdu_t
1564 #if !defined(HAVE_MALLOC) && !defined(MAX_NR_MESH_NETWORK_PDUS)
1565 #if defined(MAX_NO_MESH_NETWORK_PDUS)
1566 #error "Deprecated MAX_NO_MESH_NETWORK_PDUS defined instead of MAX_NR_MESH_NETWORK_PDUS. Please update your btstack_config.h to use MAX_NR_MESH_NETWORK_PDUS."
1567 #else
1568 #define MAX_NR_MESH_NETWORK_PDUS 0
1569 #endif
1570 #endif
1571
1572 #ifdef MAX_NR_MESH_NETWORK_PDUS
1573 #if MAX_NR_MESH_NETWORK_PDUS > 0
1574 static mesh_network_pdu_t mesh_network_pdu_storage[MAX_NR_MESH_NETWORK_PDUS];
1575 static btstack_memory_pool_t mesh_network_pdu_pool;
btstack_memory_mesh_network_pdu_get(void)1576 mesh_network_pdu_t * btstack_memory_mesh_network_pdu_get(void){
1577 void * buffer = btstack_memory_pool_get(&mesh_network_pdu_pool);
1578 if (buffer){
1579 memset(buffer, 0, sizeof(mesh_network_pdu_t));
1580 }
1581 return (mesh_network_pdu_t *) buffer;
1582 }
btstack_memory_mesh_network_pdu_free(mesh_network_pdu_t * mesh_network_pdu)1583 void btstack_memory_mesh_network_pdu_free(mesh_network_pdu_t *mesh_network_pdu){
1584 btstack_memory_pool_free(&mesh_network_pdu_pool, mesh_network_pdu);
1585 }
1586 #else
btstack_memory_mesh_network_pdu_get(void)1587 mesh_network_pdu_t * btstack_memory_mesh_network_pdu_get(void){
1588 return NULL;
1589 }
btstack_memory_mesh_network_pdu_free(mesh_network_pdu_t * mesh_network_pdu)1590 void btstack_memory_mesh_network_pdu_free(mesh_network_pdu_t *mesh_network_pdu){
1591 UNUSED(mesh_network_pdu);
1592 }
1593 #endif
1594 #elif defined(HAVE_MALLOC)
1595
1596 typedef struct {
1597 btstack_memory_buffer_t tracking;
1598 mesh_network_pdu_t data;
1599 } btstack_memory_mesh_network_pdu_t;
1600
btstack_memory_mesh_network_pdu_get(void)1601 mesh_network_pdu_t * btstack_memory_mesh_network_pdu_get(void){
1602 btstack_memory_mesh_network_pdu_t * buffer = (btstack_memory_mesh_network_pdu_t *) malloc(sizeof(btstack_memory_mesh_network_pdu_t));
1603 if (buffer){
1604 memset(buffer, 0, sizeof(btstack_memory_mesh_network_pdu_t));
1605 btstack_memory_tracking_add(&buffer->tracking);
1606 return &buffer->data;
1607 } else {
1608 return NULL;
1609 }
1610 }
btstack_memory_mesh_network_pdu_free(mesh_network_pdu_t * mesh_network_pdu)1611 void btstack_memory_mesh_network_pdu_free(mesh_network_pdu_t *mesh_network_pdu){
1612 // reconstruct buffer start
1613 btstack_memory_buffer_t * buffer = &((btstack_memory_buffer_t *) mesh_network_pdu)[-1];
1614 btstack_memory_tracking_remove(buffer);
1615 free(buffer);
1616 }
1617 #endif
1618
1619
1620 // MARK: mesh_segmented_pdu_t
1621 #if !defined(HAVE_MALLOC) && !defined(MAX_NR_MESH_SEGMENTED_PDUS)
1622 #if defined(MAX_NO_MESH_SEGMENTED_PDUS)
1623 #error "Deprecated MAX_NO_MESH_SEGMENTED_PDUS defined instead of MAX_NR_MESH_SEGMENTED_PDUS. Please update your btstack_config.h to use MAX_NR_MESH_SEGMENTED_PDUS."
1624 #else
1625 #define MAX_NR_MESH_SEGMENTED_PDUS 0
1626 #endif
1627 #endif
1628
1629 #ifdef MAX_NR_MESH_SEGMENTED_PDUS
1630 #if MAX_NR_MESH_SEGMENTED_PDUS > 0
1631 static mesh_segmented_pdu_t mesh_segmented_pdu_storage[MAX_NR_MESH_SEGMENTED_PDUS];
1632 static btstack_memory_pool_t mesh_segmented_pdu_pool;
btstack_memory_mesh_segmented_pdu_get(void)1633 mesh_segmented_pdu_t * btstack_memory_mesh_segmented_pdu_get(void){
1634 void * buffer = btstack_memory_pool_get(&mesh_segmented_pdu_pool);
1635 if (buffer){
1636 memset(buffer, 0, sizeof(mesh_segmented_pdu_t));
1637 }
1638 return (mesh_segmented_pdu_t *) buffer;
1639 }
btstack_memory_mesh_segmented_pdu_free(mesh_segmented_pdu_t * mesh_segmented_pdu)1640 void btstack_memory_mesh_segmented_pdu_free(mesh_segmented_pdu_t *mesh_segmented_pdu){
1641 btstack_memory_pool_free(&mesh_segmented_pdu_pool, mesh_segmented_pdu);
1642 }
1643 #else
btstack_memory_mesh_segmented_pdu_get(void)1644 mesh_segmented_pdu_t * btstack_memory_mesh_segmented_pdu_get(void){
1645 return NULL;
1646 }
btstack_memory_mesh_segmented_pdu_free(mesh_segmented_pdu_t * mesh_segmented_pdu)1647 void btstack_memory_mesh_segmented_pdu_free(mesh_segmented_pdu_t *mesh_segmented_pdu){
1648 UNUSED(mesh_segmented_pdu);
1649 }
1650 #endif
1651 #elif defined(HAVE_MALLOC)
1652
1653 typedef struct {
1654 btstack_memory_buffer_t tracking;
1655 mesh_segmented_pdu_t data;
1656 } btstack_memory_mesh_segmented_pdu_t;
1657
btstack_memory_mesh_segmented_pdu_get(void)1658 mesh_segmented_pdu_t * btstack_memory_mesh_segmented_pdu_get(void){
1659 btstack_memory_mesh_segmented_pdu_t * buffer = (btstack_memory_mesh_segmented_pdu_t *) malloc(sizeof(btstack_memory_mesh_segmented_pdu_t));
1660 if (buffer){
1661 memset(buffer, 0, sizeof(btstack_memory_mesh_segmented_pdu_t));
1662 btstack_memory_tracking_add(&buffer->tracking);
1663 return &buffer->data;
1664 } else {
1665 return NULL;
1666 }
1667 }
btstack_memory_mesh_segmented_pdu_free(mesh_segmented_pdu_t * mesh_segmented_pdu)1668 void btstack_memory_mesh_segmented_pdu_free(mesh_segmented_pdu_t *mesh_segmented_pdu){
1669 // reconstruct buffer start
1670 btstack_memory_buffer_t * buffer = &((btstack_memory_buffer_t *) mesh_segmented_pdu)[-1];
1671 btstack_memory_tracking_remove(buffer);
1672 free(buffer);
1673 }
1674 #endif
1675
1676
1677 // MARK: mesh_upper_transport_pdu_t
1678 #if !defined(HAVE_MALLOC) && !defined(MAX_NR_MESH_UPPER_TRANSPORT_PDUS)
1679 #if defined(MAX_NO_MESH_UPPER_TRANSPORT_PDUS)
1680 #error "Deprecated MAX_NO_MESH_UPPER_TRANSPORT_PDUS defined instead of MAX_NR_MESH_UPPER_TRANSPORT_PDUS. Please update your btstack_config.h to use MAX_NR_MESH_UPPER_TRANSPORT_PDUS."
1681 #else
1682 #define MAX_NR_MESH_UPPER_TRANSPORT_PDUS 0
1683 #endif
1684 #endif
1685
1686 #ifdef MAX_NR_MESH_UPPER_TRANSPORT_PDUS
1687 #if MAX_NR_MESH_UPPER_TRANSPORT_PDUS > 0
1688 static mesh_upper_transport_pdu_t mesh_upper_transport_pdu_storage[MAX_NR_MESH_UPPER_TRANSPORT_PDUS];
1689 static btstack_memory_pool_t mesh_upper_transport_pdu_pool;
btstack_memory_mesh_upper_transport_pdu_get(void)1690 mesh_upper_transport_pdu_t * btstack_memory_mesh_upper_transport_pdu_get(void){
1691 void * buffer = btstack_memory_pool_get(&mesh_upper_transport_pdu_pool);
1692 if (buffer){
1693 memset(buffer, 0, sizeof(mesh_upper_transport_pdu_t));
1694 }
1695 return (mesh_upper_transport_pdu_t *) buffer;
1696 }
btstack_memory_mesh_upper_transport_pdu_free(mesh_upper_transport_pdu_t * mesh_upper_transport_pdu)1697 void btstack_memory_mesh_upper_transport_pdu_free(mesh_upper_transport_pdu_t *mesh_upper_transport_pdu){
1698 btstack_memory_pool_free(&mesh_upper_transport_pdu_pool, mesh_upper_transport_pdu);
1699 }
1700 #else
btstack_memory_mesh_upper_transport_pdu_get(void)1701 mesh_upper_transport_pdu_t * btstack_memory_mesh_upper_transport_pdu_get(void){
1702 return NULL;
1703 }
btstack_memory_mesh_upper_transport_pdu_free(mesh_upper_transport_pdu_t * mesh_upper_transport_pdu)1704 void btstack_memory_mesh_upper_transport_pdu_free(mesh_upper_transport_pdu_t *mesh_upper_transport_pdu){
1705 UNUSED(mesh_upper_transport_pdu);
1706 }
1707 #endif
1708 #elif defined(HAVE_MALLOC)
1709
1710 typedef struct {
1711 btstack_memory_buffer_t tracking;
1712 mesh_upper_transport_pdu_t data;
1713 } btstack_memory_mesh_upper_transport_pdu_t;
1714
btstack_memory_mesh_upper_transport_pdu_get(void)1715 mesh_upper_transport_pdu_t * btstack_memory_mesh_upper_transport_pdu_get(void){
1716 btstack_memory_mesh_upper_transport_pdu_t * buffer = (btstack_memory_mesh_upper_transport_pdu_t *) malloc(sizeof(btstack_memory_mesh_upper_transport_pdu_t));
1717 if (buffer){
1718 memset(buffer, 0, sizeof(btstack_memory_mesh_upper_transport_pdu_t));
1719 btstack_memory_tracking_add(&buffer->tracking);
1720 return &buffer->data;
1721 } else {
1722 return NULL;
1723 }
1724 }
btstack_memory_mesh_upper_transport_pdu_free(mesh_upper_transport_pdu_t * mesh_upper_transport_pdu)1725 void btstack_memory_mesh_upper_transport_pdu_free(mesh_upper_transport_pdu_t *mesh_upper_transport_pdu){
1726 // reconstruct buffer start
1727 btstack_memory_buffer_t * buffer = &((btstack_memory_buffer_t *) mesh_upper_transport_pdu)[-1];
1728 btstack_memory_tracking_remove(buffer);
1729 free(buffer);
1730 }
1731 #endif
1732
1733
1734 // MARK: mesh_network_key_t
1735 #if !defined(HAVE_MALLOC) && !defined(MAX_NR_MESH_NETWORK_KEYS)
1736 #if defined(MAX_NO_MESH_NETWORK_KEYS)
1737 #error "Deprecated MAX_NO_MESH_NETWORK_KEYS defined instead of MAX_NR_MESH_NETWORK_KEYS. Please update your btstack_config.h to use MAX_NR_MESH_NETWORK_KEYS."
1738 #else
1739 #define MAX_NR_MESH_NETWORK_KEYS 0
1740 #endif
1741 #endif
1742
1743 #ifdef MAX_NR_MESH_NETWORK_KEYS
1744 #if MAX_NR_MESH_NETWORK_KEYS > 0
1745 static mesh_network_key_t mesh_network_key_storage[MAX_NR_MESH_NETWORK_KEYS];
1746 static btstack_memory_pool_t mesh_network_key_pool;
btstack_memory_mesh_network_key_get(void)1747 mesh_network_key_t * btstack_memory_mesh_network_key_get(void){
1748 void * buffer = btstack_memory_pool_get(&mesh_network_key_pool);
1749 if (buffer){
1750 memset(buffer, 0, sizeof(mesh_network_key_t));
1751 }
1752 return (mesh_network_key_t *) buffer;
1753 }
btstack_memory_mesh_network_key_free(mesh_network_key_t * mesh_network_key)1754 void btstack_memory_mesh_network_key_free(mesh_network_key_t *mesh_network_key){
1755 btstack_memory_pool_free(&mesh_network_key_pool, mesh_network_key);
1756 }
1757 #else
btstack_memory_mesh_network_key_get(void)1758 mesh_network_key_t * btstack_memory_mesh_network_key_get(void){
1759 return NULL;
1760 }
btstack_memory_mesh_network_key_free(mesh_network_key_t * mesh_network_key)1761 void btstack_memory_mesh_network_key_free(mesh_network_key_t *mesh_network_key){
1762 UNUSED(mesh_network_key);
1763 }
1764 #endif
1765 #elif defined(HAVE_MALLOC)
1766
1767 typedef struct {
1768 btstack_memory_buffer_t tracking;
1769 mesh_network_key_t data;
1770 } btstack_memory_mesh_network_key_t;
1771
btstack_memory_mesh_network_key_get(void)1772 mesh_network_key_t * btstack_memory_mesh_network_key_get(void){
1773 btstack_memory_mesh_network_key_t * buffer = (btstack_memory_mesh_network_key_t *) malloc(sizeof(btstack_memory_mesh_network_key_t));
1774 if (buffer){
1775 memset(buffer, 0, sizeof(btstack_memory_mesh_network_key_t));
1776 btstack_memory_tracking_add(&buffer->tracking);
1777 return &buffer->data;
1778 } else {
1779 return NULL;
1780 }
1781 }
btstack_memory_mesh_network_key_free(mesh_network_key_t * mesh_network_key)1782 void btstack_memory_mesh_network_key_free(mesh_network_key_t *mesh_network_key){
1783 // reconstruct buffer start
1784 btstack_memory_buffer_t * buffer = &((btstack_memory_buffer_t *) mesh_network_key)[-1];
1785 btstack_memory_tracking_remove(buffer);
1786 free(buffer);
1787 }
1788 #endif
1789
1790
1791 // MARK: mesh_transport_key_t
1792 #if !defined(HAVE_MALLOC) && !defined(MAX_NR_MESH_TRANSPORT_KEYS)
1793 #if defined(MAX_NO_MESH_TRANSPORT_KEYS)
1794 #error "Deprecated MAX_NO_MESH_TRANSPORT_KEYS defined instead of MAX_NR_MESH_TRANSPORT_KEYS. Please update your btstack_config.h to use MAX_NR_MESH_TRANSPORT_KEYS."
1795 #else
1796 #define MAX_NR_MESH_TRANSPORT_KEYS 0
1797 #endif
1798 #endif
1799
1800 #ifdef MAX_NR_MESH_TRANSPORT_KEYS
1801 #if MAX_NR_MESH_TRANSPORT_KEYS > 0
1802 static mesh_transport_key_t mesh_transport_key_storage[MAX_NR_MESH_TRANSPORT_KEYS];
1803 static btstack_memory_pool_t mesh_transport_key_pool;
btstack_memory_mesh_transport_key_get(void)1804 mesh_transport_key_t * btstack_memory_mesh_transport_key_get(void){
1805 void * buffer = btstack_memory_pool_get(&mesh_transport_key_pool);
1806 if (buffer){
1807 memset(buffer, 0, sizeof(mesh_transport_key_t));
1808 }
1809 return (mesh_transport_key_t *) buffer;
1810 }
btstack_memory_mesh_transport_key_free(mesh_transport_key_t * mesh_transport_key)1811 void btstack_memory_mesh_transport_key_free(mesh_transport_key_t *mesh_transport_key){
1812 btstack_memory_pool_free(&mesh_transport_key_pool, mesh_transport_key);
1813 }
1814 #else
btstack_memory_mesh_transport_key_get(void)1815 mesh_transport_key_t * btstack_memory_mesh_transport_key_get(void){
1816 return NULL;
1817 }
btstack_memory_mesh_transport_key_free(mesh_transport_key_t * mesh_transport_key)1818 void btstack_memory_mesh_transport_key_free(mesh_transport_key_t *mesh_transport_key){
1819 UNUSED(mesh_transport_key);
1820 }
1821 #endif
1822 #elif defined(HAVE_MALLOC)
1823
1824 typedef struct {
1825 btstack_memory_buffer_t tracking;
1826 mesh_transport_key_t data;
1827 } btstack_memory_mesh_transport_key_t;
1828
btstack_memory_mesh_transport_key_get(void)1829 mesh_transport_key_t * btstack_memory_mesh_transport_key_get(void){
1830 btstack_memory_mesh_transport_key_t * buffer = (btstack_memory_mesh_transport_key_t *) malloc(sizeof(btstack_memory_mesh_transport_key_t));
1831 if (buffer){
1832 memset(buffer, 0, sizeof(btstack_memory_mesh_transport_key_t));
1833 btstack_memory_tracking_add(&buffer->tracking);
1834 return &buffer->data;
1835 } else {
1836 return NULL;
1837 }
1838 }
btstack_memory_mesh_transport_key_free(mesh_transport_key_t * mesh_transport_key)1839 void btstack_memory_mesh_transport_key_free(mesh_transport_key_t *mesh_transport_key){
1840 // reconstruct buffer start
1841 btstack_memory_buffer_t * buffer = &((btstack_memory_buffer_t *) mesh_transport_key)[-1];
1842 btstack_memory_tracking_remove(buffer);
1843 free(buffer);
1844 }
1845 #endif
1846
1847
1848 // MARK: mesh_virtual_address_t
1849 #if !defined(HAVE_MALLOC) && !defined(MAX_NR_MESH_VIRTUAL_ADDRESSS)
1850 #if defined(MAX_NO_MESH_VIRTUAL_ADDRESSS)
1851 #error "Deprecated MAX_NO_MESH_VIRTUAL_ADDRESSS defined instead of MAX_NR_MESH_VIRTUAL_ADDRESSS. Please update your btstack_config.h to use MAX_NR_MESH_VIRTUAL_ADDRESSS."
1852 #else
1853 #define MAX_NR_MESH_VIRTUAL_ADDRESSS 0
1854 #endif
1855 #endif
1856
1857 #ifdef MAX_NR_MESH_VIRTUAL_ADDRESSS
1858 #if MAX_NR_MESH_VIRTUAL_ADDRESSS > 0
1859 static mesh_virtual_address_t mesh_virtual_address_storage[MAX_NR_MESH_VIRTUAL_ADDRESSS];
1860 static btstack_memory_pool_t mesh_virtual_address_pool;
btstack_memory_mesh_virtual_address_get(void)1861 mesh_virtual_address_t * btstack_memory_mesh_virtual_address_get(void){
1862 void * buffer = btstack_memory_pool_get(&mesh_virtual_address_pool);
1863 if (buffer){
1864 memset(buffer, 0, sizeof(mesh_virtual_address_t));
1865 }
1866 return (mesh_virtual_address_t *) buffer;
1867 }
btstack_memory_mesh_virtual_address_free(mesh_virtual_address_t * mesh_virtual_address)1868 void btstack_memory_mesh_virtual_address_free(mesh_virtual_address_t *mesh_virtual_address){
1869 btstack_memory_pool_free(&mesh_virtual_address_pool, mesh_virtual_address);
1870 }
1871 #else
btstack_memory_mesh_virtual_address_get(void)1872 mesh_virtual_address_t * btstack_memory_mesh_virtual_address_get(void){
1873 return NULL;
1874 }
btstack_memory_mesh_virtual_address_free(mesh_virtual_address_t * mesh_virtual_address)1875 void btstack_memory_mesh_virtual_address_free(mesh_virtual_address_t *mesh_virtual_address){
1876 UNUSED(mesh_virtual_address);
1877 }
1878 #endif
1879 #elif defined(HAVE_MALLOC)
1880
1881 typedef struct {
1882 btstack_memory_buffer_t tracking;
1883 mesh_virtual_address_t data;
1884 } btstack_memory_mesh_virtual_address_t;
1885
btstack_memory_mesh_virtual_address_get(void)1886 mesh_virtual_address_t * btstack_memory_mesh_virtual_address_get(void){
1887 btstack_memory_mesh_virtual_address_t * buffer = (btstack_memory_mesh_virtual_address_t *) malloc(sizeof(btstack_memory_mesh_virtual_address_t));
1888 if (buffer){
1889 memset(buffer, 0, sizeof(btstack_memory_mesh_virtual_address_t));
1890 btstack_memory_tracking_add(&buffer->tracking);
1891 return &buffer->data;
1892 } else {
1893 return NULL;
1894 }
1895 }
btstack_memory_mesh_virtual_address_free(mesh_virtual_address_t * mesh_virtual_address)1896 void btstack_memory_mesh_virtual_address_free(mesh_virtual_address_t *mesh_virtual_address){
1897 // reconstruct buffer start
1898 btstack_memory_buffer_t * buffer = &((btstack_memory_buffer_t *) mesh_virtual_address)[-1];
1899 btstack_memory_tracking_remove(buffer);
1900 free(buffer);
1901 }
1902 #endif
1903
1904
1905 // MARK: mesh_subnet_t
1906 #if !defined(HAVE_MALLOC) && !defined(MAX_NR_MESH_SUBNETS)
1907 #if defined(MAX_NO_MESH_SUBNETS)
1908 #error "Deprecated MAX_NO_MESH_SUBNETS defined instead of MAX_NR_MESH_SUBNETS. Please update your btstack_config.h to use MAX_NR_MESH_SUBNETS."
1909 #else
1910 #define MAX_NR_MESH_SUBNETS 0
1911 #endif
1912 #endif
1913
1914 #ifdef MAX_NR_MESH_SUBNETS
1915 #if MAX_NR_MESH_SUBNETS > 0
1916 static mesh_subnet_t mesh_subnet_storage[MAX_NR_MESH_SUBNETS];
1917 static btstack_memory_pool_t mesh_subnet_pool;
btstack_memory_mesh_subnet_get(void)1918 mesh_subnet_t * btstack_memory_mesh_subnet_get(void){
1919 void * buffer = btstack_memory_pool_get(&mesh_subnet_pool);
1920 if (buffer){
1921 memset(buffer, 0, sizeof(mesh_subnet_t));
1922 }
1923 return (mesh_subnet_t *) buffer;
1924 }
btstack_memory_mesh_subnet_free(mesh_subnet_t * mesh_subnet)1925 void btstack_memory_mesh_subnet_free(mesh_subnet_t *mesh_subnet){
1926 btstack_memory_pool_free(&mesh_subnet_pool, mesh_subnet);
1927 }
1928 #else
btstack_memory_mesh_subnet_get(void)1929 mesh_subnet_t * btstack_memory_mesh_subnet_get(void){
1930 return NULL;
1931 }
btstack_memory_mesh_subnet_free(mesh_subnet_t * mesh_subnet)1932 void btstack_memory_mesh_subnet_free(mesh_subnet_t *mesh_subnet){
1933 UNUSED(mesh_subnet);
1934 }
1935 #endif
1936 #elif defined(HAVE_MALLOC)
1937
1938 typedef struct {
1939 btstack_memory_buffer_t tracking;
1940 mesh_subnet_t data;
1941 } btstack_memory_mesh_subnet_t;
1942
btstack_memory_mesh_subnet_get(void)1943 mesh_subnet_t * btstack_memory_mesh_subnet_get(void){
1944 btstack_memory_mesh_subnet_t * buffer = (btstack_memory_mesh_subnet_t *) malloc(sizeof(btstack_memory_mesh_subnet_t));
1945 if (buffer){
1946 memset(buffer, 0, sizeof(btstack_memory_mesh_subnet_t));
1947 btstack_memory_tracking_add(&buffer->tracking);
1948 return &buffer->data;
1949 } else {
1950 return NULL;
1951 }
1952 }
btstack_memory_mesh_subnet_free(mesh_subnet_t * mesh_subnet)1953 void btstack_memory_mesh_subnet_free(mesh_subnet_t *mesh_subnet){
1954 // reconstruct buffer start
1955 btstack_memory_buffer_t * buffer = &((btstack_memory_buffer_t *) mesh_subnet)[-1];
1956 btstack_memory_tracking_remove(buffer);
1957 free(buffer);
1958 }
1959 #endif
1960
1961
1962 #endif
1963 #ifdef ENABLE_LE_ISOCHRONOUS_STREAMS
1964
1965 // MARK: hci_iso_stream_t
1966 #if !defined(HAVE_MALLOC) && !defined(MAX_NR_HCI_ISO_STREAMS)
1967 #if defined(MAX_NO_HCI_ISO_STREAMS)
1968 #error "Deprecated MAX_NO_HCI_ISO_STREAMS defined instead of MAX_NR_HCI_ISO_STREAMS. Please update your btstack_config.h to use MAX_NR_HCI_ISO_STREAMS."
1969 #else
1970 #define MAX_NR_HCI_ISO_STREAMS 0
1971 #endif
1972 #endif
1973
1974 #ifdef MAX_NR_HCI_ISO_STREAMS
1975 #if MAX_NR_HCI_ISO_STREAMS > 0
1976 static hci_iso_stream_t hci_iso_stream_storage[MAX_NR_HCI_ISO_STREAMS];
1977 static btstack_memory_pool_t hci_iso_stream_pool;
btstack_memory_hci_iso_stream_get(void)1978 hci_iso_stream_t * btstack_memory_hci_iso_stream_get(void){
1979 void * buffer = btstack_memory_pool_get(&hci_iso_stream_pool);
1980 if (buffer){
1981 memset(buffer, 0, sizeof(hci_iso_stream_t));
1982 }
1983 return (hci_iso_stream_t *) buffer;
1984 }
btstack_memory_hci_iso_stream_free(hci_iso_stream_t * hci_iso_stream)1985 void btstack_memory_hci_iso_stream_free(hci_iso_stream_t *hci_iso_stream){
1986 btstack_memory_pool_free(&hci_iso_stream_pool, hci_iso_stream);
1987 }
1988 #else
btstack_memory_hci_iso_stream_get(void)1989 hci_iso_stream_t * btstack_memory_hci_iso_stream_get(void){
1990 return NULL;
1991 }
btstack_memory_hci_iso_stream_free(hci_iso_stream_t * hci_iso_stream)1992 void btstack_memory_hci_iso_stream_free(hci_iso_stream_t *hci_iso_stream){
1993 UNUSED(hci_iso_stream);
1994 }
1995 #endif
1996 #elif defined(HAVE_MALLOC)
1997
1998 typedef struct {
1999 btstack_memory_buffer_t tracking;
2000 hci_iso_stream_t data;
2001 } btstack_memory_hci_iso_stream_t;
2002
btstack_memory_hci_iso_stream_get(void)2003 hci_iso_stream_t * btstack_memory_hci_iso_stream_get(void){
2004 btstack_memory_hci_iso_stream_t * buffer = (btstack_memory_hci_iso_stream_t *) malloc(sizeof(btstack_memory_hci_iso_stream_t));
2005 if (buffer){
2006 memset(buffer, 0, sizeof(btstack_memory_hci_iso_stream_t));
2007 btstack_memory_tracking_add(&buffer->tracking);
2008 return &buffer->data;
2009 } else {
2010 return NULL;
2011 }
2012 }
btstack_memory_hci_iso_stream_free(hci_iso_stream_t * hci_iso_stream)2013 void btstack_memory_hci_iso_stream_free(hci_iso_stream_t *hci_iso_stream){
2014 // reconstruct buffer start
2015 btstack_memory_buffer_t * buffer = &((btstack_memory_buffer_t *) hci_iso_stream)[-1];
2016 btstack_memory_tracking_remove(buffer);
2017 free(buffer);
2018 }
2019 #endif
2020
2021
2022 #endif
2023
2024 // init
btstack_memory_init(void)2025 void btstack_memory_init(void){
2026 #ifdef HAVE_MALLOC
2027 // assert that there is no unexpected padding for combined buffer
2028 btstack_assert(sizeof(test_buffer_t) == sizeof(btstack_memory_buffer_t) + sizeof(void *));
2029 #endif
2030
2031 #if MAX_NR_HCI_CONNECTIONS > 0
2032 btstack_memory_pool_create(&hci_connection_pool, hci_connection_storage, MAX_NR_HCI_CONNECTIONS, sizeof(hci_connection_t));
2033 #endif
2034
2035 #if MAX_NR_L2CAP_SERVICES > 0
2036 btstack_memory_pool_create(&l2cap_service_pool, l2cap_service_storage, MAX_NR_L2CAP_SERVICES, sizeof(l2cap_service_t));
2037 #endif
2038 #if MAX_NR_L2CAP_CHANNELS > 0
2039 btstack_memory_pool_create(&l2cap_channel_pool, l2cap_channel_storage, MAX_NR_L2CAP_CHANNELS, sizeof(l2cap_channel_t));
2040 #endif
2041
2042 #ifdef ENABLE_CLASSIC
2043 #if MAX_NR_RFCOMM_MULTIPLEXERS > 0
2044 btstack_memory_pool_create(&rfcomm_multiplexer_pool, rfcomm_multiplexer_storage, MAX_NR_RFCOMM_MULTIPLEXERS, sizeof(rfcomm_multiplexer_t));
2045 #endif
2046 #if MAX_NR_RFCOMM_SERVICES > 0
2047 btstack_memory_pool_create(&rfcomm_service_pool, rfcomm_service_storage, MAX_NR_RFCOMM_SERVICES, sizeof(rfcomm_service_t));
2048 #endif
2049 #if MAX_NR_RFCOMM_CHANNELS > 0
2050 btstack_memory_pool_create(&rfcomm_channel_pool, rfcomm_channel_storage, MAX_NR_RFCOMM_CHANNELS, sizeof(rfcomm_channel_t));
2051 #endif
2052
2053 #if MAX_NR_BTSTACK_LINK_KEY_DB_MEMORY_ENTRIES > 0
2054 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));
2055 #endif
2056
2057 #if MAX_NR_BNEP_SERVICES > 0
2058 btstack_memory_pool_create(&bnep_service_pool, bnep_service_storage, MAX_NR_BNEP_SERVICES, sizeof(bnep_service_t));
2059 #endif
2060 #if MAX_NR_BNEP_CHANNELS > 0
2061 btstack_memory_pool_create(&bnep_channel_pool, bnep_channel_storage, MAX_NR_BNEP_CHANNELS, sizeof(bnep_channel_t));
2062 #endif
2063
2064 #if MAX_NR_GOEP_SERVER_SERVICES > 0
2065 btstack_memory_pool_create(&goep_server_service_pool, goep_server_service_storage, MAX_NR_GOEP_SERVER_SERVICES, sizeof(goep_server_service_t));
2066 #endif
2067 #if MAX_NR_GOEP_SERVER_CONNECTIONS > 0
2068 btstack_memory_pool_create(&goep_server_connection_pool, goep_server_connection_storage, MAX_NR_GOEP_SERVER_CONNECTIONS, sizeof(goep_server_connection_t));
2069 #endif
2070
2071 #if MAX_NR_HFP_CONNECTIONS > 0
2072 btstack_memory_pool_create(&hfp_connection_pool, hfp_connection_storage, MAX_NR_HFP_CONNECTIONS, sizeof(hfp_connection_t));
2073 #endif
2074
2075 #if MAX_NR_HID_HOST_CONNECTIONS > 0
2076 btstack_memory_pool_create(&hid_host_connection_pool, hid_host_connection_storage, MAX_NR_HID_HOST_CONNECTIONS, sizeof(hid_host_connection_t));
2077 #endif
2078
2079 #if MAX_NR_SERVICE_RECORD_ITEMS > 0
2080 btstack_memory_pool_create(&service_record_item_pool, service_record_item_storage, MAX_NR_SERVICE_RECORD_ITEMS, sizeof(service_record_item_t));
2081 #endif
2082
2083 #if MAX_NR_AVDTP_STREAM_ENDPOINTS > 0
2084 btstack_memory_pool_create(&avdtp_stream_endpoint_pool, avdtp_stream_endpoint_storage, MAX_NR_AVDTP_STREAM_ENDPOINTS, sizeof(avdtp_stream_endpoint_t));
2085 #endif
2086
2087 #if MAX_NR_AVDTP_CONNECTIONS > 0
2088 btstack_memory_pool_create(&avdtp_connection_pool, avdtp_connection_storage, MAX_NR_AVDTP_CONNECTIONS, sizeof(avdtp_connection_t));
2089 #endif
2090
2091 #if MAX_NR_AVRCP_CONNECTIONS > 0
2092 btstack_memory_pool_create(&avrcp_connection_pool, avrcp_connection_storage, MAX_NR_AVRCP_CONNECTIONS, sizeof(avrcp_connection_t));
2093 #endif
2094
2095 #if MAX_NR_AVRCP_BROWSING_CONNECTIONS > 0
2096 btstack_memory_pool_create(&avrcp_browsing_connection_pool, avrcp_browsing_connection_storage, MAX_NR_AVRCP_BROWSING_CONNECTIONS, sizeof(avrcp_browsing_connection_t));
2097 #endif
2098
2099 #endif
2100 #ifdef ENABLE_BLE
2101 #if MAX_NR_BATTERY_SERVICE_CLIENTS > 0
2102 btstack_memory_pool_create(&battery_service_client_pool, battery_service_client_storage, MAX_NR_BATTERY_SERVICE_CLIENTS, sizeof(battery_service_client_t));
2103 #endif
2104 #if MAX_NR_GATT_CLIENTS > 0
2105 btstack_memory_pool_create(&gatt_client_pool, gatt_client_storage, MAX_NR_GATT_CLIENTS, sizeof(gatt_client_t));
2106 #endif
2107 #if MAX_NR_HIDS_CLIENTS > 0
2108 btstack_memory_pool_create(&hids_client_pool, hids_client_storage, MAX_NR_HIDS_CLIENTS, sizeof(hids_client_t));
2109 #endif
2110 #if MAX_NR_SCAN_PARAMETERS_SERVICE_CLIENTS > 0
2111 btstack_memory_pool_create(&scan_parameters_service_client_pool, scan_parameters_service_client_storage, MAX_NR_SCAN_PARAMETERS_SERVICE_CLIENTS, sizeof(scan_parameters_service_client_t));
2112 #endif
2113 #if MAX_NR_SM_LOOKUP_ENTRIES > 0
2114 btstack_memory_pool_create(&sm_lookup_entry_pool, sm_lookup_entry_storage, MAX_NR_SM_LOOKUP_ENTRIES, sizeof(sm_lookup_entry_t));
2115 #endif
2116 #if MAX_NR_WHITELIST_ENTRIES > 0
2117 btstack_memory_pool_create(&whitelist_entry_pool, whitelist_entry_storage, MAX_NR_WHITELIST_ENTRIES, sizeof(whitelist_entry_t));
2118 #endif
2119 #if MAX_NR_PERIODIC_ADVERTISER_LIST_ENTRIES > 0
2120 btstack_memory_pool_create(&periodic_advertiser_list_entry_pool, periodic_advertiser_list_entry_storage, MAX_NR_PERIODIC_ADVERTISER_LIST_ENTRIES, sizeof(periodic_advertiser_list_entry_t));
2121 #endif
2122
2123 #endif
2124 #ifdef ENABLE_MESH
2125 #if MAX_NR_MESH_NETWORK_PDUS > 0
2126 btstack_memory_pool_create(&mesh_network_pdu_pool, mesh_network_pdu_storage, MAX_NR_MESH_NETWORK_PDUS, sizeof(mesh_network_pdu_t));
2127 #endif
2128 #if MAX_NR_MESH_SEGMENTED_PDUS > 0
2129 btstack_memory_pool_create(&mesh_segmented_pdu_pool, mesh_segmented_pdu_storage, MAX_NR_MESH_SEGMENTED_PDUS, sizeof(mesh_segmented_pdu_t));
2130 #endif
2131 #if MAX_NR_MESH_UPPER_TRANSPORT_PDUS > 0
2132 btstack_memory_pool_create(&mesh_upper_transport_pdu_pool, mesh_upper_transport_pdu_storage, MAX_NR_MESH_UPPER_TRANSPORT_PDUS, sizeof(mesh_upper_transport_pdu_t));
2133 #endif
2134 #if MAX_NR_MESH_NETWORK_KEYS > 0
2135 btstack_memory_pool_create(&mesh_network_key_pool, mesh_network_key_storage, MAX_NR_MESH_NETWORK_KEYS, sizeof(mesh_network_key_t));
2136 #endif
2137 #if MAX_NR_MESH_TRANSPORT_KEYS > 0
2138 btstack_memory_pool_create(&mesh_transport_key_pool, mesh_transport_key_storage, MAX_NR_MESH_TRANSPORT_KEYS, sizeof(mesh_transport_key_t));
2139 #endif
2140 #if MAX_NR_MESH_VIRTUAL_ADDRESSS > 0
2141 btstack_memory_pool_create(&mesh_virtual_address_pool, mesh_virtual_address_storage, MAX_NR_MESH_VIRTUAL_ADDRESSS, sizeof(mesh_virtual_address_t));
2142 #endif
2143 #if MAX_NR_MESH_SUBNETS > 0
2144 btstack_memory_pool_create(&mesh_subnet_pool, mesh_subnet_storage, MAX_NR_MESH_SUBNETS, sizeof(mesh_subnet_t));
2145 #endif
2146
2147 #endif
2148 #ifdef ENABLE_LE_ISOCHRONOUS_STREAMS
2149 #if MAX_NR_HCI_ISO_STREAMS > 0
2150 btstack_memory_pool_create(&hci_iso_stream_pool, hci_iso_stream_storage, MAX_NR_HCI_ISO_STREAMS, sizeof(hci_iso_stream_t));
2151 #endif
2152
2153 #endif
2154 }
2155