1a3b02b71Smatthias.ringwald /*
2a0c35809S[email protected] * Copyright (C) 2014 BlueKitchen GmbH
3a3b02b71Smatthias.ringwald *
4a3b02b71Smatthias.ringwald * Redistribution and use in source and binary forms, with or without
5a3b02b71Smatthias.ringwald * modification, are permitted provided that the following conditions
6a3b02b71Smatthias.ringwald * are met:
7a3b02b71Smatthias.ringwald *
8a3b02b71Smatthias.ringwald * 1. Redistributions of source code must retain the above copyright
9a3b02b71Smatthias.ringwald * notice, this list of conditions and the following disclaimer.
10a3b02b71Smatthias.ringwald * 2. Redistributions in binary form must reproduce the above copyright
11a3b02b71Smatthias.ringwald * notice, this list of conditions and the following disclaimer in the
12a3b02b71Smatthias.ringwald * documentation and/or other materials provided with the distribution.
13a3b02b71Smatthias.ringwald * 3. Neither the name of the copyright holders nor the names of
14a3b02b71Smatthias.ringwald * contributors may be used to endorse or promote products derived
15a3b02b71Smatthias.ringwald * from this software without specific prior written permission.
166b64433eSmatthias.ringwald * 4. Any redistribution, use, or modification is done solely for
176b64433eSmatthias.ringwald * personal benefit and not for any commercial purpose or for
186b64433eSmatthias.ringwald * monetary gain.
19a3b02b71Smatthias.ringwald *
202e97c149S[email protected] * THIS SOFTWARE IS PROVIDED BY BLUEKITCHEN GMBH AND CONTRIBUTORS
21a3b02b71Smatthias.ringwald * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22a3b02b71Smatthias.ringwald * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
232fca4dadSMilanka Ringwald * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BLUEKITCHEN
242fca4dadSMilanka Ringwald * GMBH OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
25a3b02b71Smatthias.ringwald * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
26a3b02b71Smatthias.ringwald * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
27a3b02b71Smatthias.ringwald * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
28a3b02b71Smatthias.ringwald * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
29a3b02b71Smatthias.ringwald * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
30a3b02b71Smatthias.ringwald * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31a3b02b71Smatthias.ringwald * SUCH DAMAGE.
32a3b02b71Smatthias.ringwald *
332e97c149S[email protected] * Please inquire about commercial licensing options at
342e97c149S[email protected] * [email protected]
356b64433eSmatthias.ringwald *
36a3b02b71Smatthias.ringwald */
37a3b02b71Smatthias.ringwald
38f7434c1fSMatthias Ringwald
39e501bae0SMatthias Ringwald #define BTSTACK_FILE__ "btstack_memory.c"
40bb2a7656SMatthias Ringwald
41b6269742SMatthias Ringwald
42a3b02b71Smatthias.ringwald /*
43f7434c1fSMatthias Ringwald * btstack_memory.c
44a3b02b71Smatthias.ringwald *
45a3b02b71Smatthias.ringwald * @brief BTstack memory management via configurable memory pools
46a3b02b71Smatthias.ringwald *
47a98592bcSMatthias Ringwald * @note code generated by tool/btstack_memory_generator.py
48a2673d88SMatthias Ringwald * @note returnes buffers are initialized with 0
49a3b02b71Smatthias.ringwald *
50a3b02b71Smatthias.ringwald */
51a3b02b71Smatthias.ringwald
52a3b02b71Smatthias.ringwald #include "btstack_memory.h"
53d2e6c4b7SMatthias Ringwald #include "btstack_memory_pool.h"
54b6269742SMatthias Ringwald #include "btstack_debug.h"
55a3b02b71Smatthias.ringwald
56a3b02b71Smatthias.ringwald #include <stdlib.h>
57a3b02b71Smatthias.ringwald
58cf26c8fbSMilanka Ringwald #ifdef ENABLE_MALLOC_TEST
594490dd1dSMatthias Ringwald void * test_malloc(size_t size);
60cf26c8fbSMilanka Ringwald #define malloc test_malloc
61cf26c8fbSMilanka Ringwald #endif
62cf26c8fbSMilanka Ringwald
63b6269742SMatthias Ringwald #ifdef HAVE_MALLOC
64b6269742SMatthias Ringwald typedef struct btstack_memory_buffer {
65b6269742SMatthias Ringwald struct btstack_memory_buffer * next;
66b6269742SMatthias Ringwald struct btstack_memory_buffer * prev;
67b6269742SMatthias Ringwald } btstack_memory_buffer_t;
68b6269742SMatthias Ringwald
69798bd46fSMatthias Ringwald typedef struct {
70798bd46fSMatthias Ringwald btstack_memory_buffer_t tracking;
71798bd46fSMatthias Ringwald void * pointer;
72798bd46fSMatthias Ringwald } test_buffer_t;
73798bd46fSMatthias Ringwald
74b6269742SMatthias Ringwald static btstack_memory_buffer_t * btstack_memory_malloc_buffers;
7519ef97d2SMatthias Ringwald static uint32_t btstack_memory_malloc_counter;
76b6269742SMatthias Ringwald
btstack_memory_tracking_add(btstack_memory_buffer_t * buffer)772a95308bSMatthias Ringwald static void btstack_memory_tracking_add(btstack_memory_buffer_t * buffer){
782a95308bSMatthias Ringwald btstack_assert(buffer != NULL);
7919ef97d2SMatthias Ringwald if (btstack_memory_malloc_buffers != NULL) {
8019ef97d2SMatthias Ringwald // let current first item prev point to new first item
8119ef97d2SMatthias Ringwald btstack_memory_malloc_buffers->prev = buffer;
8219ef97d2SMatthias Ringwald }
83b6269742SMatthias Ringwald buffer->prev = NULL;
84b6269742SMatthias Ringwald buffer->next = btstack_memory_malloc_buffers;
85b6269742SMatthias Ringwald btstack_memory_malloc_buffers = buffer;
8619ef97d2SMatthias Ringwald
8719ef97d2SMatthias Ringwald btstack_memory_malloc_counter++;
88b6269742SMatthias Ringwald }
89b6269742SMatthias Ringwald
btstack_memory_tracking_remove(btstack_memory_buffer_t * buffer)902a95308bSMatthias Ringwald static void btstack_memory_tracking_remove(btstack_memory_buffer_t * buffer){
912a95308bSMatthias Ringwald btstack_assert(buffer != NULL);
92b6269742SMatthias Ringwald if (buffer->prev == NULL){
93b6269742SMatthias Ringwald // first item
94b6269742SMatthias Ringwald btstack_memory_malloc_buffers = buffer->next;
95b6269742SMatthias Ringwald } else {
96b6269742SMatthias Ringwald buffer->prev->next = buffer->next;
97b6269742SMatthias Ringwald }
98b6269742SMatthias Ringwald if (buffer->next != NULL){
99b6269742SMatthias Ringwald buffer->next->prev = buffer->prev;
100b6269742SMatthias Ringwald }
10119ef97d2SMatthias Ringwald
10219ef97d2SMatthias Ringwald btstack_memory_malloc_counter--;
103b6269742SMatthias Ringwald }
104b6269742SMatthias Ringwald #endif
105b6269742SMatthias Ringwald
btstack_memory_deinit(void)106b6269742SMatthias Ringwald void btstack_memory_deinit(void){
107b6269742SMatthias Ringwald #ifdef HAVE_MALLOC
108b6269742SMatthias Ringwald while (btstack_memory_malloc_buffers != NULL){
109b6269742SMatthias Ringwald btstack_memory_buffer_t * buffer = btstack_memory_malloc_buffers;
110b6269742SMatthias Ringwald btstack_memory_malloc_buffers = buffer->next;
111b6269742SMatthias Ringwald free(buffer);
1120e109a16SMatthias Ringwald btstack_memory_malloc_counter--;
113b6269742SMatthias Ringwald }
11419ef97d2SMatthias Ringwald btstack_assert(btstack_memory_malloc_counter == 0);
115b6269742SMatthias Ringwald #endif
116b6269742SMatthias Ringwald }
117a3b02b71Smatthias.ringwald
1182e97c149S[email protected]
119a3b02b71Smatthias.ringwald // MARK: hci_connection_t
120a265b909SMatthias Ringwald #if !defined(HAVE_MALLOC) && !defined(MAX_NR_HCI_CONNECTIONS)
121a265b909SMatthias Ringwald #if defined(MAX_NO_HCI_CONNECTIONS)
12227faf85aSMilanka Ringwald #error "Deprecated MAX_NO_HCI_CONNECTIONS defined instead of MAX_NR_HCI_CONNECTIONS. Please update your btstack_config.h to use MAX_NR_HCI_CONNECTIONS."
123a265b909SMatthias Ringwald #else
124a265b909SMatthias Ringwald #define MAX_NR_HCI_CONNECTIONS 0
125a265b909SMatthias Ringwald #endif
126a265b909SMatthias Ringwald #endif
127a265b909SMatthias Ringwald
128a265b909SMatthias Ringwald #ifdef MAX_NR_HCI_CONNECTIONS
129a265b909SMatthias Ringwald #if MAX_NR_HCI_CONNECTIONS > 0
130a265b909SMatthias Ringwald static hci_connection_t hci_connection_storage[MAX_NR_HCI_CONNECTIONS];
13129d0c4f7SMatthias Ringwald static btstack_memory_pool_t hci_connection_pool;
btstack_memory_hci_connection_get(void)1326527a633S[email protected] hci_connection_t * btstack_memory_hci_connection_get(void){
133a2673d88SMatthias Ringwald void * buffer = btstack_memory_pool_get(&hci_connection_pool);
134a2673d88SMatthias Ringwald if (buffer){
135a2673d88SMatthias Ringwald memset(buffer, 0, sizeof(hci_connection_t));
136a2673d88SMatthias Ringwald }
137a2673d88SMatthias Ringwald return (hci_connection_t *) buffer;
138a3b02b71Smatthias.ringwald }
btstack_memory_hci_connection_free(hci_connection_t * hci_connection)1396527a633S[email protected] void btstack_memory_hci_connection_free(hci_connection_t *hci_connection){
14029d0c4f7SMatthias Ringwald btstack_memory_pool_free(&hci_connection_pool, hci_connection);
141a3b02b71Smatthias.ringwald }
142c4d3f927Smatthias.ringwald #else
btstack_memory_hci_connection_get(void)1436527a633S[email protected] hci_connection_t * btstack_memory_hci_connection_get(void){
144c4d3f927Smatthias.ringwald return NULL;
145c4d3f927Smatthias.ringwald }
btstack_memory_hci_connection_free(hci_connection_t * hci_connection)1466527a633S[email protected] void btstack_memory_hci_connection_free(hci_connection_t *hci_connection){
147b6269742SMatthias Ringwald UNUSED(hci_connection);
148*42a2bbebSMatthias Ringwald }
149c4d3f927Smatthias.ringwald #endif
150a3b02b71Smatthias.ringwald #elif defined(HAVE_MALLOC)
1512a95308bSMatthias Ringwald
1522a95308bSMatthias Ringwald typedef struct {
1532a95308bSMatthias Ringwald btstack_memory_buffer_t tracking;
154798bd46fSMatthias Ringwald hci_connection_t data;
1552a95308bSMatthias Ringwald } btstack_memory_hci_connection_t;
1562a95308bSMatthias Ringwald
btstack_memory_hci_connection_get(void)1576527a633S[email protected] hci_connection_t * btstack_memory_hci_connection_get(void){
1582a95308bSMatthias Ringwald btstack_memory_hci_connection_t * buffer = (btstack_memory_hci_connection_t *) malloc(sizeof(btstack_memory_hci_connection_t));
159a2673d88SMatthias Ringwald if (buffer){
160798bd46fSMatthias Ringwald memset(buffer, 0, sizeof(btstack_memory_hci_connection_t));
1612a95308bSMatthias Ringwald btstack_memory_tracking_add(&buffer->tracking);
1622a95308bSMatthias Ringwald return &buffer->data;
163b6269742SMatthias Ringwald } else {
164b6269742SMatthias Ringwald return NULL;
165a2673d88SMatthias Ringwald }
166a3b02b71Smatthias.ringwald }
btstack_memory_hci_connection_free(hci_connection_t * hci_connection)1676527a633S[email protected] void btstack_memory_hci_connection_free(hci_connection_t *hci_connection){
168798bd46fSMatthias Ringwald // reconstruct buffer start
169798bd46fSMatthias Ringwald btstack_memory_buffer_t * buffer = &((btstack_memory_buffer_t *) hci_connection)[-1];
170798bd46fSMatthias Ringwald btstack_memory_tracking_remove(buffer);
171b6269742SMatthias Ringwald free(buffer);
172a3b02b71Smatthias.ringwald }
173a3b02b71Smatthias.ringwald #endif
174a3b02b71Smatthias.ringwald
175a3b02b71Smatthias.ringwald
1762e97c149S[email protected]
177a3b02b71Smatthias.ringwald // MARK: l2cap_service_t
178a265b909SMatthias Ringwald #if !defined(HAVE_MALLOC) && !defined(MAX_NR_L2CAP_SERVICES)
179a265b909SMatthias Ringwald #if defined(MAX_NO_L2CAP_SERVICES)
18027faf85aSMilanka Ringwald #error "Deprecated MAX_NO_L2CAP_SERVICES defined instead of MAX_NR_L2CAP_SERVICES. Please update your btstack_config.h to use MAX_NR_L2CAP_SERVICES."
181a265b909SMatthias Ringwald #else
182a265b909SMatthias Ringwald #define MAX_NR_L2CAP_SERVICES 0
183a265b909SMatthias Ringwald #endif
184a265b909SMatthias Ringwald #endif
185a265b909SMatthias Ringwald
186a265b909SMatthias Ringwald #ifdef MAX_NR_L2CAP_SERVICES
187a265b909SMatthias Ringwald #if MAX_NR_L2CAP_SERVICES > 0
188a265b909SMatthias Ringwald static l2cap_service_t l2cap_service_storage[MAX_NR_L2CAP_SERVICES];
18929d0c4f7SMatthias Ringwald static btstack_memory_pool_t l2cap_service_pool;
btstack_memory_l2cap_service_get(void)1906527a633S[email protected] l2cap_service_t * btstack_memory_l2cap_service_get(void){
191a2673d88SMatthias Ringwald void * buffer = btstack_memory_pool_get(&l2cap_service_pool);
192a2673d88SMatthias Ringwald if (buffer){
193a2673d88SMatthias Ringwald memset(buffer, 0, sizeof(l2cap_service_t));
194a2673d88SMatthias Ringwald }
195a2673d88SMatthias Ringwald return (l2cap_service_t *) buffer;
196a3b02b71Smatthias.ringwald }
btstack_memory_l2cap_service_free(l2cap_service_t * l2cap_service)1976527a633S[email protected] void btstack_memory_l2cap_service_free(l2cap_service_t *l2cap_service){
19829d0c4f7SMatthias Ringwald btstack_memory_pool_free(&l2cap_service_pool, l2cap_service);
199a3b02b71Smatthias.ringwald }
200c4d3f927Smatthias.ringwald #else
btstack_memory_l2cap_service_get(void)2016527a633S[email protected] l2cap_service_t * btstack_memory_l2cap_service_get(void){
202c4d3f927Smatthias.ringwald return NULL;
203c4d3f927Smatthias.ringwald }
btstack_memory_l2cap_service_free(l2cap_service_t * l2cap_service)2046527a633S[email protected] void btstack_memory_l2cap_service_free(l2cap_service_t *l2cap_service){
205b6269742SMatthias Ringwald UNUSED(l2cap_service);
206*42a2bbebSMatthias Ringwald }
207c4d3f927Smatthias.ringwald #endif
208a3b02b71Smatthias.ringwald #elif defined(HAVE_MALLOC)
2092a95308bSMatthias Ringwald
2102a95308bSMatthias Ringwald typedef struct {
2112a95308bSMatthias Ringwald btstack_memory_buffer_t tracking;
212798bd46fSMatthias Ringwald l2cap_service_t data;
2132a95308bSMatthias Ringwald } btstack_memory_l2cap_service_t;
2142a95308bSMatthias Ringwald
btstack_memory_l2cap_service_get(void)2156527a633S[email protected] l2cap_service_t * btstack_memory_l2cap_service_get(void){
2162a95308bSMatthias Ringwald btstack_memory_l2cap_service_t * buffer = (btstack_memory_l2cap_service_t *) malloc(sizeof(btstack_memory_l2cap_service_t));
217a2673d88SMatthias Ringwald if (buffer){
218798bd46fSMatthias Ringwald memset(buffer, 0, sizeof(btstack_memory_l2cap_service_t));
2192a95308bSMatthias Ringwald btstack_memory_tracking_add(&buffer->tracking);
2202a95308bSMatthias Ringwald return &buffer->data;
221b6269742SMatthias Ringwald } else {
222b6269742SMatthias Ringwald return NULL;
223a2673d88SMatthias Ringwald }
224a3b02b71Smatthias.ringwald }
btstack_memory_l2cap_service_free(l2cap_service_t * l2cap_service)2256527a633S[email protected] void btstack_memory_l2cap_service_free(l2cap_service_t *l2cap_service){
226798bd46fSMatthias Ringwald // reconstruct buffer start
227798bd46fSMatthias Ringwald btstack_memory_buffer_t * buffer = &((btstack_memory_buffer_t *) l2cap_service)[-1];
228798bd46fSMatthias Ringwald btstack_memory_tracking_remove(buffer);
229b6269742SMatthias Ringwald free(buffer);
230a3b02b71Smatthias.ringwald }
231a3b02b71Smatthias.ringwald #endif
232a3b02b71Smatthias.ringwald
233a3b02b71Smatthias.ringwald
234a3b02b71Smatthias.ringwald // MARK: l2cap_channel_t
235a265b909SMatthias Ringwald #if !defined(HAVE_MALLOC) && !defined(MAX_NR_L2CAP_CHANNELS)
236a265b909SMatthias Ringwald #if defined(MAX_NO_L2CAP_CHANNELS)
23727faf85aSMilanka Ringwald #error "Deprecated MAX_NO_L2CAP_CHANNELS defined instead of MAX_NR_L2CAP_CHANNELS. Please update your btstack_config.h to use MAX_NR_L2CAP_CHANNELS."
238a265b909SMatthias Ringwald #else
239a265b909SMatthias Ringwald #define MAX_NR_L2CAP_CHANNELS 0
240a265b909SMatthias Ringwald #endif
241a265b909SMatthias Ringwald #endif
242a265b909SMatthias Ringwald
243a265b909SMatthias Ringwald #ifdef MAX_NR_L2CAP_CHANNELS
244a265b909SMatthias Ringwald #if MAX_NR_L2CAP_CHANNELS > 0
245a265b909SMatthias Ringwald static l2cap_channel_t l2cap_channel_storage[MAX_NR_L2CAP_CHANNELS];
24629d0c4f7SMatthias Ringwald static btstack_memory_pool_t l2cap_channel_pool;
btstack_memory_l2cap_channel_get(void)2476527a633S[email protected] l2cap_channel_t * btstack_memory_l2cap_channel_get(void){
248a2673d88SMatthias Ringwald void * buffer = btstack_memory_pool_get(&l2cap_channel_pool);
249a2673d88SMatthias Ringwald if (buffer){
250a2673d88SMatthias Ringwald memset(buffer, 0, sizeof(l2cap_channel_t));
251a2673d88SMatthias Ringwald }
252a2673d88SMatthias Ringwald return (l2cap_channel_t *) buffer;
253a3b02b71Smatthias.ringwald }
btstack_memory_l2cap_channel_free(l2cap_channel_t * l2cap_channel)2546527a633S[email protected] void btstack_memory_l2cap_channel_free(l2cap_channel_t *l2cap_channel){
25529d0c4f7SMatthias Ringwald btstack_memory_pool_free(&l2cap_channel_pool, l2cap_channel);
256a3b02b71Smatthias.ringwald }
257c4d3f927Smatthias.ringwald #else
btstack_memory_l2cap_channel_get(void)2586527a633S[email protected] l2cap_channel_t * btstack_memory_l2cap_channel_get(void){
259c4d3f927Smatthias.ringwald return NULL;
260c4d3f927Smatthias.ringwald }
btstack_memory_l2cap_channel_free(l2cap_channel_t * l2cap_channel)2616527a633S[email protected] void btstack_memory_l2cap_channel_free(l2cap_channel_t *l2cap_channel){
262b6269742SMatthias Ringwald UNUSED(l2cap_channel);
263*42a2bbebSMatthias Ringwald }
264c4d3f927Smatthias.ringwald #endif
265a3b02b71Smatthias.ringwald #elif defined(HAVE_MALLOC)
2662a95308bSMatthias Ringwald
2672a95308bSMatthias Ringwald typedef struct {
2682a95308bSMatthias Ringwald btstack_memory_buffer_t tracking;
269798bd46fSMatthias Ringwald l2cap_channel_t data;
2702a95308bSMatthias Ringwald } btstack_memory_l2cap_channel_t;
2712a95308bSMatthias Ringwald
btstack_memory_l2cap_channel_get(void)2726527a633S[email protected] l2cap_channel_t * btstack_memory_l2cap_channel_get(void){
2732a95308bSMatthias Ringwald btstack_memory_l2cap_channel_t * buffer = (btstack_memory_l2cap_channel_t *) malloc(sizeof(btstack_memory_l2cap_channel_t));
274a2673d88SMatthias Ringwald if (buffer){
275798bd46fSMatthias Ringwald memset(buffer, 0, sizeof(btstack_memory_l2cap_channel_t));
2762a95308bSMatthias Ringwald btstack_memory_tracking_add(&buffer->tracking);
2772a95308bSMatthias Ringwald return &buffer->data;
278b6269742SMatthias Ringwald } else {
279b6269742SMatthias Ringwald return NULL;
280a2673d88SMatthias Ringwald }
281a3b02b71Smatthias.ringwald }
btstack_memory_l2cap_channel_free(l2cap_channel_t * l2cap_channel)2826527a633S[email protected] void btstack_memory_l2cap_channel_free(l2cap_channel_t *l2cap_channel){
283798bd46fSMatthias Ringwald // reconstruct buffer start
284798bd46fSMatthias Ringwald btstack_memory_buffer_t * buffer = &((btstack_memory_buffer_t *) l2cap_channel)[-1];
285798bd46fSMatthias Ringwald btstack_memory_tracking_remove(buffer);
286b6269742SMatthias Ringwald free(buffer);
287a3b02b71Smatthias.ringwald }
288a3b02b71Smatthias.ringwald #endif
289a3b02b71Smatthias.ringwald
290a3b02b71Smatthias.ringwald
29144c5d856SMatthias Ringwald #ifdef ENABLE_CLASSIC
2922e97c149S[email protected]
293a3b02b71Smatthias.ringwald // MARK: rfcomm_multiplexer_t
294a265b909SMatthias Ringwald #if !defined(HAVE_MALLOC) && !defined(MAX_NR_RFCOMM_MULTIPLEXERS)
295a265b909SMatthias Ringwald #if defined(MAX_NO_RFCOMM_MULTIPLEXERS)
29627faf85aSMilanka Ringwald #error "Deprecated MAX_NO_RFCOMM_MULTIPLEXERS defined instead of MAX_NR_RFCOMM_MULTIPLEXERS. Please update your btstack_config.h to use MAX_NR_RFCOMM_MULTIPLEXERS."
297a265b909SMatthias Ringwald #else
298a265b909SMatthias Ringwald #define MAX_NR_RFCOMM_MULTIPLEXERS 0
299a265b909SMatthias Ringwald #endif
300a265b909SMatthias Ringwald #endif
301a265b909SMatthias Ringwald
302a265b909SMatthias Ringwald #ifdef MAX_NR_RFCOMM_MULTIPLEXERS
303a265b909SMatthias Ringwald #if MAX_NR_RFCOMM_MULTIPLEXERS > 0
304a265b909SMatthias Ringwald static rfcomm_multiplexer_t rfcomm_multiplexer_storage[MAX_NR_RFCOMM_MULTIPLEXERS];
30529d0c4f7SMatthias Ringwald static btstack_memory_pool_t rfcomm_multiplexer_pool;
btstack_memory_rfcomm_multiplexer_get(void)3066527a633S[email protected] rfcomm_multiplexer_t * btstack_memory_rfcomm_multiplexer_get(void){
307a2673d88SMatthias Ringwald void * buffer = btstack_memory_pool_get(&rfcomm_multiplexer_pool);
308a2673d88SMatthias Ringwald if (buffer){
309a2673d88SMatthias Ringwald memset(buffer, 0, sizeof(rfcomm_multiplexer_t));
310a2673d88SMatthias Ringwald }
311a2673d88SMatthias Ringwald return (rfcomm_multiplexer_t *) buffer;
312a3b02b71Smatthias.ringwald }
btstack_memory_rfcomm_multiplexer_free(rfcomm_multiplexer_t * rfcomm_multiplexer)3136527a633S[email protected] void btstack_memory_rfcomm_multiplexer_free(rfcomm_multiplexer_t *rfcomm_multiplexer){
31429d0c4f7SMatthias Ringwald btstack_memory_pool_free(&rfcomm_multiplexer_pool, rfcomm_multiplexer);
315a3b02b71Smatthias.ringwald }
316c4d3f927Smatthias.ringwald #else
btstack_memory_rfcomm_multiplexer_get(void)3176527a633S[email protected] rfcomm_multiplexer_t * btstack_memory_rfcomm_multiplexer_get(void){
318c4d3f927Smatthias.ringwald return NULL;
319c4d3f927Smatthias.ringwald }
btstack_memory_rfcomm_multiplexer_free(rfcomm_multiplexer_t * rfcomm_multiplexer)3206527a633S[email protected] void btstack_memory_rfcomm_multiplexer_free(rfcomm_multiplexer_t *rfcomm_multiplexer){
321b6269742SMatthias Ringwald UNUSED(rfcomm_multiplexer);
322*42a2bbebSMatthias Ringwald }
323c4d3f927Smatthias.ringwald #endif
324a3b02b71Smatthias.ringwald #elif defined(HAVE_MALLOC)
3252a95308bSMatthias Ringwald
3262a95308bSMatthias Ringwald typedef struct {
3272a95308bSMatthias Ringwald btstack_memory_buffer_t tracking;
328798bd46fSMatthias Ringwald rfcomm_multiplexer_t data;
3292a95308bSMatthias Ringwald } btstack_memory_rfcomm_multiplexer_t;
3302a95308bSMatthias Ringwald
btstack_memory_rfcomm_multiplexer_get(void)3316527a633S[email protected] rfcomm_multiplexer_t * btstack_memory_rfcomm_multiplexer_get(void){
3322a95308bSMatthias Ringwald btstack_memory_rfcomm_multiplexer_t * buffer = (btstack_memory_rfcomm_multiplexer_t *) malloc(sizeof(btstack_memory_rfcomm_multiplexer_t));
333a2673d88SMatthias Ringwald if (buffer){
334798bd46fSMatthias Ringwald memset(buffer, 0, sizeof(btstack_memory_rfcomm_multiplexer_t));
3352a95308bSMatthias Ringwald btstack_memory_tracking_add(&buffer->tracking);
3362a95308bSMatthias Ringwald return &buffer->data;
337b6269742SMatthias Ringwald } else {
338b6269742SMatthias Ringwald return NULL;
339a2673d88SMatthias Ringwald }
340a3b02b71Smatthias.ringwald }
btstack_memory_rfcomm_multiplexer_free(rfcomm_multiplexer_t * rfcomm_multiplexer)3416527a633S[email protected] void btstack_memory_rfcomm_multiplexer_free(rfcomm_multiplexer_t *rfcomm_multiplexer){
342798bd46fSMatthias Ringwald // reconstruct buffer start
343798bd46fSMatthias Ringwald btstack_memory_buffer_t * buffer = &((btstack_memory_buffer_t *) rfcomm_multiplexer)[-1];
344798bd46fSMatthias Ringwald btstack_memory_tracking_remove(buffer);
345b6269742SMatthias Ringwald free(buffer);
346a3b02b71Smatthias.ringwald }
347a3b02b71Smatthias.ringwald #endif
348a3b02b71Smatthias.ringwald
349a3b02b71Smatthias.ringwald
350a3b02b71Smatthias.ringwald // MARK: rfcomm_service_t
351a265b909SMatthias Ringwald #if !defined(HAVE_MALLOC) && !defined(MAX_NR_RFCOMM_SERVICES)
352a265b909SMatthias Ringwald #if defined(MAX_NO_RFCOMM_SERVICES)
35327faf85aSMilanka Ringwald #error "Deprecated MAX_NO_RFCOMM_SERVICES defined instead of MAX_NR_RFCOMM_SERVICES. Please update your btstack_config.h to use MAX_NR_RFCOMM_SERVICES."
354a265b909SMatthias Ringwald #else
355a265b909SMatthias Ringwald #define MAX_NR_RFCOMM_SERVICES 0
356a265b909SMatthias Ringwald #endif
357a265b909SMatthias Ringwald #endif
358a265b909SMatthias Ringwald
359a265b909SMatthias Ringwald #ifdef MAX_NR_RFCOMM_SERVICES
360a265b909SMatthias Ringwald #if MAX_NR_RFCOMM_SERVICES > 0
361a265b909SMatthias Ringwald static rfcomm_service_t rfcomm_service_storage[MAX_NR_RFCOMM_SERVICES];
36229d0c4f7SMatthias Ringwald static btstack_memory_pool_t rfcomm_service_pool;
btstack_memory_rfcomm_service_get(void)3636527a633S[email protected] rfcomm_service_t * btstack_memory_rfcomm_service_get(void){
364a2673d88SMatthias Ringwald void * buffer = btstack_memory_pool_get(&rfcomm_service_pool);
365a2673d88SMatthias Ringwald if (buffer){
366a2673d88SMatthias Ringwald memset(buffer, 0, sizeof(rfcomm_service_t));
367a2673d88SMatthias Ringwald }
368a2673d88SMatthias Ringwald return (rfcomm_service_t *) buffer;
369a3b02b71Smatthias.ringwald }
btstack_memory_rfcomm_service_free(rfcomm_service_t * rfcomm_service)3706527a633S[email protected] void btstack_memory_rfcomm_service_free(rfcomm_service_t *rfcomm_service){
37129d0c4f7SMatthias Ringwald btstack_memory_pool_free(&rfcomm_service_pool, rfcomm_service);
372a3b02b71Smatthias.ringwald }
373c4d3f927Smatthias.ringwald #else
btstack_memory_rfcomm_service_get(void)3746527a633S[email protected] rfcomm_service_t * btstack_memory_rfcomm_service_get(void){
375c4d3f927Smatthias.ringwald return NULL;
376c4d3f927Smatthias.ringwald }
btstack_memory_rfcomm_service_free(rfcomm_service_t * rfcomm_service)3776527a633S[email protected] void btstack_memory_rfcomm_service_free(rfcomm_service_t *rfcomm_service){
378b6269742SMatthias Ringwald UNUSED(rfcomm_service);
379*42a2bbebSMatthias Ringwald }
380c4d3f927Smatthias.ringwald #endif
381a3b02b71Smatthias.ringwald #elif defined(HAVE_MALLOC)
3822a95308bSMatthias Ringwald
3832a95308bSMatthias Ringwald typedef struct {
3842a95308bSMatthias Ringwald btstack_memory_buffer_t tracking;
385798bd46fSMatthias Ringwald rfcomm_service_t data;
3862a95308bSMatthias Ringwald } btstack_memory_rfcomm_service_t;
3872a95308bSMatthias Ringwald
btstack_memory_rfcomm_service_get(void)3886527a633S[email protected] rfcomm_service_t * btstack_memory_rfcomm_service_get(void){
3892a95308bSMatthias Ringwald btstack_memory_rfcomm_service_t * buffer = (btstack_memory_rfcomm_service_t *) malloc(sizeof(btstack_memory_rfcomm_service_t));
390a2673d88SMatthias Ringwald if (buffer){
391798bd46fSMatthias Ringwald memset(buffer, 0, sizeof(btstack_memory_rfcomm_service_t));
3922a95308bSMatthias Ringwald btstack_memory_tracking_add(&buffer->tracking);
3932a95308bSMatthias Ringwald return &buffer->data;
394b6269742SMatthias Ringwald } else {
395b6269742SMatthias Ringwald return NULL;
396a2673d88SMatthias Ringwald }
397a3b02b71Smatthias.ringwald }
btstack_memory_rfcomm_service_free(rfcomm_service_t * rfcomm_service)3986527a633S[email protected] void btstack_memory_rfcomm_service_free(rfcomm_service_t *rfcomm_service){
399798bd46fSMatthias Ringwald // reconstruct buffer start
400798bd46fSMatthias Ringwald btstack_memory_buffer_t * buffer = &((btstack_memory_buffer_t *) rfcomm_service)[-1];
401798bd46fSMatthias Ringwald btstack_memory_tracking_remove(buffer);
402b6269742SMatthias Ringwald free(buffer);
403a3b02b71Smatthias.ringwald }
404a3b02b71Smatthias.ringwald #endif
405a3b02b71Smatthias.ringwald
406a3b02b71Smatthias.ringwald
407a3b02b71Smatthias.ringwald // MARK: rfcomm_channel_t
408a265b909SMatthias Ringwald #if !defined(HAVE_MALLOC) && !defined(MAX_NR_RFCOMM_CHANNELS)
409a265b909SMatthias Ringwald #if defined(MAX_NO_RFCOMM_CHANNELS)
41027faf85aSMilanka Ringwald #error "Deprecated MAX_NO_RFCOMM_CHANNELS defined instead of MAX_NR_RFCOMM_CHANNELS. Please update your btstack_config.h to use MAX_NR_RFCOMM_CHANNELS."
411a265b909SMatthias Ringwald #else
412a265b909SMatthias Ringwald #define MAX_NR_RFCOMM_CHANNELS 0
413a265b909SMatthias Ringwald #endif
414a265b909SMatthias Ringwald #endif
415a265b909SMatthias Ringwald
416a265b909SMatthias Ringwald #ifdef MAX_NR_RFCOMM_CHANNELS
417a265b909SMatthias Ringwald #if MAX_NR_RFCOMM_CHANNELS > 0
418a265b909SMatthias Ringwald static rfcomm_channel_t rfcomm_channel_storage[MAX_NR_RFCOMM_CHANNELS];
41929d0c4f7SMatthias Ringwald static btstack_memory_pool_t rfcomm_channel_pool;
btstack_memory_rfcomm_channel_get(void)4206527a633S[email protected] rfcomm_channel_t * btstack_memory_rfcomm_channel_get(void){
421a2673d88SMatthias Ringwald void * buffer = btstack_memory_pool_get(&rfcomm_channel_pool);
422a2673d88SMatthias Ringwald if (buffer){
423a2673d88SMatthias Ringwald memset(buffer, 0, sizeof(rfcomm_channel_t));
424a2673d88SMatthias Ringwald }
425a2673d88SMatthias Ringwald return (rfcomm_channel_t *) buffer;
426a3b02b71Smatthias.ringwald }
btstack_memory_rfcomm_channel_free(rfcomm_channel_t * rfcomm_channel)4276527a633S[email protected] void btstack_memory_rfcomm_channel_free(rfcomm_channel_t *rfcomm_channel){
42829d0c4f7SMatthias Ringwald btstack_memory_pool_free(&rfcomm_channel_pool, rfcomm_channel);
429a3b02b71Smatthias.ringwald }
430c4d3f927Smatthias.ringwald #else
btstack_memory_rfcomm_channel_get(void)4316527a633S[email protected] rfcomm_channel_t * btstack_memory_rfcomm_channel_get(void){
432c4d3f927Smatthias.ringwald return NULL;
433c4d3f927Smatthias.ringwald }
btstack_memory_rfcomm_channel_free(rfcomm_channel_t * rfcomm_channel)4346527a633S[email protected] void btstack_memory_rfcomm_channel_free(rfcomm_channel_t *rfcomm_channel){
435b6269742SMatthias Ringwald UNUSED(rfcomm_channel);
436*42a2bbebSMatthias Ringwald }
437c4d3f927Smatthias.ringwald #endif
438a3b02b71Smatthias.ringwald #elif defined(HAVE_MALLOC)
4392a95308bSMatthias Ringwald
4402a95308bSMatthias Ringwald typedef struct {
4412a95308bSMatthias Ringwald btstack_memory_buffer_t tracking;
442798bd46fSMatthias Ringwald rfcomm_channel_t data;
4432a95308bSMatthias Ringwald } btstack_memory_rfcomm_channel_t;
4442a95308bSMatthias Ringwald
btstack_memory_rfcomm_channel_get(void)4456527a633S[email protected] rfcomm_channel_t * btstack_memory_rfcomm_channel_get(void){
4462a95308bSMatthias Ringwald btstack_memory_rfcomm_channel_t * buffer = (btstack_memory_rfcomm_channel_t *) malloc(sizeof(btstack_memory_rfcomm_channel_t));
447a2673d88SMatthias Ringwald if (buffer){
448798bd46fSMatthias Ringwald memset(buffer, 0, sizeof(btstack_memory_rfcomm_channel_t));
4492a95308bSMatthias Ringwald btstack_memory_tracking_add(&buffer->tracking);
4502a95308bSMatthias Ringwald return &buffer->data;
451b6269742SMatthias Ringwald } else {
452b6269742SMatthias Ringwald return NULL;
453a2673d88SMatthias Ringwald }
454a3b02b71Smatthias.ringwald }
btstack_memory_rfcomm_channel_free(rfcomm_channel_t * rfcomm_channel)4556527a633S[email protected] void btstack_memory_rfcomm_channel_free(rfcomm_channel_t *rfcomm_channel){
456798bd46fSMatthias Ringwald // reconstruct buffer start
457798bd46fSMatthias Ringwald btstack_memory_buffer_t * buffer = &((btstack_memory_buffer_t *) rfcomm_channel)[-1];
458798bd46fSMatthias Ringwald btstack_memory_tracking_remove(buffer);
459b6269742SMatthias Ringwald free(buffer);
460a3b02b71Smatthias.ringwald }
461a3b02b71Smatthias.ringwald #endif
462a3b02b71Smatthias.ringwald
463fdb398c2S[email protected]
464e0e5e285Smatthias.ringwald
4652c455dadSMatthias Ringwald // MARK: btstack_link_key_db_memory_entry_t
466a265b909SMatthias Ringwald #if !defined(HAVE_MALLOC) && !defined(MAX_NR_BTSTACK_LINK_KEY_DB_MEMORY_ENTRIES)
467a265b909SMatthias Ringwald #if defined(MAX_NO_BTSTACK_LINK_KEY_DB_MEMORY_ENTRIES)
46827faf85aSMilanka Ringwald #error "Deprecated MAX_NO_BTSTACK_LINK_KEY_DB_MEMORY_ENTRIES defined instead of MAX_NR_BTSTACK_LINK_KEY_DB_MEMORY_ENTRIES. Please update your btstack_config.h to use MAX_NR_BTSTACK_LINK_KEY_DB_MEMORY_ENTRIES."
469a265b909SMatthias Ringwald #else
470a265b909SMatthias Ringwald #define MAX_NR_BTSTACK_LINK_KEY_DB_MEMORY_ENTRIES 0
471a265b909SMatthias Ringwald #endif
472a265b909SMatthias Ringwald #endif
473a265b909SMatthias Ringwald
474a265b909SMatthias Ringwald #ifdef MAX_NR_BTSTACK_LINK_KEY_DB_MEMORY_ENTRIES
475a265b909SMatthias Ringwald #if MAX_NR_BTSTACK_LINK_KEY_DB_MEMORY_ENTRIES > 0
476a265b909SMatthias Ringwald static btstack_link_key_db_memory_entry_t btstack_link_key_db_memory_entry_storage[MAX_NR_BTSTACK_LINK_KEY_DB_MEMORY_ENTRIES];
4772c455dadSMatthias Ringwald static btstack_memory_pool_t btstack_link_key_db_memory_entry_pool;
btstack_memory_btstack_link_key_db_memory_entry_get(void)4782c455dadSMatthias Ringwald btstack_link_key_db_memory_entry_t * btstack_memory_btstack_link_key_db_memory_entry_get(void){
479a2673d88SMatthias Ringwald void * buffer = btstack_memory_pool_get(&btstack_link_key_db_memory_entry_pool);
480a2673d88SMatthias Ringwald if (buffer){
481a2673d88SMatthias Ringwald memset(buffer, 0, sizeof(btstack_link_key_db_memory_entry_t));
482a2673d88SMatthias Ringwald }
483a2673d88SMatthias Ringwald return (btstack_link_key_db_memory_entry_t *) buffer;
4841801b596Smatthias.ringwald }
btstack_memory_btstack_link_key_db_memory_entry_free(btstack_link_key_db_memory_entry_t * btstack_link_key_db_memory_entry)4852c455dadSMatthias Ringwald void btstack_memory_btstack_link_key_db_memory_entry_free(btstack_link_key_db_memory_entry_t *btstack_link_key_db_memory_entry){
4862c455dadSMatthias Ringwald btstack_memory_pool_free(&btstack_link_key_db_memory_entry_pool, btstack_link_key_db_memory_entry);
4871801b596Smatthias.ringwald }
488c4d3f927Smatthias.ringwald #else
btstack_memory_btstack_link_key_db_memory_entry_get(void)4892c455dadSMatthias Ringwald btstack_link_key_db_memory_entry_t * btstack_memory_btstack_link_key_db_memory_entry_get(void){
490c4d3f927Smatthias.ringwald return NULL;
491c4d3f927Smatthias.ringwald }
btstack_memory_btstack_link_key_db_memory_entry_free(btstack_link_key_db_memory_entry_t * btstack_link_key_db_memory_entry)4922c455dadSMatthias Ringwald void btstack_memory_btstack_link_key_db_memory_entry_free(btstack_link_key_db_memory_entry_t *btstack_link_key_db_memory_entry){
493b6269742SMatthias Ringwald UNUSED(btstack_link_key_db_memory_entry);
494*42a2bbebSMatthias Ringwald }
495c4d3f927Smatthias.ringwald #endif
4961801b596Smatthias.ringwald #elif defined(HAVE_MALLOC)
4972a95308bSMatthias Ringwald
4982a95308bSMatthias Ringwald typedef struct {
4992a95308bSMatthias Ringwald btstack_memory_buffer_t tracking;
500798bd46fSMatthias Ringwald btstack_link_key_db_memory_entry_t data;
5012a95308bSMatthias Ringwald } btstack_memory_btstack_link_key_db_memory_entry_t;
5022a95308bSMatthias Ringwald
btstack_memory_btstack_link_key_db_memory_entry_get(void)5032c455dadSMatthias Ringwald btstack_link_key_db_memory_entry_t * btstack_memory_btstack_link_key_db_memory_entry_get(void){
5042a95308bSMatthias Ringwald 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));
505a2673d88SMatthias Ringwald if (buffer){
506798bd46fSMatthias Ringwald memset(buffer, 0, sizeof(btstack_memory_btstack_link_key_db_memory_entry_t));
5072a95308bSMatthias Ringwald btstack_memory_tracking_add(&buffer->tracking);
5082a95308bSMatthias Ringwald return &buffer->data;
509b6269742SMatthias Ringwald } else {
510b6269742SMatthias Ringwald return NULL;
511a2673d88SMatthias Ringwald }
5121801b596Smatthias.ringwald }
btstack_memory_btstack_link_key_db_memory_entry_free(btstack_link_key_db_memory_entry_t * btstack_link_key_db_memory_entry)5132c455dadSMatthias Ringwald void btstack_memory_btstack_link_key_db_memory_entry_free(btstack_link_key_db_memory_entry_t *btstack_link_key_db_memory_entry){
514798bd46fSMatthias Ringwald // reconstruct buffer start
515798bd46fSMatthias Ringwald btstack_memory_buffer_t * buffer = &((btstack_memory_buffer_t *) btstack_link_key_db_memory_entry)[-1];
516798bd46fSMatthias Ringwald btstack_memory_tracking_remove(buffer);
517b6269742SMatthias Ringwald free(buffer);
518e0e5e285Smatthias.ringwald }
5191801b596Smatthias.ringwald #endif
5201801b596Smatthias.ringwald
5212e97c149S[email protected]
5222e97c149S[email protected]
5232e97c149S[email protected] // MARK: bnep_service_t
524a265b909SMatthias Ringwald #if !defined(HAVE_MALLOC) && !defined(MAX_NR_BNEP_SERVICES)
525a265b909SMatthias Ringwald #if defined(MAX_NO_BNEP_SERVICES)
52627faf85aSMilanka Ringwald #error "Deprecated MAX_NO_BNEP_SERVICES defined instead of MAX_NR_BNEP_SERVICES. Please update your btstack_config.h to use MAX_NR_BNEP_SERVICES."
527a265b909SMatthias Ringwald #else
528a265b909SMatthias Ringwald #define MAX_NR_BNEP_SERVICES 0
529a265b909SMatthias Ringwald #endif
530a265b909SMatthias Ringwald #endif
531a265b909SMatthias Ringwald
532a265b909SMatthias Ringwald #ifdef MAX_NR_BNEP_SERVICES
533a265b909SMatthias Ringwald #if MAX_NR_BNEP_SERVICES > 0
534a265b909SMatthias Ringwald static bnep_service_t bnep_service_storage[MAX_NR_BNEP_SERVICES];
53529d0c4f7SMatthias Ringwald static btstack_memory_pool_t bnep_service_pool;
btstack_memory_bnep_service_get(void)5362e97c149S[email protected] bnep_service_t * btstack_memory_bnep_service_get(void){
537a2673d88SMatthias Ringwald void * buffer = btstack_memory_pool_get(&bnep_service_pool);
538a2673d88SMatthias Ringwald if (buffer){
539a2673d88SMatthias Ringwald memset(buffer, 0, sizeof(bnep_service_t));
540a2673d88SMatthias Ringwald }
541a2673d88SMatthias Ringwald return (bnep_service_t *) buffer;
5422e97c149S[email protected] }
btstack_memory_bnep_service_free(bnep_service_t * bnep_service)5432e97c149S[email protected] void btstack_memory_bnep_service_free(bnep_service_t *bnep_service){
54429d0c4f7SMatthias Ringwald btstack_memory_pool_free(&bnep_service_pool, bnep_service);
5452e97c149S[email protected] }
5462e97c149S[email protected] #else
btstack_memory_bnep_service_get(void)5472e97c149S[email protected] bnep_service_t * btstack_memory_bnep_service_get(void){
5482e97c149S[email protected] return NULL;
5492e97c149S[email protected] }
btstack_memory_bnep_service_free(bnep_service_t * bnep_service)5502e97c149S[email protected] void btstack_memory_bnep_service_free(bnep_service_t *bnep_service){
551b6269742SMatthias Ringwald UNUSED(bnep_service);
552*42a2bbebSMatthias Ringwald }
5532e97c149S[email protected] #endif
5542e97c149S[email protected] #elif defined(HAVE_MALLOC)
5552a95308bSMatthias Ringwald
5562a95308bSMatthias Ringwald typedef struct {
5572a95308bSMatthias Ringwald btstack_memory_buffer_t tracking;
558798bd46fSMatthias Ringwald bnep_service_t data;
5592a95308bSMatthias Ringwald } btstack_memory_bnep_service_t;
5602a95308bSMatthias Ringwald
btstack_memory_bnep_service_get(void)5612e97c149S[email protected] bnep_service_t * btstack_memory_bnep_service_get(void){
5622a95308bSMatthias Ringwald btstack_memory_bnep_service_t * buffer = (btstack_memory_bnep_service_t *) malloc(sizeof(btstack_memory_bnep_service_t));
563a2673d88SMatthias Ringwald if (buffer){
564798bd46fSMatthias Ringwald memset(buffer, 0, sizeof(btstack_memory_bnep_service_t));
5652a95308bSMatthias Ringwald btstack_memory_tracking_add(&buffer->tracking);
5662a95308bSMatthias Ringwald return &buffer->data;
567b6269742SMatthias Ringwald } else {
568b6269742SMatthias Ringwald return NULL;
569a2673d88SMatthias Ringwald }
5702e97c149S[email protected] }
btstack_memory_bnep_service_free(bnep_service_t * bnep_service)5712e97c149S[email protected] void btstack_memory_bnep_service_free(bnep_service_t *bnep_service){
572798bd46fSMatthias Ringwald // reconstruct buffer start
573798bd46fSMatthias Ringwald btstack_memory_buffer_t * buffer = &((btstack_memory_buffer_t *) bnep_service)[-1];
574798bd46fSMatthias Ringwald btstack_memory_tracking_remove(buffer);
575b6269742SMatthias Ringwald free(buffer);
5762e97c149S[email protected] }
5772e97c149S[email protected] #endif
5782e97c149S[email protected]
5792e97c149S[email protected]
5802e97c149S[email protected] // MARK: bnep_channel_t
581a265b909SMatthias Ringwald #if !defined(HAVE_MALLOC) && !defined(MAX_NR_BNEP_CHANNELS)
582a265b909SMatthias Ringwald #if defined(MAX_NO_BNEP_CHANNELS)
58327faf85aSMilanka Ringwald #error "Deprecated MAX_NO_BNEP_CHANNELS defined instead of MAX_NR_BNEP_CHANNELS. Please update your btstack_config.h to use MAX_NR_BNEP_CHANNELS."
584a265b909SMatthias Ringwald #else
585a265b909SMatthias Ringwald #define MAX_NR_BNEP_CHANNELS 0
586a265b909SMatthias Ringwald #endif
587a265b909SMatthias Ringwald #endif
588a265b909SMatthias Ringwald
589a265b909SMatthias Ringwald #ifdef MAX_NR_BNEP_CHANNELS
590a265b909SMatthias Ringwald #if MAX_NR_BNEP_CHANNELS > 0
591a265b909SMatthias Ringwald static bnep_channel_t bnep_channel_storage[MAX_NR_BNEP_CHANNELS];
59229d0c4f7SMatthias Ringwald static btstack_memory_pool_t bnep_channel_pool;
btstack_memory_bnep_channel_get(void)5932e97c149S[email protected] bnep_channel_t * btstack_memory_bnep_channel_get(void){
594a2673d88SMatthias Ringwald void * buffer = btstack_memory_pool_get(&bnep_channel_pool);
595a2673d88SMatthias Ringwald if (buffer){
596a2673d88SMatthias Ringwald memset(buffer, 0, sizeof(bnep_channel_t));
597a2673d88SMatthias Ringwald }
598a2673d88SMatthias Ringwald return (bnep_channel_t *) buffer;
5992e97c149S[email protected] }
btstack_memory_bnep_channel_free(bnep_channel_t * bnep_channel)6002e97c149S[email protected] void btstack_memory_bnep_channel_free(bnep_channel_t *bnep_channel){
60129d0c4f7SMatthias Ringwald btstack_memory_pool_free(&bnep_channel_pool, bnep_channel);
6022e97c149S[email protected] }
6032e97c149S[email protected] #else
btstack_memory_bnep_channel_get(void)6042e97c149S[email protected] bnep_channel_t * btstack_memory_bnep_channel_get(void){
6052e97c149S[email protected] return NULL;
6062e97c149S[email protected] }
btstack_memory_bnep_channel_free(bnep_channel_t * bnep_channel)6072e97c149S[email protected] void btstack_memory_bnep_channel_free(bnep_channel_t *bnep_channel){
608b6269742SMatthias Ringwald UNUSED(bnep_channel);
609*42a2bbebSMatthias Ringwald }
6102e97c149S[email protected] #endif
6112e97c149S[email protected] #elif defined(HAVE_MALLOC)
6122a95308bSMatthias Ringwald
6132a95308bSMatthias Ringwald typedef struct {
6142a95308bSMatthias Ringwald btstack_memory_buffer_t tracking;
615798bd46fSMatthias Ringwald bnep_channel_t data;
6162a95308bSMatthias Ringwald } btstack_memory_bnep_channel_t;
6172a95308bSMatthias Ringwald
btstack_memory_bnep_channel_get(void)6182e97c149S[email protected] bnep_channel_t * btstack_memory_bnep_channel_get(void){
6192a95308bSMatthias Ringwald btstack_memory_bnep_channel_t * buffer = (btstack_memory_bnep_channel_t *) malloc(sizeof(btstack_memory_bnep_channel_t));
620a2673d88SMatthias Ringwald if (buffer){
621798bd46fSMatthias Ringwald memset(buffer, 0, sizeof(btstack_memory_bnep_channel_t));
6222a95308bSMatthias Ringwald btstack_memory_tracking_add(&buffer->tracking);
6232a95308bSMatthias Ringwald return &buffer->data;
624b6269742SMatthias Ringwald } else {
625b6269742SMatthias Ringwald return NULL;
626a2673d88SMatthias Ringwald }
6272e97c149S[email protected] }
btstack_memory_bnep_channel_free(bnep_channel_t * bnep_channel)6282e97c149S[email protected] void btstack_memory_bnep_channel_free(bnep_channel_t *bnep_channel){
629798bd46fSMatthias Ringwald // reconstruct buffer start
630798bd46fSMatthias Ringwald btstack_memory_buffer_t * buffer = &((btstack_memory_buffer_t *) bnep_channel)[-1];
631798bd46fSMatthias Ringwald btstack_memory_tracking_remove(buffer);
632b6269742SMatthias Ringwald free(buffer);
6332e97c149S[email protected] }
6342e97c149S[email protected] #endif
6352e97c149S[email protected]
6362e97c149S[email protected]
637ea5029c9SMilanka Ringwald
638b8c00949SMatthias Ringwald // MARK: goep_server_service_t
639b8c00949SMatthias Ringwald #if !defined(HAVE_MALLOC) && !defined(MAX_NR_GOEP_SERVER_SERVICES)
640b8c00949SMatthias Ringwald #if defined(MAX_NO_GOEP_SERVER_SERVICES)
641b8c00949SMatthias Ringwald #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."
642b8c00949SMatthias Ringwald #else
643b8c00949SMatthias Ringwald #define MAX_NR_GOEP_SERVER_SERVICES 0
644b8c00949SMatthias Ringwald #endif
645b8c00949SMatthias Ringwald #endif
646b8c00949SMatthias Ringwald
647b8c00949SMatthias Ringwald #ifdef MAX_NR_GOEP_SERVER_SERVICES
648b8c00949SMatthias Ringwald #if MAX_NR_GOEP_SERVER_SERVICES > 0
649b8c00949SMatthias Ringwald static goep_server_service_t goep_server_service_storage[MAX_NR_GOEP_SERVER_SERVICES];
650b8c00949SMatthias Ringwald static btstack_memory_pool_t goep_server_service_pool;
btstack_memory_goep_server_service_get(void)651b8c00949SMatthias Ringwald goep_server_service_t * btstack_memory_goep_server_service_get(void){
652b8c00949SMatthias Ringwald void * buffer = btstack_memory_pool_get(&goep_server_service_pool);
653b8c00949SMatthias Ringwald if (buffer){
654b8c00949SMatthias Ringwald memset(buffer, 0, sizeof(goep_server_service_t));
655b8c00949SMatthias Ringwald }
656b8c00949SMatthias Ringwald return (goep_server_service_t *) buffer;
657b8c00949SMatthias Ringwald }
btstack_memory_goep_server_service_free(goep_server_service_t * goep_server_service)658b8c00949SMatthias Ringwald void btstack_memory_goep_server_service_free(goep_server_service_t *goep_server_service){
659b8c00949SMatthias Ringwald btstack_memory_pool_free(&goep_server_service_pool, goep_server_service);
660b8c00949SMatthias Ringwald }
661b8c00949SMatthias Ringwald #else
btstack_memory_goep_server_service_get(void)662b8c00949SMatthias Ringwald goep_server_service_t * btstack_memory_goep_server_service_get(void){
663b8c00949SMatthias Ringwald return NULL;
664b8c00949SMatthias Ringwald }
btstack_memory_goep_server_service_free(goep_server_service_t * goep_server_service)665b8c00949SMatthias Ringwald void btstack_memory_goep_server_service_free(goep_server_service_t *goep_server_service){
666b8c00949SMatthias Ringwald UNUSED(goep_server_service);
667*42a2bbebSMatthias Ringwald }
668b8c00949SMatthias Ringwald #endif
669b8c00949SMatthias Ringwald #elif defined(HAVE_MALLOC)
670b8c00949SMatthias Ringwald
671b8c00949SMatthias Ringwald typedef struct {
672b8c00949SMatthias Ringwald btstack_memory_buffer_t tracking;
673b8c00949SMatthias Ringwald goep_server_service_t data;
674b8c00949SMatthias Ringwald } btstack_memory_goep_server_service_t;
675b8c00949SMatthias Ringwald
btstack_memory_goep_server_service_get(void)676b8c00949SMatthias Ringwald goep_server_service_t * btstack_memory_goep_server_service_get(void){
677b8c00949SMatthias Ringwald btstack_memory_goep_server_service_t * buffer = (btstack_memory_goep_server_service_t *) malloc(sizeof(btstack_memory_goep_server_service_t));
678b8c00949SMatthias Ringwald if (buffer){
679b8c00949SMatthias Ringwald memset(buffer, 0, sizeof(btstack_memory_goep_server_service_t));
680b8c00949SMatthias Ringwald btstack_memory_tracking_add(&buffer->tracking);
681b8c00949SMatthias Ringwald return &buffer->data;
682b8c00949SMatthias Ringwald } else {
683b8c00949SMatthias Ringwald return NULL;
684b8c00949SMatthias Ringwald }
685b8c00949SMatthias Ringwald }
btstack_memory_goep_server_service_free(goep_server_service_t * goep_server_service)686b8c00949SMatthias Ringwald void btstack_memory_goep_server_service_free(goep_server_service_t *goep_server_service){
687b8c00949SMatthias Ringwald // reconstruct buffer start
688b8c00949SMatthias Ringwald btstack_memory_buffer_t * buffer = &((btstack_memory_buffer_t *) goep_server_service)[-1];
689b8c00949SMatthias Ringwald btstack_memory_tracking_remove(buffer);
690b8c00949SMatthias Ringwald free(buffer);
691b8c00949SMatthias Ringwald }
692b8c00949SMatthias Ringwald #endif
693b8c00949SMatthias Ringwald
694b8c00949SMatthias Ringwald
695b8c00949SMatthias Ringwald // MARK: goep_server_connection_t
696b8c00949SMatthias Ringwald #if !defined(HAVE_MALLOC) && !defined(MAX_NR_GOEP_SERVER_CONNECTIONS)
697b8c00949SMatthias Ringwald #if defined(MAX_NO_GOEP_SERVER_CONNECTIONS)
698b8c00949SMatthias Ringwald #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."
699b8c00949SMatthias Ringwald #else
700b8c00949SMatthias Ringwald #define MAX_NR_GOEP_SERVER_CONNECTIONS 0
701b8c00949SMatthias Ringwald #endif
702b8c00949SMatthias Ringwald #endif
703b8c00949SMatthias Ringwald
704b8c00949SMatthias Ringwald #ifdef MAX_NR_GOEP_SERVER_CONNECTIONS
705b8c00949SMatthias Ringwald #if MAX_NR_GOEP_SERVER_CONNECTIONS > 0
706b8c00949SMatthias Ringwald static goep_server_connection_t goep_server_connection_storage[MAX_NR_GOEP_SERVER_CONNECTIONS];
707b8c00949SMatthias Ringwald static btstack_memory_pool_t goep_server_connection_pool;
btstack_memory_goep_server_connection_get(void)708b8c00949SMatthias Ringwald goep_server_connection_t * btstack_memory_goep_server_connection_get(void){
709b8c00949SMatthias Ringwald void * buffer = btstack_memory_pool_get(&goep_server_connection_pool);
710b8c00949SMatthias Ringwald if (buffer){
711b8c00949SMatthias Ringwald memset(buffer, 0, sizeof(goep_server_connection_t));
712b8c00949SMatthias Ringwald }
713b8c00949SMatthias Ringwald return (goep_server_connection_t *) buffer;
714b8c00949SMatthias Ringwald }
btstack_memory_goep_server_connection_free(goep_server_connection_t * goep_server_connection)715b8c00949SMatthias Ringwald void btstack_memory_goep_server_connection_free(goep_server_connection_t *goep_server_connection){
716b8c00949SMatthias Ringwald btstack_memory_pool_free(&goep_server_connection_pool, goep_server_connection);
717b8c00949SMatthias Ringwald }
718b8c00949SMatthias Ringwald #else
btstack_memory_goep_server_connection_get(void)719b8c00949SMatthias Ringwald goep_server_connection_t * btstack_memory_goep_server_connection_get(void){
720b8c00949SMatthias Ringwald return NULL;
721b8c00949SMatthias Ringwald }
btstack_memory_goep_server_connection_free(goep_server_connection_t * goep_server_connection)722b8c00949SMatthias Ringwald void btstack_memory_goep_server_connection_free(goep_server_connection_t *goep_server_connection){
723b8c00949SMatthias Ringwald UNUSED(goep_server_connection);
724*42a2bbebSMatthias Ringwald }
725b8c00949SMatthias Ringwald #endif
726b8c00949SMatthias Ringwald #elif defined(HAVE_MALLOC)
727b8c00949SMatthias Ringwald
728b8c00949SMatthias Ringwald typedef struct {
729b8c00949SMatthias Ringwald btstack_memory_buffer_t tracking;
730b8c00949SMatthias Ringwald goep_server_connection_t data;
731b8c00949SMatthias Ringwald } btstack_memory_goep_server_connection_t;
732b8c00949SMatthias Ringwald
btstack_memory_goep_server_connection_get(void)733b8c00949SMatthias Ringwald goep_server_connection_t * btstack_memory_goep_server_connection_get(void){
734b8c00949SMatthias Ringwald btstack_memory_goep_server_connection_t * buffer = (btstack_memory_goep_server_connection_t *) malloc(sizeof(btstack_memory_goep_server_connection_t));
735b8c00949SMatthias Ringwald if (buffer){
736b8c00949SMatthias Ringwald memset(buffer, 0, sizeof(btstack_memory_goep_server_connection_t));
737b8c00949SMatthias Ringwald btstack_memory_tracking_add(&buffer->tracking);
738b8c00949SMatthias Ringwald return &buffer->data;
739b8c00949SMatthias Ringwald } else {
740b8c00949SMatthias Ringwald return NULL;
741b8c00949SMatthias Ringwald }
742b8c00949SMatthias Ringwald }
btstack_memory_goep_server_connection_free(goep_server_connection_t * goep_server_connection)743b8c00949SMatthias Ringwald void btstack_memory_goep_server_connection_free(goep_server_connection_t *goep_server_connection){
744b8c00949SMatthias Ringwald // reconstruct buffer start
745b8c00949SMatthias Ringwald btstack_memory_buffer_t * buffer = &((btstack_memory_buffer_t *) goep_server_connection)[-1];
746b8c00949SMatthias Ringwald btstack_memory_tracking_remove(buffer);
747b8c00949SMatthias Ringwald free(buffer);
748b8c00949SMatthias Ringwald }
749b8c00949SMatthias Ringwald #endif
750b8c00949SMatthias Ringwald
751b8c00949SMatthias Ringwald
752b8c00949SMatthias Ringwald
753ea5029c9SMilanka Ringwald // MARK: hfp_connection_t
754a265b909SMatthias Ringwald #if !defined(HAVE_MALLOC) && !defined(MAX_NR_HFP_CONNECTIONS)
755a265b909SMatthias Ringwald #if defined(MAX_NO_HFP_CONNECTIONS)
75627faf85aSMilanka Ringwald #error "Deprecated MAX_NO_HFP_CONNECTIONS defined instead of MAX_NR_HFP_CONNECTIONS. Please update your btstack_config.h to use MAX_NR_HFP_CONNECTIONS."
757a265b909SMatthias Ringwald #else
758a265b909SMatthias Ringwald #define MAX_NR_HFP_CONNECTIONS 0
759a265b909SMatthias Ringwald #endif
760a265b909SMatthias Ringwald #endif
761a265b909SMatthias Ringwald
762a265b909SMatthias Ringwald #ifdef MAX_NR_HFP_CONNECTIONS
763a265b909SMatthias Ringwald #if MAX_NR_HFP_CONNECTIONS > 0
764a265b909SMatthias Ringwald static hfp_connection_t hfp_connection_storage[MAX_NR_HFP_CONNECTIONS];
76529d0c4f7SMatthias Ringwald static btstack_memory_pool_t hfp_connection_pool;
btstack_memory_hfp_connection_get(void)766ea5029c9SMilanka Ringwald hfp_connection_t * btstack_memory_hfp_connection_get(void){
767a2673d88SMatthias Ringwald void * buffer = btstack_memory_pool_get(&hfp_connection_pool);
768a2673d88SMatthias Ringwald if (buffer){
769a2673d88SMatthias Ringwald memset(buffer, 0, sizeof(hfp_connection_t));
770a2673d88SMatthias Ringwald }
771a2673d88SMatthias Ringwald return (hfp_connection_t *) buffer;
772ea5029c9SMilanka Ringwald }
btstack_memory_hfp_connection_free(hfp_connection_t * hfp_connection)773ea5029c9SMilanka Ringwald void btstack_memory_hfp_connection_free(hfp_connection_t *hfp_connection){
77429d0c4f7SMatthias Ringwald btstack_memory_pool_free(&hfp_connection_pool, hfp_connection);
775ea5029c9SMilanka Ringwald }
776ea5029c9SMilanka Ringwald #else
btstack_memory_hfp_connection_get(void)777ea5029c9SMilanka Ringwald hfp_connection_t * btstack_memory_hfp_connection_get(void){
778ea5029c9SMilanka Ringwald return NULL;
779ea5029c9SMilanka Ringwald }
btstack_memory_hfp_connection_free(hfp_connection_t * hfp_connection)780ea5029c9SMilanka Ringwald void btstack_memory_hfp_connection_free(hfp_connection_t *hfp_connection){
781b6269742SMatthias Ringwald UNUSED(hfp_connection);
782*42a2bbebSMatthias Ringwald }
783ea5029c9SMilanka Ringwald #endif
784ea5029c9SMilanka Ringwald #elif defined(HAVE_MALLOC)
7852a95308bSMatthias Ringwald
7862a95308bSMatthias Ringwald typedef struct {
7872a95308bSMatthias Ringwald btstack_memory_buffer_t tracking;
788798bd46fSMatthias Ringwald hfp_connection_t data;
7892a95308bSMatthias Ringwald } btstack_memory_hfp_connection_t;
7902a95308bSMatthias Ringwald
btstack_memory_hfp_connection_get(void)791ea5029c9SMilanka Ringwald hfp_connection_t * btstack_memory_hfp_connection_get(void){
7922a95308bSMatthias Ringwald btstack_memory_hfp_connection_t * buffer = (btstack_memory_hfp_connection_t *) malloc(sizeof(btstack_memory_hfp_connection_t));
793a2673d88SMatthias Ringwald if (buffer){
794798bd46fSMatthias Ringwald memset(buffer, 0, sizeof(btstack_memory_hfp_connection_t));
7952a95308bSMatthias Ringwald btstack_memory_tracking_add(&buffer->tracking);
7962a95308bSMatthias Ringwald return &buffer->data;
797b6269742SMatthias Ringwald } else {
798b6269742SMatthias Ringwald return NULL;
799a2673d88SMatthias Ringwald }
800ea5029c9SMilanka Ringwald }
btstack_memory_hfp_connection_free(hfp_connection_t * hfp_connection)801ea5029c9SMilanka Ringwald void btstack_memory_hfp_connection_free(hfp_connection_t *hfp_connection){
802798bd46fSMatthias Ringwald // reconstruct buffer start
803798bd46fSMatthias Ringwald btstack_memory_buffer_t * buffer = &((btstack_memory_buffer_t *) hfp_connection)[-1];
804798bd46fSMatthias Ringwald btstack_memory_tracking_remove(buffer);
805b6269742SMatthias Ringwald free(buffer);
806ea5029c9SMilanka Ringwald }
807ea5029c9SMilanka Ringwald #endif
808ea5029c9SMilanka Ringwald
809ea5029c9SMilanka Ringwald
810cd9ee144SMatthias Ringwald
811f399f7fbSMilanka Ringwald // MARK: hid_host_connection_t
812f399f7fbSMilanka Ringwald #if !defined(HAVE_MALLOC) && !defined(MAX_NR_HID_HOST_CONNECTIONS)
813f399f7fbSMilanka Ringwald #if defined(MAX_NO_HID_HOST_CONNECTIONS)
814f399f7fbSMilanka Ringwald #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."
815f399f7fbSMilanka Ringwald #else
816f399f7fbSMilanka Ringwald #define MAX_NR_HID_HOST_CONNECTIONS 0
817f399f7fbSMilanka Ringwald #endif
818f399f7fbSMilanka Ringwald #endif
819f399f7fbSMilanka Ringwald
820f399f7fbSMilanka Ringwald #ifdef MAX_NR_HID_HOST_CONNECTIONS
821f399f7fbSMilanka Ringwald #if MAX_NR_HID_HOST_CONNECTIONS > 0
822f399f7fbSMilanka Ringwald static hid_host_connection_t hid_host_connection_storage[MAX_NR_HID_HOST_CONNECTIONS];
823f399f7fbSMilanka Ringwald static btstack_memory_pool_t hid_host_connection_pool;
btstack_memory_hid_host_connection_get(void)824f399f7fbSMilanka Ringwald hid_host_connection_t * btstack_memory_hid_host_connection_get(void){
825f399f7fbSMilanka Ringwald void * buffer = btstack_memory_pool_get(&hid_host_connection_pool);
826f399f7fbSMilanka Ringwald if (buffer){
827f399f7fbSMilanka Ringwald memset(buffer, 0, sizeof(hid_host_connection_t));
828f399f7fbSMilanka Ringwald }
829f399f7fbSMilanka Ringwald return (hid_host_connection_t *) buffer;
830f399f7fbSMilanka Ringwald }
btstack_memory_hid_host_connection_free(hid_host_connection_t * hid_host_connection)831f399f7fbSMilanka Ringwald void btstack_memory_hid_host_connection_free(hid_host_connection_t *hid_host_connection){
832f399f7fbSMilanka Ringwald btstack_memory_pool_free(&hid_host_connection_pool, hid_host_connection);
833f399f7fbSMilanka Ringwald }
834f399f7fbSMilanka Ringwald #else
btstack_memory_hid_host_connection_get(void)835f399f7fbSMilanka Ringwald hid_host_connection_t * btstack_memory_hid_host_connection_get(void){
836f399f7fbSMilanka Ringwald return NULL;
837f399f7fbSMilanka Ringwald }
btstack_memory_hid_host_connection_free(hid_host_connection_t * hid_host_connection)838f399f7fbSMilanka Ringwald void btstack_memory_hid_host_connection_free(hid_host_connection_t *hid_host_connection){
839174a0c1cSMilanka Ringwald UNUSED(hid_host_connection);
840*42a2bbebSMatthias Ringwald }
841f399f7fbSMilanka Ringwald #endif
842f399f7fbSMilanka Ringwald #elif defined(HAVE_MALLOC)
843174a0c1cSMilanka Ringwald
844174a0c1cSMilanka Ringwald typedef struct {
845174a0c1cSMilanka Ringwald btstack_memory_buffer_t tracking;
846174a0c1cSMilanka Ringwald hid_host_connection_t data;
847174a0c1cSMilanka Ringwald } btstack_memory_hid_host_connection_t;
848174a0c1cSMilanka Ringwald
btstack_memory_hid_host_connection_get(void)849f399f7fbSMilanka Ringwald hid_host_connection_t * btstack_memory_hid_host_connection_get(void){
850174a0c1cSMilanka Ringwald btstack_memory_hid_host_connection_t * buffer = (btstack_memory_hid_host_connection_t *) malloc(sizeof(btstack_memory_hid_host_connection_t));
851f399f7fbSMilanka Ringwald if (buffer){
852174a0c1cSMilanka Ringwald memset(buffer, 0, sizeof(btstack_memory_hid_host_connection_t));
853174a0c1cSMilanka Ringwald btstack_memory_tracking_add(&buffer->tracking);
854174a0c1cSMilanka Ringwald return &buffer->data;
855174a0c1cSMilanka Ringwald } else {
856174a0c1cSMilanka Ringwald return NULL;
857f399f7fbSMilanka Ringwald }
858f399f7fbSMilanka Ringwald }
btstack_memory_hid_host_connection_free(hid_host_connection_t * hid_host_connection)859f399f7fbSMilanka Ringwald void btstack_memory_hid_host_connection_free(hid_host_connection_t *hid_host_connection){
860174a0c1cSMilanka Ringwald // reconstruct buffer start
861174a0c1cSMilanka Ringwald btstack_memory_buffer_t * buffer = &((btstack_memory_buffer_t *) hid_host_connection)[-1];
862174a0c1cSMilanka Ringwald btstack_memory_tracking_remove(buffer);
863174a0c1cSMilanka Ringwald free(buffer);
864f399f7fbSMilanka Ringwald }
865f399f7fbSMilanka Ringwald #endif
866f399f7fbSMilanka Ringwald
867f399f7fbSMilanka Ringwald
868f399f7fbSMilanka Ringwald
8696fd2a92aSMatthias Ringwald // MARK: service_record_item_t
8706fd2a92aSMatthias Ringwald #if !defined(HAVE_MALLOC) && !defined(MAX_NR_SERVICE_RECORD_ITEMS)
8716fd2a92aSMatthias Ringwald #if defined(MAX_NO_SERVICE_RECORD_ITEMS)
8726fd2a92aSMatthias Ringwald #error "Deprecated MAX_NO_SERVICE_RECORD_ITEMS defined instead of MAX_NR_SERVICE_RECORD_ITEMS. Please update your btstack_config.h to use MAX_NR_SERVICE_RECORD_ITEMS."
8736fd2a92aSMatthias Ringwald #else
8746fd2a92aSMatthias Ringwald #define MAX_NR_SERVICE_RECORD_ITEMS 0
8756fd2a92aSMatthias Ringwald #endif
8766fd2a92aSMatthias Ringwald #endif
8776fd2a92aSMatthias Ringwald
8786fd2a92aSMatthias Ringwald #ifdef MAX_NR_SERVICE_RECORD_ITEMS
8796fd2a92aSMatthias Ringwald #if MAX_NR_SERVICE_RECORD_ITEMS > 0
8806fd2a92aSMatthias Ringwald static service_record_item_t service_record_item_storage[MAX_NR_SERVICE_RECORD_ITEMS];
8816fd2a92aSMatthias Ringwald static btstack_memory_pool_t service_record_item_pool;
btstack_memory_service_record_item_get(void)8826fd2a92aSMatthias Ringwald service_record_item_t * btstack_memory_service_record_item_get(void){
8836fd2a92aSMatthias Ringwald void * buffer = btstack_memory_pool_get(&service_record_item_pool);
8846fd2a92aSMatthias Ringwald if (buffer){
8856fd2a92aSMatthias Ringwald memset(buffer, 0, sizeof(service_record_item_t));
8866fd2a92aSMatthias Ringwald }
8876fd2a92aSMatthias Ringwald return (service_record_item_t *) buffer;
8886fd2a92aSMatthias Ringwald }
btstack_memory_service_record_item_free(service_record_item_t * service_record_item)8896fd2a92aSMatthias Ringwald void btstack_memory_service_record_item_free(service_record_item_t *service_record_item){
8906fd2a92aSMatthias Ringwald btstack_memory_pool_free(&service_record_item_pool, service_record_item);
8916fd2a92aSMatthias Ringwald }
8926fd2a92aSMatthias Ringwald #else
btstack_memory_service_record_item_get(void)8936fd2a92aSMatthias Ringwald service_record_item_t * btstack_memory_service_record_item_get(void){
8946fd2a92aSMatthias Ringwald return NULL;
8956fd2a92aSMatthias Ringwald }
btstack_memory_service_record_item_free(service_record_item_t * service_record_item)8966fd2a92aSMatthias Ringwald void btstack_memory_service_record_item_free(service_record_item_t *service_record_item){
8976fd2a92aSMatthias Ringwald UNUSED(service_record_item);
898*42a2bbebSMatthias Ringwald }
8996fd2a92aSMatthias Ringwald #endif
9006fd2a92aSMatthias Ringwald #elif defined(HAVE_MALLOC)
9016fd2a92aSMatthias Ringwald
9026fd2a92aSMatthias Ringwald typedef struct {
9036fd2a92aSMatthias Ringwald btstack_memory_buffer_t tracking;
9046fd2a92aSMatthias Ringwald service_record_item_t data;
9056fd2a92aSMatthias Ringwald } btstack_memory_service_record_item_t;
9066fd2a92aSMatthias Ringwald
btstack_memory_service_record_item_get(void)9076fd2a92aSMatthias Ringwald service_record_item_t * btstack_memory_service_record_item_get(void){
9086fd2a92aSMatthias Ringwald btstack_memory_service_record_item_t * buffer = (btstack_memory_service_record_item_t *) malloc(sizeof(btstack_memory_service_record_item_t));
9096fd2a92aSMatthias Ringwald if (buffer){
9106fd2a92aSMatthias Ringwald memset(buffer, 0, sizeof(btstack_memory_service_record_item_t));
9116fd2a92aSMatthias Ringwald btstack_memory_tracking_add(&buffer->tracking);
9126fd2a92aSMatthias Ringwald return &buffer->data;
9136fd2a92aSMatthias Ringwald } else {
9146fd2a92aSMatthias Ringwald return NULL;
9156fd2a92aSMatthias Ringwald }
9166fd2a92aSMatthias Ringwald }
btstack_memory_service_record_item_free(service_record_item_t * service_record_item)9176fd2a92aSMatthias Ringwald void btstack_memory_service_record_item_free(service_record_item_t *service_record_item){
9186fd2a92aSMatthias Ringwald // reconstruct buffer start
9196fd2a92aSMatthias Ringwald btstack_memory_buffer_t * buffer = &((btstack_memory_buffer_t *) service_record_item)[-1];
9206fd2a92aSMatthias Ringwald btstack_memory_tracking_remove(buffer);
9216fd2a92aSMatthias Ringwald free(buffer);
9226fd2a92aSMatthias Ringwald }
9236fd2a92aSMatthias Ringwald #endif
9246fd2a92aSMatthias Ringwald
9256fd2a92aSMatthias Ringwald
9266fd2a92aSMatthias Ringwald
9270e826a17SMilanka Ringwald // MARK: avdtp_stream_endpoint_t
9280e826a17SMilanka Ringwald #if !defined(HAVE_MALLOC) && !defined(MAX_NR_AVDTP_STREAM_ENDPOINTS)
9290e826a17SMilanka Ringwald #if defined(MAX_NO_AVDTP_STREAM_ENDPOINTS)
9300e826a17SMilanka Ringwald #error "Deprecated MAX_NO_AVDTP_STREAM_ENDPOINTS defined instead of MAX_NR_AVDTP_STREAM_ENDPOINTS. Please update your btstack_config.h to use MAX_NR_AVDTP_STREAM_ENDPOINTS."
93127faf85aSMilanka Ringwald #else
9320e826a17SMilanka Ringwald #define MAX_NR_AVDTP_STREAM_ENDPOINTS 0
93327faf85aSMilanka Ringwald #endif
93427faf85aSMilanka Ringwald #endif
93527faf85aSMilanka Ringwald
9360e826a17SMilanka Ringwald #ifdef MAX_NR_AVDTP_STREAM_ENDPOINTS
9370e826a17SMilanka Ringwald #if MAX_NR_AVDTP_STREAM_ENDPOINTS > 0
9380e826a17SMilanka Ringwald static avdtp_stream_endpoint_t avdtp_stream_endpoint_storage[MAX_NR_AVDTP_STREAM_ENDPOINTS];
9390e826a17SMilanka Ringwald static btstack_memory_pool_t avdtp_stream_endpoint_pool;
btstack_memory_avdtp_stream_endpoint_get(void)9400e826a17SMilanka Ringwald avdtp_stream_endpoint_t * btstack_memory_avdtp_stream_endpoint_get(void){
941a2673d88SMatthias Ringwald void * buffer = btstack_memory_pool_get(&avdtp_stream_endpoint_pool);
942a2673d88SMatthias Ringwald if (buffer){
943a2673d88SMatthias Ringwald memset(buffer, 0, sizeof(avdtp_stream_endpoint_t));
944a2673d88SMatthias Ringwald }
945a2673d88SMatthias Ringwald return (avdtp_stream_endpoint_t *) buffer;
94627faf85aSMilanka Ringwald }
btstack_memory_avdtp_stream_endpoint_free(avdtp_stream_endpoint_t * avdtp_stream_endpoint)9470e826a17SMilanka Ringwald void btstack_memory_avdtp_stream_endpoint_free(avdtp_stream_endpoint_t *avdtp_stream_endpoint){
9480e826a17SMilanka Ringwald btstack_memory_pool_free(&avdtp_stream_endpoint_pool, avdtp_stream_endpoint);
94927faf85aSMilanka Ringwald }
95027faf85aSMilanka Ringwald #else
btstack_memory_avdtp_stream_endpoint_get(void)9510e826a17SMilanka Ringwald avdtp_stream_endpoint_t * btstack_memory_avdtp_stream_endpoint_get(void){
95227faf85aSMilanka Ringwald return NULL;
95327faf85aSMilanka Ringwald }
btstack_memory_avdtp_stream_endpoint_free(avdtp_stream_endpoint_t * avdtp_stream_endpoint)9540e826a17SMilanka Ringwald void btstack_memory_avdtp_stream_endpoint_free(avdtp_stream_endpoint_t *avdtp_stream_endpoint){
955b6269742SMatthias Ringwald UNUSED(avdtp_stream_endpoint);
956*42a2bbebSMatthias Ringwald }
95727faf85aSMilanka Ringwald #endif
95827faf85aSMilanka Ringwald #elif defined(HAVE_MALLOC)
9592a95308bSMatthias Ringwald
9602a95308bSMatthias Ringwald typedef struct {
9612a95308bSMatthias Ringwald btstack_memory_buffer_t tracking;
962798bd46fSMatthias Ringwald avdtp_stream_endpoint_t data;
9632a95308bSMatthias Ringwald } btstack_memory_avdtp_stream_endpoint_t;
9642a95308bSMatthias Ringwald
btstack_memory_avdtp_stream_endpoint_get(void)9650e826a17SMilanka Ringwald avdtp_stream_endpoint_t * btstack_memory_avdtp_stream_endpoint_get(void){
9662a95308bSMatthias Ringwald btstack_memory_avdtp_stream_endpoint_t * buffer = (btstack_memory_avdtp_stream_endpoint_t *) malloc(sizeof(btstack_memory_avdtp_stream_endpoint_t));
967a2673d88SMatthias Ringwald if (buffer){
968798bd46fSMatthias Ringwald memset(buffer, 0, sizeof(btstack_memory_avdtp_stream_endpoint_t));
9692a95308bSMatthias Ringwald btstack_memory_tracking_add(&buffer->tracking);
9702a95308bSMatthias Ringwald return &buffer->data;
971b6269742SMatthias Ringwald } else {
972b6269742SMatthias Ringwald return NULL;
973a2673d88SMatthias Ringwald }
97427faf85aSMilanka Ringwald }
btstack_memory_avdtp_stream_endpoint_free(avdtp_stream_endpoint_t * avdtp_stream_endpoint)9750e826a17SMilanka Ringwald void btstack_memory_avdtp_stream_endpoint_free(avdtp_stream_endpoint_t *avdtp_stream_endpoint){
976798bd46fSMatthias Ringwald // reconstruct buffer start
977798bd46fSMatthias Ringwald btstack_memory_buffer_t * buffer = &((btstack_memory_buffer_t *) avdtp_stream_endpoint)[-1];
978798bd46fSMatthias Ringwald btstack_memory_tracking_remove(buffer);
979b6269742SMatthias Ringwald free(buffer);
98027faf85aSMilanka Ringwald }
98127faf85aSMilanka Ringwald #endif
98227faf85aSMilanka Ringwald
98327faf85aSMilanka Ringwald
98412e7f38cSMilanka Ringwald
98512e7f38cSMilanka Ringwald // MARK: avdtp_connection_t
98612e7f38cSMilanka Ringwald #if !defined(HAVE_MALLOC) && !defined(MAX_NR_AVDTP_CONNECTIONS)
98712e7f38cSMilanka Ringwald #if defined(MAX_NO_AVDTP_CONNECTIONS)
98812e7f38cSMilanka Ringwald #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."
98912e7f38cSMilanka Ringwald #else
99012e7f38cSMilanka Ringwald #define MAX_NR_AVDTP_CONNECTIONS 0
99112e7f38cSMilanka Ringwald #endif
99212e7f38cSMilanka Ringwald #endif
99312e7f38cSMilanka Ringwald
99412e7f38cSMilanka Ringwald #ifdef MAX_NR_AVDTP_CONNECTIONS
99512e7f38cSMilanka Ringwald #if MAX_NR_AVDTP_CONNECTIONS > 0
99612e7f38cSMilanka Ringwald static avdtp_connection_t avdtp_connection_storage[MAX_NR_AVDTP_CONNECTIONS];
99712e7f38cSMilanka Ringwald static btstack_memory_pool_t avdtp_connection_pool;
btstack_memory_avdtp_connection_get(void)99812e7f38cSMilanka Ringwald avdtp_connection_t * btstack_memory_avdtp_connection_get(void){
999a2673d88SMatthias Ringwald void * buffer = btstack_memory_pool_get(&avdtp_connection_pool);
1000a2673d88SMatthias Ringwald if (buffer){
1001a2673d88SMatthias Ringwald memset(buffer, 0, sizeof(avdtp_connection_t));
1002a2673d88SMatthias Ringwald }
1003a2673d88SMatthias Ringwald return (avdtp_connection_t *) buffer;
100412e7f38cSMilanka Ringwald }
btstack_memory_avdtp_connection_free(avdtp_connection_t * avdtp_connection)100512e7f38cSMilanka Ringwald void btstack_memory_avdtp_connection_free(avdtp_connection_t *avdtp_connection){
100612e7f38cSMilanka Ringwald btstack_memory_pool_free(&avdtp_connection_pool, avdtp_connection);
100712e7f38cSMilanka Ringwald }
100812e7f38cSMilanka Ringwald #else
btstack_memory_avdtp_connection_get(void)100912e7f38cSMilanka Ringwald avdtp_connection_t * btstack_memory_avdtp_connection_get(void){
101012e7f38cSMilanka Ringwald return NULL;
101112e7f38cSMilanka Ringwald }
btstack_memory_avdtp_connection_free(avdtp_connection_t * avdtp_connection)101212e7f38cSMilanka Ringwald void btstack_memory_avdtp_connection_free(avdtp_connection_t *avdtp_connection){
1013b6269742SMatthias Ringwald UNUSED(avdtp_connection);
1014*42a2bbebSMatthias Ringwald }
101512e7f38cSMilanka Ringwald #endif
101612e7f38cSMilanka Ringwald #elif defined(HAVE_MALLOC)
10172a95308bSMatthias Ringwald
10182a95308bSMatthias Ringwald typedef struct {
10192a95308bSMatthias Ringwald btstack_memory_buffer_t tracking;
1020798bd46fSMatthias Ringwald avdtp_connection_t data;
10212a95308bSMatthias Ringwald } btstack_memory_avdtp_connection_t;
10222a95308bSMatthias Ringwald
btstack_memory_avdtp_connection_get(void)102312e7f38cSMilanka Ringwald avdtp_connection_t * btstack_memory_avdtp_connection_get(void){
10242a95308bSMatthias Ringwald btstack_memory_avdtp_connection_t * buffer = (btstack_memory_avdtp_connection_t *) malloc(sizeof(btstack_memory_avdtp_connection_t));
1025a2673d88SMatthias Ringwald if (buffer){
1026798bd46fSMatthias Ringwald memset(buffer, 0, sizeof(btstack_memory_avdtp_connection_t));
10272a95308bSMatthias Ringwald btstack_memory_tracking_add(&buffer->tracking);
10282a95308bSMatthias Ringwald return &buffer->data;
1029b6269742SMatthias Ringwald } else {
1030b6269742SMatthias Ringwald return NULL;
1031a2673d88SMatthias Ringwald }
103212e7f38cSMilanka Ringwald }
btstack_memory_avdtp_connection_free(avdtp_connection_t * avdtp_connection)103312e7f38cSMilanka Ringwald void btstack_memory_avdtp_connection_free(avdtp_connection_t *avdtp_connection){
1034798bd46fSMatthias Ringwald // reconstruct buffer start
1035798bd46fSMatthias Ringwald btstack_memory_buffer_t * buffer = &((btstack_memory_buffer_t *) avdtp_connection)[-1];
1036798bd46fSMatthias Ringwald btstack_memory_tracking_remove(buffer);
1037b6269742SMatthias Ringwald free(buffer);
103812e7f38cSMilanka Ringwald }
103912e7f38cSMilanka Ringwald #endif
104012e7f38cSMilanka Ringwald
104112e7f38cSMilanka Ringwald
104291451a2bSMilanka Ringwald
104391451a2bSMilanka Ringwald // MARK: avrcp_connection_t
104491451a2bSMilanka Ringwald #if !defined(HAVE_MALLOC) && !defined(MAX_NR_AVRCP_CONNECTIONS)
104591451a2bSMilanka Ringwald #if defined(MAX_NO_AVRCP_CONNECTIONS)
104691451a2bSMilanka Ringwald #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."
104791451a2bSMilanka Ringwald #else
104891451a2bSMilanka Ringwald #define MAX_NR_AVRCP_CONNECTIONS 0
104991451a2bSMilanka Ringwald #endif
105091451a2bSMilanka Ringwald #endif
105191451a2bSMilanka Ringwald
105291451a2bSMilanka Ringwald #ifdef MAX_NR_AVRCP_CONNECTIONS
105391451a2bSMilanka Ringwald #if MAX_NR_AVRCP_CONNECTIONS > 0
105491451a2bSMilanka Ringwald static avrcp_connection_t avrcp_connection_storage[MAX_NR_AVRCP_CONNECTIONS];
105591451a2bSMilanka Ringwald static btstack_memory_pool_t avrcp_connection_pool;
btstack_memory_avrcp_connection_get(void)105691451a2bSMilanka Ringwald avrcp_connection_t * btstack_memory_avrcp_connection_get(void){
1057a2673d88SMatthias Ringwald void * buffer = btstack_memory_pool_get(&avrcp_connection_pool);
1058a2673d88SMatthias Ringwald if (buffer){
1059a2673d88SMatthias Ringwald memset(buffer, 0, sizeof(avrcp_connection_t));
1060a2673d88SMatthias Ringwald }
1061a2673d88SMatthias Ringwald return (avrcp_connection_t *) buffer;
106291451a2bSMilanka Ringwald }
btstack_memory_avrcp_connection_free(avrcp_connection_t * avrcp_connection)106391451a2bSMilanka Ringwald void btstack_memory_avrcp_connection_free(avrcp_connection_t *avrcp_connection){
106491451a2bSMilanka Ringwald btstack_memory_pool_free(&avrcp_connection_pool, avrcp_connection);
106591451a2bSMilanka Ringwald }
106691451a2bSMilanka Ringwald #else
btstack_memory_avrcp_connection_get(void)106791451a2bSMilanka Ringwald avrcp_connection_t * btstack_memory_avrcp_connection_get(void){
106891451a2bSMilanka Ringwald return NULL;
106991451a2bSMilanka Ringwald }
btstack_memory_avrcp_connection_free(avrcp_connection_t * avrcp_connection)107091451a2bSMilanka Ringwald void btstack_memory_avrcp_connection_free(avrcp_connection_t *avrcp_connection){
1071b6269742SMatthias Ringwald UNUSED(avrcp_connection);
1072*42a2bbebSMatthias Ringwald }
107391451a2bSMilanka Ringwald #endif
107491451a2bSMilanka Ringwald #elif defined(HAVE_MALLOC)
10752a95308bSMatthias Ringwald
10762a95308bSMatthias Ringwald typedef struct {
10772a95308bSMatthias Ringwald btstack_memory_buffer_t tracking;
1078798bd46fSMatthias Ringwald avrcp_connection_t data;
10792a95308bSMatthias Ringwald } btstack_memory_avrcp_connection_t;
10802a95308bSMatthias Ringwald
btstack_memory_avrcp_connection_get(void)108191451a2bSMilanka Ringwald avrcp_connection_t * btstack_memory_avrcp_connection_get(void){
10822a95308bSMatthias Ringwald btstack_memory_avrcp_connection_t * buffer = (btstack_memory_avrcp_connection_t *) malloc(sizeof(btstack_memory_avrcp_connection_t));
1083a2673d88SMatthias Ringwald if (buffer){
1084798bd46fSMatthias Ringwald memset(buffer, 0, sizeof(btstack_memory_avrcp_connection_t));
10852a95308bSMatthias Ringwald btstack_memory_tracking_add(&buffer->tracking);
10862a95308bSMatthias Ringwald return &buffer->data;
1087b6269742SMatthias Ringwald } else {
1088b6269742SMatthias Ringwald return NULL;
1089a2673d88SMatthias Ringwald }
109091451a2bSMilanka Ringwald }
btstack_memory_avrcp_connection_free(avrcp_connection_t * avrcp_connection)109191451a2bSMilanka Ringwald void btstack_memory_avrcp_connection_free(avrcp_connection_t *avrcp_connection){
1092798bd46fSMatthias Ringwald // reconstruct buffer start
1093798bd46fSMatthias Ringwald btstack_memory_buffer_t * buffer = &((btstack_memory_buffer_t *) avrcp_connection)[-1];
1094798bd46fSMatthias Ringwald btstack_memory_tracking_remove(buffer);
1095b6269742SMatthias Ringwald free(buffer);
109691451a2bSMilanka Ringwald }
109791451a2bSMilanka Ringwald #endif
109891451a2bSMilanka Ringwald
109991451a2bSMilanka Ringwald
1100f12a3722SMilanka Ringwald
1101f12a3722SMilanka Ringwald // MARK: avrcp_browsing_connection_t
1102f12a3722SMilanka Ringwald #if !defined(HAVE_MALLOC) && !defined(MAX_NR_AVRCP_BROWSING_CONNECTIONS)
1103f12a3722SMilanka Ringwald #if defined(MAX_NO_AVRCP_BROWSING_CONNECTIONS)
1104f12a3722SMilanka Ringwald #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."
1105f12a3722SMilanka Ringwald #else
1106f12a3722SMilanka Ringwald #define MAX_NR_AVRCP_BROWSING_CONNECTIONS 0
1107f12a3722SMilanka Ringwald #endif
1108f12a3722SMilanka Ringwald #endif
1109f12a3722SMilanka Ringwald
1110f12a3722SMilanka Ringwald #ifdef MAX_NR_AVRCP_BROWSING_CONNECTIONS
1111f12a3722SMilanka Ringwald #if MAX_NR_AVRCP_BROWSING_CONNECTIONS > 0
1112f12a3722SMilanka Ringwald static avrcp_browsing_connection_t avrcp_browsing_connection_storage[MAX_NR_AVRCP_BROWSING_CONNECTIONS];
1113f12a3722SMilanka Ringwald static btstack_memory_pool_t avrcp_browsing_connection_pool;
btstack_memory_avrcp_browsing_connection_get(void)1114f12a3722SMilanka Ringwald avrcp_browsing_connection_t * btstack_memory_avrcp_browsing_connection_get(void){
1115a2673d88SMatthias Ringwald void * buffer = btstack_memory_pool_get(&avrcp_browsing_connection_pool);
1116a2673d88SMatthias Ringwald if (buffer){
1117a2673d88SMatthias Ringwald memset(buffer, 0, sizeof(avrcp_browsing_connection_t));
1118a2673d88SMatthias Ringwald }
1119a2673d88SMatthias Ringwald return (avrcp_browsing_connection_t *) buffer;
1120f12a3722SMilanka Ringwald }
btstack_memory_avrcp_browsing_connection_free(avrcp_browsing_connection_t * avrcp_browsing_connection)1121f12a3722SMilanka Ringwald void btstack_memory_avrcp_browsing_connection_free(avrcp_browsing_connection_t *avrcp_browsing_connection){
1122f12a3722SMilanka Ringwald btstack_memory_pool_free(&avrcp_browsing_connection_pool, avrcp_browsing_connection);
1123f12a3722SMilanka Ringwald }
1124f12a3722SMilanka Ringwald #else
btstack_memory_avrcp_browsing_connection_get(void)1125f12a3722SMilanka Ringwald avrcp_browsing_connection_t * btstack_memory_avrcp_browsing_connection_get(void){
1126f12a3722SMilanka Ringwald return NULL;
1127f12a3722SMilanka Ringwald }
btstack_memory_avrcp_browsing_connection_free(avrcp_browsing_connection_t * avrcp_browsing_connection)1128f12a3722SMilanka Ringwald void btstack_memory_avrcp_browsing_connection_free(avrcp_browsing_connection_t *avrcp_browsing_connection){
1129b6269742SMatthias Ringwald UNUSED(avrcp_browsing_connection);
1130*42a2bbebSMatthias Ringwald }
1131f12a3722SMilanka Ringwald #endif
1132f12a3722SMilanka Ringwald #elif defined(HAVE_MALLOC)
11332a95308bSMatthias Ringwald
11342a95308bSMatthias Ringwald typedef struct {
11352a95308bSMatthias Ringwald btstack_memory_buffer_t tracking;
1136798bd46fSMatthias Ringwald avrcp_browsing_connection_t data;
11372a95308bSMatthias Ringwald } btstack_memory_avrcp_browsing_connection_t;
11382a95308bSMatthias Ringwald
btstack_memory_avrcp_browsing_connection_get(void)1139f12a3722SMilanka Ringwald avrcp_browsing_connection_t * btstack_memory_avrcp_browsing_connection_get(void){
11402a95308bSMatthias Ringwald btstack_memory_avrcp_browsing_connection_t * buffer = (btstack_memory_avrcp_browsing_connection_t *) malloc(sizeof(btstack_memory_avrcp_browsing_connection_t));
1141a2673d88SMatthias Ringwald if (buffer){
1142798bd46fSMatthias Ringwald memset(buffer, 0, sizeof(btstack_memory_avrcp_browsing_connection_t));
11432a95308bSMatthias Ringwald btstack_memory_tracking_add(&buffer->tracking);
11442a95308bSMatthias Ringwald return &buffer->data;
1145b6269742SMatthias Ringwald } else {
1146b6269742SMatthias Ringwald return NULL;
1147a2673d88SMatthias Ringwald }
1148f12a3722SMilanka Ringwald }
btstack_memory_avrcp_browsing_connection_free(avrcp_browsing_connection_t * avrcp_browsing_connection)1149f12a3722SMilanka Ringwald void btstack_memory_avrcp_browsing_connection_free(avrcp_browsing_connection_t *avrcp_browsing_connection){
1150798bd46fSMatthias Ringwald // reconstruct buffer start
1151798bd46fSMatthias Ringwald btstack_memory_buffer_t * buffer = &((btstack_memory_buffer_t *) avrcp_browsing_connection)[-1];
1152798bd46fSMatthias Ringwald btstack_memory_tracking_remove(buffer);
1153b6269742SMatthias Ringwald free(buffer);
1154f12a3722SMilanka Ringwald }
1155f12a3722SMilanka Ringwald #endif
1156f12a3722SMilanka Ringwald
1157f12a3722SMilanka Ringwald
115844c5d856SMatthias Ringwald #endif
1159a9a4c409SMatthias Ringwald #ifdef ENABLE_BLE
11602e97c149S[email protected]
1161174a0c1cSMilanka Ringwald // MARK: battery_service_client_t
1162174a0c1cSMilanka Ringwald #if !defined(HAVE_MALLOC) && !defined(MAX_NR_BATTERY_SERVICE_CLIENTS)
1163174a0c1cSMilanka Ringwald #if defined(MAX_NO_BATTERY_SERVICE_CLIENTS)
1164174a0c1cSMilanka Ringwald #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."
1165174a0c1cSMilanka Ringwald #else
1166174a0c1cSMilanka Ringwald #define MAX_NR_BATTERY_SERVICE_CLIENTS 0
1167174a0c1cSMilanka Ringwald #endif
1168174a0c1cSMilanka Ringwald #endif
1169174a0c1cSMilanka Ringwald
1170174a0c1cSMilanka Ringwald #ifdef MAX_NR_BATTERY_SERVICE_CLIENTS
1171174a0c1cSMilanka Ringwald #if MAX_NR_BATTERY_SERVICE_CLIENTS > 0
1172174a0c1cSMilanka Ringwald static battery_service_client_t battery_service_client_storage[MAX_NR_BATTERY_SERVICE_CLIENTS];
1173174a0c1cSMilanka Ringwald static btstack_memory_pool_t battery_service_client_pool;
btstack_memory_battery_service_client_get(void)1174174a0c1cSMilanka Ringwald battery_service_client_t * btstack_memory_battery_service_client_get(void){
1175174a0c1cSMilanka Ringwald void * buffer = btstack_memory_pool_get(&battery_service_client_pool);
1176174a0c1cSMilanka Ringwald if (buffer){
1177174a0c1cSMilanka Ringwald memset(buffer, 0, sizeof(battery_service_client_t));
1178174a0c1cSMilanka Ringwald }
1179174a0c1cSMilanka Ringwald return (battery_service_client_t *) buffer;
1180174a0c1cSMilanka Ringwald }
btstack_memory_battery_service_client_free(battery_service_client_t * battery_service_client)1181174a0c1cSMilanka Ringwald void btstack_memory_battery_service_client_free(battery_service_client_t *battery_service_client){
1182174a0c1cSMilanka Ringwald btstack_memory_pool_free(&battery_service_client_pool, battery_service_client);
1183174a0c1cSMilanka Ringwald }
1184174a0c1cSMilanka Ringwald #else
btstack_memory_battery_service_client_get(void)1185174a0c1cSMilanka Ringwald battery_service_client_t * btstack_memory_battery_service_client_get(void){
1186174a0c1cSMilanka Ringwald return NULL;
1187174a0c1cSMilanka Ringwald }
btstack_memory_battery_service_client_free(battery_service_client_t * battery_service_client)1188174a0c1cSMilanka Ringwald void btstack_memory_battery_service_client_free(battery_service_client_t *battery_service_client){
1189174a0c1cSMilanka Ringwald UNUSED(battery_service_client);
1190*42a2bbebSMatthias Ringwald }
1191174a0c1cSMilanka Ringwald #endif
1192174a0c1cSMilanka Ringwald #elif defined(HAVE_MALLOC)
1193174a0c1cSMilanka Ringwald
1194174a0c1cSMilanka Ringwald typedef struct {
1195174a0c1cSMilanka Ringwald btstack_memory_buffer_t tracking;
1196174a0c1cSMilanka Ringwald battery_service_client_t data;
1197174a0c1cSMilanka Ringwald } btstack_memory_battery_service_client_t;
1198174a0c1cSMilanka Ringwald
btstack_memory_battery_service_client_get(void)1199174a0c1cSMilanka Ringwald battery_service_client_t * btstack_memory_battery_service_client_get(void){
1200174a0c1cSMilanka Ringwald btstack_memory_battery_service_client_t * buffer = (btstack_memory_battery_service_client_t *) malloc(sizeof(btstack_memory_battery_service_client_t));
1201174a0c1cSMilanka Ringwald if (buffer){
1202174a0c1cSMilanka Ringwald memset(buffer, 0, sizeof(btstack_memory_battery_service_client_t));
1203174a0c1cSMilanka Ringwald btstack_memory_tracking_add(&buffer->tracking);
1204174a0c1cSMilanka Ringwald return &buffer->data;
1205174a0c1cSMilanka Ringwald } else {
1206174a0c1cSMilanka Ringwald return NULL;
1207174a0c1cSMilanka Ringwald }
1208174a0c1cSMilanka Ringwald }
btstack_memory_battery_service_client_free(battery_service_client_t * battery_service_client)1209174a0c1cSMilanka Ringwald void btstack_memory_battery_service_client_free(battery_service_client_t *battery_service_client){
1210174a0c1cSMilanka Ringwald // reconstruct buffer start
1211174a0c1cSMilanka Ringwald btstack_memory_buffer_t * buffer = &((btstack_memory_buffer_t *) battery_service_client)[-1];
1212174a0c1cSMilanka Ringwald btstack_memory_tracking_remove(buffer);
1213174a0c1cSMilanka Ringwald free(buffer);
1214174a0c1cSMilanka Ringwald }
1215174a0c1cSMilanka Ringwald #endif
1216174a0c1cSMilanka Ringwald
1217174a0c1cSMilanka Ringwald
12182e97c149S[email protected] // MARK: gatt_client_t
1219a265b909SMatthias Ringwald #if !defined(HAVE_MALLOC) && !defined(MAX_NR_GATT_CLIENTS)
1220a265b909SMatthias Ringwald #if defined(MAX_NO_GATT_CLIENTS)
122127faf85aSMilanka Ringwald #error "Deprecated MAX_NO_GATT_CLIENTS defined instead of MAX_NR_GATT_CLIENTS. Please update your btstack_config.h to use MAX_NR_GATT_CLIENTS."
1222a265b909SMatthias Ringwald #else
1223a265b909SMatthias Ringwald #define MAX_NR_GATT_CLIENTS 0
1224a265b909SMatthias Ringwald #endif
1225a265b909SMatthias Ringwald #endif
1226a265b909SMatthias Ringwald
1227a265b909SMatthias Ringwald #ifdef MAX_NR_GATT_CLIENTS
1228a265b909SMatthias Ringwald #if MAX_NR_GATT_CLIENTS > 0
1229a265b909SMatthias Ringwald static gatt_client_t gatt_client_storage[MAX_NR_GATT_CLIENTS];
123029d0c4f7SMatthias Ringwald static btstack_memory_pool_t gatt_client_pool;
btstack_memory_gatt_client_get(void)1231d0fdae3cS[email protected] gatt_client_t * btstack_memory_gatt_client_get(void){
1232a2673d88SMatthias Ringwald void * buffer = btstack_memory_pool_get(&gatt_client_pool);
1233a2673d88SMatthias Ringwald if (buffer){
1234a2673d88SMatthias Ringwald memset(buffer, 0, sizeof(gatt_client_t));
1235a2673d88SMatthias Ringwald }
1236a2673d88SMatthias Ringwald return (gatt_client_t *) buffer;
1237d0fdae3cS[email protected] }
btstack_memory_gatt_client_free(gatt_client_t * gatt_client)1238d0fdae3cS[email protected] void btstack_memory_gatt_client_free(gatt_client_t *gatt_client){
123929d0c4f7SMatthias Ringwald btstack_memory_pool_free(&gatt_client_pool, gatt_client);
1240d0fdae3cS[email protected] }
1241d0fdae3cS[email protected] #else
btstack_memory_gatt_client_get(void)1242d0fdae3cS[email protected] gatt_client_t * btstack_memory_gatt_client_get(void){
1243d0fdae3cS[email protected] return NULL;
1244d0fdae3cS[email protected] }
btstack_memory_gatt_client_free(gatt_client_t * gatt_client)1245d0fdae3cS[email protected] void btstack_memory_gatt_client_free(gatt_client_t *gatt_client){
1246b6269742SMatthias Ringwald UNUSED(gatt_client);
1247*42a2bbebSMatthias Ringwald }
1248d0fdae3cS[email protected] #endif
1249d0fdae3cS[email protected] #elif defined(HAVE_MALLOC)
12502a95308bSMatthias Ringwald
12512a95308bSMatthias Ringwald typedef struct {
12522a95308bSMatthias Ringwald btstack_memory_buffer_t tracking;
1253798bd46fSMatthias Ringwald gatt_client_t data;
12542a95308bSMatthias Ringwald } btstack_memory_gatt_client_t;
12552a95308bSMatthias Ringwald
btstack_memory_gatt_client_get(void)1256d0fdae3cS[email protected] gatt_client_t * btstack_memory_gatt_client_get(void){
12572a95308bSMatthias Ringwald btstack_memory_gatt_client_t * buffer = (btstack_memory_gatt_client_t *) malloc(sizeof(btstack_memory_gatt_client_t));
1258a2673d88SMatthias Ringwald if (buffer){
1259798bd46fSMatthias Ringwald memset(buffer, 0, sizeof(btstack_memory_gatt_client_t));
12602a95308bSMatthias Ringwald btstack_memory_tracking_add(&buffer->tracking);
12612a95308bSMatthias Ringwald return &buffer->data;
1262b6269742SMatthias Ringwald } else {
1263b6269742SMatthias Ringwald return NULL;
1264a2673d88SMatthias Ringwald }
1265d0fdae3cS[email protected] }
btstack_memory_gatt_client_free(gatt_client_t * gatt_client)1266d0fdae3cS[email protected] void btstack_memory_gatt_client_free(gatt_client_t *gatt_client){
1267798bd46fSMatthias Ringwald // reconstruct buffer start
1268798bd46fSMatthias Ringwald btstack_memory_buffer_t * buffer = &((btstack_memory_buffer_t *) gatt_client)[-1];
1269798bd46fSMatthias Ringwald btstack_memory_tracking_remove(buffer);
1270b6269742SMatthias Ringwald free(buffer);
1271d0fdae3cS[email protected] }
1272d0fdae3cS[email protected] #endif
12732e97c149S[email protected]
12742e97c149S[email protected]
1275cf26c8fbSMilanka Ringwald // MARK: hids_client_t
1276cf26c8fbSMilanka Ringwald #if !defined(HAVE_MALLOC) && !defined(MAX_NR_HIDS_CLIENTS)
1277cf26c8fbSMilanka Ringwald #if defined(MAX_NO_HIDS_CLIENTS)
1278cf26c8fbSMilanka Ringwald #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."
1279cf26c8fbSMilanka Ringwald #else
1280cf26c8fbSMilanka Ringwald #define MAX_NR_HIDS_CLIENTS 0
1281cf26c8fbSMilanka Ringwald #endif
1282cf26c8fbSMilanka Ringwald #endif
1283cf26c8fbSMilanka Ringwald
1284cf26c8fbSMilanka Ringwald #ifdef MAX_NR_HIDS_CLIENTS
1285cf26c8fbSMilanka Ringwald #if MAX_NR_HIDS_CLIENTS > 0
1286cf26c8fbSMilanka Ringwald static hids_client_t hids_client_storage[MAX_NR_HIDS_CLIENTS];
1287cf26c8fbSMilanka Ringwald static btstack_memory_pool_t hids_client_pool;
btstack_memory_hids_client_get(void)1288cf26c8fbSMilanka Ringwald hids_client_t * btstack_memory_hids_client_get(void){
1289cf26c8fbSMilanka Ringwald void * buffer = btstack_memory_pool_get(&hids_client_pool);
1290cf26c8fbSMilanka Ringwald if (buffer){
1291cf26c8fbSMilanka Ringwald memset(buffer, 0, sizeof(hids_client_t));
1292cf26c8fbSMilanka Ringwald }
1293cf26c8fbSMilanka Ringwald return (hids_client_t *) buffer;
1294cf26c8fbSMilanka Ringwald }
btstack_memory_hids_client_free(hids_client_t * hids_client)1295cf26c8fbSMilanka Ringwald void btstack_memory_hids_client_free(hids_client_t *hids_client){
1296cf26c8fbSMilanka Ringwald btstack_memory_pool_free(&hids_client_pool, hids_client);
1297cf26c8fbSMilanka Ringwald }
1298cf26c8fbSMilanka Ringwald #else
btstack_memory_hids_client_get(void)1299cf26c8fbSMilanka Ringwald hids_client_t * btstack_memory_hids_client_get(void){
1300cf26c8fbSMilanka Ringwald return NULL;
1301cf26c8fbSMilanka Ringwald }
btstack_memory_hids_client_free(hids_client_t * hids_client)1302cf26c8fbSMilanka Ringwald void btstack_memory_hids_client_free(hids_client_t *hids_client){
1303cf26c8fbSMilanka Ringwald UNUSED(hids_client);
1304*42a2bbebSMatthias Ringwald }
1305cf26c8fbSMilanka Ringwald #endif
1306cf26c8fbSMilanka Ringwald #elif defined(HAVE_MALLOC)
1307cf26c8fbSMilanka Ringwald
1308cf26c8fbSMilanka Ringwald typedef struct {
1309cf26c8fbSMilanka Ringwald btstack_memory_buffer_t tracking;
1310cf26c8fbSMilanka Ringwald hids_client_t data;
1311cf26c8fbSMilanka Ringwald } btstack_memory_hids_client_t;
1312cf26c8fbSMilanka Ringwald
btstack_memory_hids_client_get(void)1313cf26c8fbSMilanka Ringwald hids_client_t * btstack_memory_hids_client_get(void){
1314cf26c8fbSMilanka Ringwald btstack_memory_hids_client_t * buffer = (btstack_memory_hids_client_t *) malloc(sizeof(btstack_memory_hids_client_t));
1315cf26c8fbSMilanka Ringwald if (buffer){
1316cf26c8fbSMilanka Ringwald memset(buffer, 0, sizeof(btstack_memory_hids_client_t));
1317cf26c8fbSMilanka Ringwald btstack_memory_tracking_add(&buffer->tracking);
1318cf26c8fbSMilanka Ringwald return &buffer->data;
1319cf26c8fbSMilanka Ringwald } else {
1320cf26c8fbSMilanka Ringwald return NULL;
1321cf26c8fbSMilanka Ringwald }
1322cf26c8fbSMilanka Ringwald }
btstack_memory_hids_client_free(hids_client_t * hids_client)1323cf26c8fbSMilanka Ringwald void btstack_memory_hids_client_free(hids_client_t *hids_client){
1324cf26c8fbSMilanka Ringwald // reconstruct buffer start
1325cf26c8fbSMilanka Ringwald btstack_memory_buffer_t * buffer = &((btstack_memory_buffer_t *) hids_client)[-1];
1326cf26c8fbSMilanka Ringwald btstack_memory_tracking_remove(buffer);
1327cf26c8fbSMilanka Ringwald free(buffer);
1328cf26c8fbSMilanka Ringwald }
1329cf26c8fbSMilanka Ringwald #endif
1330cf26c8fbSMilanka Ringwald
1331cf26c8fbSMilanka Ringwald
1332cf26c8fbSMilanka Ringwald // MARK: scan_parameters_service_client_t
1333cf26c8fbSMilanka Ringwald #if !defined(HAVE_MALLOC) && !defined(MAX_NR_SCAN_PARAMETERS_SERVICE_CLIENTS)
1334cf26c8fbSMilanka Ringwald #if defined(MAX_NO_SCAN_PARAMETERS_SERVICE_CLIENTS)
1335cf26c8fbSMilanka Ringwald #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."
1336cf26c8fbSMilanka Ringwald #else
1337cf26c8fbSMilanka Ringwald #define MAX_NR_SCAN_PARAMETERS_SERVICE_CLIENTS 0
1338cf26c8fbSMilanka Ringwald #endif
1339cf26c8fbSMilanka Ringwald #endif
1340cf26c8fbSMilanka Ringwald
1341cf26c8fbSMilanka Ringwald #ifdef MAX_NR_SCAN_PARAMETERS_SERVICE_CLIENTS
1342cf26c8fbSMilanka Ringwald #if MAX_NR_SCAN_PARAMETERS_SERVICE_CLIENTS > 0
1343cf26c8fbSMilanka Ringwald static scan_parameters_service_client_t scan_parameters_service_client_storage[MAX_NR_SCAN_PARAMETERS_SERVICE_CLIENTS];
1344cf26c8fbSMilanka Ringwald static btstack_memory_pool_t scan_parameters_service_client_pool;
btstack_memory_scan_parameters_service_client_get(void)1345cf26c8fbSMilanka Ringwald scan_parameters_service_client_t * btstack_memory_scan_parameters_service_client_get(void){
1346cf26c8fbSMilanka Ringwald void * buffer = btstack_memory_pool_get(&scan_parameters_service_client_pool);
1347cf26c8fbSMilanka Ringwald if (buffer){
1348cf26c8fbSMilanka Ringwald memset(buffer, 0, sizeof(scan_parameters_service_client_t));
1349cf26c8fbSMilanka Ringwald }
1350cf26c8fbSMilanka Ringwald return (scan_parameters_service_client_t *) buffer;
1351cf26c8fbSMilanka Ringwald }
btstack_memory_scan_parameters_service_client_free(scan_parameters_service_client_t * scan_parameters_service_client)1352cf26c8fbSMilanka Ringwald void btstack_memory_scan_parameters_service_client_free(scan_parameters_service_client_t *scan_parameters_service_client){
1353cf26c8fbSMilanka Ringwald btstack_memory_pool_free(&scan_parameters_service_client_pool, scan_parameters_service_client);
1354cf26c8fbSMilanka Ringwald }
1355cf26c8fbSMilanka Ringwald #else
btstack_memory_scan_parameters_service_client_get(void)1356cf26c8fbSMilanka Ringwald scan_parameters_service_client_t * btstack_memory_scan_parameters_service_client_get(void){
1357cf26c8fbSMilanka Ringwald return NULL;
1358cf26c8fbSMilanka Ringwald }
btstack_memory_scan_parameters_service_client_free(scan_parameters_service_client_t * scan_parameters_service_client)1359cf26c8fbSMilanka Ringwald void btstack_memory_scan_parameters_service_client_free(scan_parameters_service_client_t *scan_parameters_service_client){
1360cf26c8fbSMilanka Ringwald UNUSED(scan_parameters_service_client);
1361*42a2bbebSMatthias Ringwald }
1362cf26c8fbSMilanka Ringwald #endif
1363cf26c8fbSMilanka Ringwald #elif defined(HAVE_MALLOC)
1364cf26c8fbSMilanka Ringwald
1365cf26c8fbSMilanka Ringwald typedef struct {
1366cf26c8fbSMilanka Ringwald btstack_memory_buffer_t tracking;
1367cf26c8fbSMilanka Ringwald scan_parameters_service_client_t data;
1368cf26c8fbSMilanka Ringwald } btstack_memory_scan_parameters_service_client_t;
1369cf26c8fbSMilanka Ringwald
btstack_memory_scan_parameters_service_client_get(void)1370cf26c8fbSMilanka Ringwald scan_parameters_service_client_t * btstack_memory_scan_parameters_service_client_get(void){
1371cf26c8fbSMilanka Ringwald btstack_memory_scan_parameters_service_client_t * buffer = (btstack_memory_scan_parameters_service_client_t *) malloc(sizeof(btstack_memory_scan_parameters_service_client_t));
1372cf26c8fbSMilanka Ringwald if (buffer){
1373cf26c8fbSMilanka Ringwald memset(buffer, 0, sizeof(btstack_memory_scan_parameters_service_client_t));
1374cf26c8fbSMilanka Ringwald btstack_memory_tracking_add(&buffer->tracking);
1375cf26c8fbSMilanka Ringwald return &buffer->data;
1376cf26c8fbSMilanka Ringwald } else {
1377cf26c8fbSMilanka Ringwald return NULL;
1378cf26c8fbSMilanka Ringwald }
1379cf26c8fbSMilanka Ringwald }
btstack_memory_scan_parameters_service_client_free(scan_parameters_service_client_t * scan_parameters_service_client)1380cf26c8fbSMilanka Ringwald void btstack_memory_scan_parameters_service_client_free(scan_parameters_service_client_t *scan_parameters_service_client){
1381cf26c8fbSMilanka Ringwald // reconstruct buffer start
1382cf26c8fbSMilanka Ringwald btstack_memory_buffer_t * buffer = &((btstack_memory_buffer_t *) scan_parameters_service_client)[-1];
1383cf26c8fbSMilanka Ringwald btstack_memory_tracking_remove(buffer);
1384cf26c8fbSMilanka Ringwald free(buffer);
1385cf26c8fbSMilanka Ringwald }
1386cf26c8fbSMilanka Ringwald #endif
1387cf26c8fbSMilanka Ringwald
1388cf26c8fbSMilanka Ringwald
1389cf49570bSMatthias Ringwald // MARK: sm_lookup_entry_t
1390a265b909SMatthias Ringwald #if !defined(HAVE_MALLOC) && !defined(MAX_NR_SM_LOOKUP_ENTRIES)
1391a265b909SMatthias Ringwald #if defined(MAX_NO_SM_LOOKUP_ENTRIES)
139227faf85aSMilanka Ringwald #error "Deprecated MAX_NO_SM_LOOKUP_ENTRIES defined instead of MAX_NR_SM_LOOKUP_ENTRIES. Please update your btstack_config.h to use MAX_NR_SM_LOOKUP_ENTRIES."
1393a265b909SMatthias Ringwald #else
1394a265b909SMatthias Ringwald #define MAX_NR_SM_LOOKUP_ENTRIES 0
1395a265b909SMatthias Ringwald #endif
1396a265b909SMatthias Ringwald #endif
1397a265b909SMatthias Ringwald
1398a265b909SMatthias Ringwald #ifdef MAX_NR_SM_LOOKUP_ENTRIES
1399a265b909SMatthias Ringwald #if MAX_NR_SM_LOOKUP_ENTRIES > 0
1400a265b909SMatthias Ringwald static sm_lookup_entry_t sm_lookup_entry_storage[MAX_NR_SM_LOOKUP_ENTRIES];
140129d0c4f7SMatthias Ringwald static btstack_memory_pool_t sm_lookup_entry_pool;
btstack_memory_sm_lookup_entry_get(void)1402cf49570bSMatthias Ringwald sm_lookup_entry_t * btstack_memory_sm_lookup_entry_get(void){
1403a2673d88SMatthias Ringwald void * buffer = btstack_memory_pool_get(&sm_lookup_entry_pool);
1404a2673d88SMatthias Ringwald if (buffer){
1405a2673d88SMatthias Ringwald memset(buffer, 0, sizeof(sm_lookup_entry_t));
1406a2673d88SMatthias Ringwald }
1407a2673d88SMatthias Ringwald return (sm_lookup_entry_t *) buffer;
1408cf49570bSMatthias Ringwald }
btstack_memory_sm_lookup_entry_free(sm_lookup_entry_t * sm_lookup_entry)1409cf49570bSMatthias Ringwald void btstack_memory_sm_lookup_entry_free(sm_lookup_entry_t *sm_lookup_entry){
141029d0c4f7SMatthias Ringwald btstack_memory_pool_free(&sm_lookup_entry_pool, sm_lookup_entry);
1411cf49570bSMatthias Ringwald }
1412cf49570bSMatthias Ringwald #else
btstack_memory_sm_lookup_entry_get(void)1413cf49570bSMatthias Ringwald sm_lookup_entry_t * btstack_memory_sm_lookup_entry_get(void){
1414cf49570bSMatthias Ringwald return NULL;
1415cf49570bSMatthias Ringwald }
btstack_memory_sm_lookup_entry_free(sm_lookup_entry_t * sm_lookup_entry)1416cf49570bSMatthias Ringwald void btstack_memory_sm_lookup_entry_free(sm_lookup_entry_t *sm_lookup_entry){
1417b6269742SMatthias Ringwald UNUSED(sm_lookup_entry);
1418*42a2bbebSMatthias Ringwald }
1419cf49570bSMatthias Ringwald #endif
1420cf49570bSMatthias Ringwald #elif defined(HAVE_MALLOC)
14212a95308bSMatthias Ringwald
14222a95308bSMatthias Ringwald typedef struct {
14232a95308bSMatthias Ringwald btstack_memory_buffer_t tracking;
1424798bd46fSMatthias Ringwald sm_lookup_entry_t data;
14252a95308bSMatthias Ringwald } btstack_memory_sm_lookup_entry_t;
14262a95308bSMatthias Ringwald
btstack_memory_sm_lookup_entry_get(void)1427cf49570bSMatthias Ringwald sm_lookup_entry_t * btstack_memory_sm_lookup_entry_get(void){
14282a95308bSMatthias Ringwald btstack_memory_sm_lookup_entry_t * buffer = (btstack_memory_sm_lookup_entry_t *) malloc(sizeof(btstack_memory_sm_lookup_entry_t));
1429a2673d88SMatthias Ringwald if (buffer){
1430798bd46fSMatthias Ringwald memset(buffer, 0, sizeof(btstack_memory_sm_lookup_entry_t));
14312a95308bSMatthias Ringwald btstack_memory_tracking_add(&buffer->tracking);
14322a95308bSMatthias Ringwald return &buffer->data;
1433b6269742SMatthias Ringwald } else {
1434b6269742SMatthias Ringwald return NULL;
1435a2673d88SMatthias Ringwald }
1436cf49570bSMatthias Ringwald }
btstack_memory_sm_lookup_entry_free(sm_lookup_entry_t * sm_lookup_entry)1437cf49570bSMatthias Ringwald void btstack_memory_sm_lookup_entry_free(sm_lookup_entry_t *sm_lookup_entry){
1438798bd46fSMatthias Ringwald // reconstruct buffer start
1439798bd46fSMatthias Ringwald btstack_memory_buffer_t * buffer = &((btstack_memory_buffer_t *) sm_lookup_entry)[-1];
1440798bd46fSMatthias Ringwald btstack_memory_tracking_remove(buffer);
1441b6269742SMatthias Ringwald free(buffer);
1442cf49570bSMatthias Ringwald }
1443cf49570bSMatthias Ringwald #endif
1444cf49570bSMatthias Ringwald
1445cf49570bSMatthias Ringwald
1446174a0c1cSMilanka Ringwald // MARK: whitelist_entry_t
1447174a0c1cSMilanka Ringwald #if !defined(HAVE_MALLOC) && !defined(MAX_NR_WHITELIST_ENTRIES)
1448174a0c1cSMilanka Ringwald #if defined(MAX_NO_WHITELIST_ENTRIES)
1449174a0c1cSMilanka Ringwald #error "Deprecated MAX_NO_WHITELIST_ENTRIES defined instead of MAX_NR_WHITELIST_ENTRIES. Please update your btstack_config.h to use MAX_NR_WHITELIST_ENTRIES."
1450174a0c1cSMilanka Ringwald #else
1451174a0c1cSMilanka Ringwald #define MAX_NR_WHITELIST_ENTRIES 0
1452174a0c1cSMilanka Ringwald #endif
1453174a0c1cSMilanka Ringwald #endif
1454174a0c1cSMilanka Ringwald
1455174a0c1cSMilanka Ringwald #ifdef MAX_NR_WHITELIST_ENTRIES
1456174a0c1cSMilanka Ringwald #if MAX_NR_WHITELIST_ENTRIES > 0
1457174a0c1cSMilanka Ringwald static whitelist_entry_t whitelist_entry_storage[MAX_NR_WHITELIST_ENTRIES];
1458174a0c1cSMilanka Ringwald static btstack_memory_pool_t whitelist_entry_pool;
btstack_memory_whitelist_entry_get(void)1459174a0c1cSMilanka Ringwald whitelist_entry_t * btstack_memory_whitelist_entry_get(void){
1460174a0c1cSMilanka Ringwald void * buffer = btstack_memory_pool_get(&whitelist_entry_pool);
1461174a0c1cSMilanka Ringwald if (buffer){
1462174a0c1cSMilanka Ringwald memset(buffer, 0, sizeof(whitelist_entry_t));
1463174a0c1cSMilanka Ringwald }
1464174a0c1cSMilanka Ringwald return (whitelist_entry_t *) buffer;
1465174a0c1cSMilanka Ringwald }
btstack_memory_whitelist_entry_free(whitelist_entry_t * whitelist_entry)1466174a0c1cSMilanka Ringwald void btstack_memory_whitelist_entry_free(whitelist_entry_t *whitelist_entry){
1467174a0c1cSMilanka Ringwald btstack_memory_pool_free(&whitelist_entry_pool, whitelist_entry);
1468174a0c1cSMilanka Ringwald }
1469174a0c1cSMilanka Ringwald #else
btstack_memory_whitelist_entry_get(void)1470174a0c1cSMilanka Ringwald whitelist_entry_t * btstack_memory_whitelist_entry_get(void){
1471174a0c1cSMilanka Ringwald return NULL;
1472174a0c1cSMilanka Ringwald }
btstack_memory_whitelist_entry_free(whitelist_entry_t * whitelist_entry)1473174a0c1cSMilanka Ringwald void btstack_memory_whitelist_entry_free(whitelist_entry_t *whitelist_entry){
1474174a0c1cSMilanka Ringwald UNUSED(whitelist_entry);
1475*42a2bbebSMatthias Ringwald }
1476174a0c1cSMilanka Ringwald #endif
1477174a0c1cSMilanka Ringwald #elif defined(HAVE_MALLOC)
1478174a0c1cSMilanka Ringwald
1479174a0c1cSMilanka Ringwald typedef struct {
1480174a0c1cSMilanka Ringwald btstack_memory_buffer_t tracking;
1481174a0c1cSMilanka Ringwald whitelist_entry_t data;
1482174a0c1cSMilanka Ringwald } btstack_memory_whitelist_entry_t;
1483174a0c1cSMilanka Ringwald
btstack_memory_whitelist_entry_get(void)1484174a0c1cSMilanka Ringwald whitelist_entry_t * btstack_memory_whitelist_entry_get(void){
1485174a0c1cSMilanka Ringwald btstack_memory_whitelist_entry_t * buffer = (btstack_memory_whitelist_entry_t *) malloc(sizeof(btstack_memory_whitelist_entry_t));
1486174a0c1cSMilanka Ringwald if (buffer){
1487174a0c1cSMilanka Ringwald memset(buffer, 0, sizeof(btstack_memory_whitelist_entry_t));
1488174a0c1cSMilanka Ringwald btstack_memory_tracking_add(&buffer->tracking);
1489174a0c1cSMilanka Ringwald return &buffer->data;
1490174a0c1cSMilanka Ringwald } else {
1491174a0c1cSMilanka Ringwald return NULL;
1492174a0c1cSMilanka Ringwald }
1493174a0c1cSMilanka Ringwald }
btstack_memory_whitelist_entry_free(whitelist_entry_t * whitelist_entry)1494174a0c1cSMilanka Ringwald void btstack_memory_whitelist_entry_free(whitelist_entry_t *whitelist_entry){
1495174a0c1cSMilanka Ringwald // reconstruct buffer start
1496174a0c1cSMilanka Ringwald btstack_memory_buffer_t * buffer = &((btstack_memory_buffer_t *) whitelist_entry)[-1];
1497174a0c1cSMilanka Ringwald btstack_memory_tracking_remove(buffer);
1498174a0c1cSMilanka Ringwald free(buffer);
1499174a0c1cSMilanka Ringwald }
1500174a0c1cSMilanka Ringwald #endif
1501174a0c1cSMilanka Ringwald
1502174a0c1cSMilanka Ringwald
1503dbca66ffSMatthias Ringwald // MARK: periodic_advertiser_list_entry_t
1504dbca66ffSMatthias Ringwald #if !defined(HAVE_MALLOC) && !defined(MAX_NR_PERIODIC_ADVERTISER_LIST_ENTRIES)
1505dbca66ffSMatthias Ringwald #if defined(MAX_NO_PERIODIC_ADVERTISER_LIST_ENTRIES)
1506dbca66ffSMatthias Ringwald #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."
1507dbca66ffSMatthias Ringwald #else
1508dbca66ffSMatthias Ringwald #define MAX_NR_PERIODIC_ADVERTISER_LIST_ENTRIES 0
1509dbca66ffSMatthias Ringwald #endif
1510dbca66ffSMatthias Ringwald #endif
1511dbca66ffSMatthias Ringwald
1512dbca66ffSMatthias Ringwald #ifdef MAX_NR_PERIODIC_ADVERTISER_LIST_ENTRIES
1513dbca66ffSMatthias Ringwald #if MAX_NR_PERIODIC_ADVERTISER_LIST_ENTRIES > 0
1514dbca66ffSMatthias Ringwald static periodic_advertiser_list_entry_t periodic_advertiser_list_entry_storage[MAX_NR_PERIODIC_ADVERTISER_LIST_ENTRIES];
1515dbca66ffSMatthias Ringwald static btstack_memory_pool_t periodic_advertiser_list_entry_pool;
btstack_memory_periodic_advertiser_list_entry_get(void)1516dbca66ffSMatthias Ringwald periodic_advertiser_list_entry_t * btstack_memory_periodic_advertiser_list_entry_get(void){
1517dbca66ffSMatthias Ringwald void * buffer = btstack_memory_pool_get(&periodic_advertiser_list_entry_pool);
1518dbca66ffSMatthias Ringwald if (buffer){
1519dbca66ffSMatthias Ringwald memset(buffer, 0, sizeof(periodic_advertiser_list_entry_t));
1520dbca66ffSMatthias Ringwald }
1521dbca66ffSMatthias Ringwald return (periodic_advertiser_list_entry_t *) buffer;
1522dbca66ffSMatthias Ringwald }
btstack_memory_periodic_advertiser_list_entry_free(periodic_advertiser_list_entry_t * periodic_advertiser_list_entry)1523dbca66ffSMatthias Ringwald void btstack_memory_periodic_advertiser_list_entry_free(periodic_advertiser_list_entry_t *periodic_advertiser_list_entry){
1524dbca66ffSMatthias Ringwald btstack_memory_pool_free(&periodic_advertiser_list_entry_pool, periodic_advertiser_list_entry);
1525dbca66ffSMatthias Ringwald }
1526dbca66ffSMatthias Ringwald #else
btstack_memory_periodic_advertiser_list_entry_get(void)1527dbca66ffSMatthias Ringwald periodic_advertiser_list_entry_t * btstack_memory_periodic_advertiser_list_entry_get(void){
1528dbca66ffSMatthias Ringwald return NULL;
1529dbca66ffSMatthias Ringwald }
btstack_memory_periodic_advertiser_list_entry_free(periodic_advertiser_list_entry_t * periodic_advertiser_list_entry)1530dbca66ffSMatthias Ringwald void btstack_memory_periodic_advertiser_list_entry_free(periodic_advertiser_list_entry_t *periodic_advertiser_list_entry){
1531dbca66ffSMatthias Ringwald UNUSED(periodic_advertiser_list_entry);
1532*42a2bbebSMatthias Ringwald }
1533dbca66ffSMatthias Ringwald #endif
1534dbca66ffSMatthias Ringwald #elif defined(HAVE_MALLOC)
1535dbca66ffSMatthias Ringwald
1536dbca66ffSMatthias Ringwald typedef struct {
1537dbca66ffSMatthias Ringwald btstack_memory_buffer_t tracking;
1538dbca66ffSMatthias Ringwald periodic_advertiser_list_entry_t data;
1539dbca66ffSMatthias Ringwald } btstack_memory_periodic_advertiser_list_entry_t;
1540dbca66ffSMatthias Ringwald
btstack_memory_periodic_advertiser_list_entry_get(void)1541dbca66ffSMatthias Ringwald periodic_advertiser_list_entry_t * btstack_memory_periodic_advertiser_list_entry_get(void){
1542dbca66ffSMatthias Ringwald btstack_memory_periodic_advertiser_list_entry_t * buffer = (btstack_memory_periodic_advertiser_list_entry_t *) malloc(sizeof(btstack_memory_periodic_advertiser_list_entry_t));
1543dbca66ffSMatthias Ringwald if (buffer){
1544dbca66ffSMatthias Ringwald memset(buffer, 0, sizeof(btstack_memory_periodic_advertiser_list_entry_t));
1545dbca66ffSMatthias Ringwald btstack_memory_tracking_add(&buffer->tracking);
1546dbca66ffSMatthias Ringwald return &buffer->data;
1547dbca66ffSMatthias Ringwald } else {
1548dbca66ffSMatthias Ringwald return NULL;
1549dbca66ffSMatthias Ringwald }
1550dbca66ffSMatthias Ringwald }
btstack_memory_periodic_advertiser_list_entry_free(periodic_advertiser_list_entry_t * periodic_advertiser_list_entry)1551dbca66ffSMatthias Ringwald void btstack_memory_periodic_advertiser_list_entry_free(periodic_advertiser_list_entry_t *periodic_advertiser_list_entry){
1552dbca66ffSMatthias Ringwald // reconstruct buffer start
1553dbca66ffSMatthias Ringwald btstack_memory_buffer_t * buffer = &((btstack_memory_buffer_t *) periodic_advertiser_list_entry)[-1];
1554dbca66ffSMatthias Ringwald btstack_memory_tracking_remove(buffer);
1555dbca66ffSMatthias Ringwald free(buffer);
1556dbca66ffSMatthias Ringwald }
1557dbca66ffSMatthias Ringwald #endif
1558dbca66ffSMatthias Ringwald
1559dbca66ffSMatthias Ringwald
156044c5d856SMatthias Ringwald #endif
156144c5d856SMatthias Ringwald #ifdef ENABLE_MESH
1562ebb73e1fSMatthias Ringwald
1563ebb73e1fSMatthias Ringwald // MARK: mesh_network_pdu_t
1564ebb73e1fSMatthias Ringwald #if !defined(HAVE_MALLOC) && !defined(MAX_NR_MESH_NETWORK_PDUS)
1565ebb73e1fSMatthias Ringwald #if defined(MAX_NO_MESH_NETWORK_PDUS)
1566ebb73e1fSMatthias Ringwald #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."
1567ebb73e1fSMatthias Ringwald #else
1568ebb73e1fSMatthias Ringwald #define MAX_NR_MESH_NETWORK_PDUS 0
1569ebb73e1fSMatthias Ringwald #endif
1570ebb73e1fSMatthias Ringwald #endif
1571ebb73e1fSMatthias Ringwald
1572ebb73e1fSMatthias Ringwald #ifdef MAX_NR_MESH_NETWORK_PDUS
1573ebb73e1fSMatthias Ringwald #if MAX_NR_MESH_NETWORK_PDUS > 0
1574ebb73e1fSMatthias Ringwald static mesh_network_pdu_t mesh_network_pdu_storage[MAX_NR_MESH_NETWORK_PDUS];
1575ebb73e1fSMatthias Ringwald static btstack_memory_pool_t mesh_network_pdu_pool;
btstack_memory_mesh_network_pdu_get(void)1576ebb73e1fSMatthias Ringwald mesh_network_pdu_t * btstack_memory_mesh_network_pdu_get(void){
15771c4e8084SMatthias Ringwald void * buffer = btstack_memory_pool_get(&mesh_network_pdu_pool);
15781c4e8084SMatthias Ringwald if (buffer){
15791c4e8084SMatthias Ringwald memset(buffer, 0, sizeof(mesh_network_pdu_t));
15801c4e8084SMatthias Ringwald }
15811c4e8084SMatthias Ringwald return (mesh_network_pdu_t *) buffer;
1582ebb73e1fSMatthias Ringwald }
btstack_memory_mesh_network_pdu_free(mesh_network_pdu_t * mesh_network_pdu)1583ebb73e1fSMatthias Ringwald void btstack_memory_mesh_network_pdu_free(mesh_network_pdu_t *mesh_network_pdu){
1584ebb73e1fSMatthias Ringwald btstack_memory_pool_free(&mesh_network_pdu_pool, mesh_network_pdu);
1585ebb73e1fSMatthias Ringwald }
1586ebb73e1fSMatthias Ringwald #else
btstack_memory_mesh_network_pdu_get(void)1587ebb73e1fSMatthias Ringwald mesh_network_pdu_t * btstack_memory_mesh_network_pdu_get(void){
1588ebb73e1fSMatthias Ringwald return NULL;
1589ebb73e1fSMatthias Ringwald }
btstack_memory_mesh_network_pdu_free(mesh_network_pdu_t * mesh_network_pdu)1590ebb73e1fSMatthias Ringwald void btstack_memory_mesh_network_pdu_free(mesh_network_pdu_t *mesh_network_pdu){
1591b6269742SMatthias Ringwald UNUSED(mesh_network_pdu);
1592*42a2bbebSMatthias Ringwald }
1593ebb73e1fSMatthias Ringwald #endif
1594ebb73e1fSMatthias Ringwald #elif defined(HAVE_MALLOC)
15952a95308bSMatthias Ringwald
15962a95308bSMatthias Ringwald typedef struct {
15972a95308bSMatthias Ringwald btstack_memory_buffer_t tracking;
1598798bd46fSMatthias Ringwald mesh_network_pdu_t data;
15992a95308bSMatthias Ringwald } btstack_memory_mesh_network_pdu_t;
16002a95308bSMatthias Ringwald
btstack_memory_mesh_network_pdu_get(void)1601ebb73e1fSMatthias Ringwald mesh_network_pdu_t * btstack_memory_mesh_network_pdu_get(void){
16022a95308bSMatthias Ringwald btstack_memory_mesh_network_pdu_t * buffer = (btstack_memory_mesh_network_pdu_t *) malloc(sizeof(btstack_memory_mesh_network_pdu_t));
16031c4e8084SMatthias Ringwald if (buffer){
1604798bd46fSMatthias Ringwald memset(buffer, 0, sizeof(btstack_memory_mesh_network_pdu_t));
16052a95308bSMatthias Ringwald btstack_memory_tracking_add(&buffer->tracking);
16062a95308bSMatthias Ringwald return &buffer->data;
1607b6269742SMatthias Ringwald } else {
1608b6269742SMatthias Ringwald return NULL;
16091c4e8084SMatthias Ringwald }
1610ebb73e1fSMatthias Ringwald }
btstack_memory_mesh_network_pdu_free(mesh_network_pdu_t * mesh_network_pdu)1611ebb73e1fSMatthias Ringwald void btstack_memory_mesh_network_pdu_free(mesh_network_pdu_t *mesh_network_pdu){
1612798bd46fSMatthias Ringwald // reconstruct buffer start
1613798bd46fSMatthias Ringwald btstack_memory_buffer_t * buffer = &((btstack_memory_buffer_t *) mesh_network_pdu)[-1];
1614798bd46fSMatthias Ringwald btstack_memory_tracking_remove(buffer);
1615b6269742SMatthias Ringwald free(buffer);
1616ebb73e1fSMatthias Ringwald }
1617ebb73e1fSMatthias Ringwald #endif
1618ebb73e1fSMatthias Ringwald
1619ebb73e1fSMatthias Ringwald
1620a4bbc09dSMatthias Ringwald // MARK: mesh_segmented_pdu_t
1621a4bbc09dSMatthias Ringwald #if !defined(HAVE_MALLOC) && !defined(MAX_NR_MESH_SEGMENTED_PDUS)
1622a4bbc09dSMatthias Ringwald #if defined(MAX_NO_MESH_SEGMENTED_PDUS)
1623a4bbc09dSMatthias Ringwald #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."
1624f7434c1fSMatthias Ringwald #else
1625a4bbc09dSMatthias Ringwald #define MAX_NR_MESH_SEGMENTED_PDUS 0
1626f7434c1fSMatthias Ringwald #endif
1627f7434c1fSMatthias Ringwald #endif
1628f7434c1fSMatthias Ringwald
1629a4bbc09dSMatthias Ringwald #ifdef MAX_NR_MESH_SEGMENTED_PDUS
1630a4bbc09dSMatthias Ringwald #if MAX_NR_MESH_SEGMENTED_PDUS > 0
1631a4bbc09dSMatthias Ringwald static mesh_segmented_pdu_t mesh_segmented_pdu_storage[MAX_NR_MESH_SEGMENTED_PDUS];
1632a4bbc09dSMatthias Ringwald static btstack_memory_pool_t mesh_segmented_pdu_pool;
btstack_memory_mesh_segmented_pdu_get(void)1633a4bbc09dSMatthias Ringwald mesh_segmented_pdu_t * btstack_memory_mesh_segmented_pdu_get(void){
1634a4bbc09dSMatthias Ringwald void * buffer = btstack_memory_pool_get(&mesh_segmented_pdu_pool);
1635f7434c1fSMatthias Ringwald if (buffer){
1636a4bbc09dSMatthias Ringwald memset(buffer, 0, sizeof(mesh_segmented_pdu_t));
1637f7434c1fSMatthias Ringwald }
1638a4bbc09dSMatthias Ringwald return (mesh_segmented_pdu_t *) buffer;
1639f7434c1fSMatthias Ringwald }
btstack_memory_mesh_segmented_pdu_free(mesh_segmented_pdu_t * mesh_segmented_pdu)1640a4bbc09dSMatthias Ringwald void btstack_memory_mesh_segmented_pdu_free(mesh_segmented_pdu_t *mesh_segmented_pdu){
1641a4bbc09dSMatthias Ringwald btstack_memory_pool_free(&mesh_segmented_pdu_pool, mesh_segmented_pdu);
1642f7434c1fSMatthias Ringwald }
1643f7434c1fSMatthias Ringwald #else
btstack_memory_mesh_segmented_pdu_get(void)1644a4bbc09dSMatthias Ringwald mesh_segmented_pdu_t * btstack_memory_mesh_segmented_pdu_get(void){
1645f7434c1fSMatthias Ringwald return NULL;
1646f7434c1fSMatthias Ringwald }
btstack_memory_mesh_segmented_pdu_free(mesh_segmented_pdu_t * mesh_segmented_pdu)1647a4bbc09dSMatthias Ringwald void btstack_memory_mesh_segmented_pdu_free(mesh_segmented_pdu_t *mesh_segmented_pdu){
1648b6269742SMatthias Ringwald UNUSED(mesh_segmented_pdu);
1649*42a2bbebSMatthias Ringwald }
1650f7434c1fSMatthias Ringwald #endif
1651f7434c1fSMatthias Ringwald #elif defined(HAVE_MALLOC)
16522a95308bSMatthias Ringwald
16532a95308bSMatthias Ringwald typedef struct {
16542a95308bSMatthias Ringwald btstack_memory_buffer_t tracking;
1655798bd46fSMatthias Ringwald mesh_segmented_pdu_t data;
16562a95308bSMatthias Ringwald } btstack_memory_mesh_segmented_pdu_t;
16572a95308bSMatthias Ringwald
btstack_memory_mesh_segmented_pdu_get(void)1658a4bbc09dSMatthias Ringwald mesh_segmented_pdu_t * btstack_memory_mesh_segmented_pdu_get(void){
16592a95308bSMatthias Ringwald btstack_memory_mesh_segmented_pdu_t * buffer = (btstack_memory_mesh_segmented_pdu_t *) malloc(sizeof(btstack_memory_mesh_segmented_pdu_t));
1660f7434c1fSMatthias Ringwald if (buffer){
1661798bd46fSMatthias Ringwald memset(buffer, 0, sizeof(btstack_memory_mesh_segmented_pdu_t));
16622a95308bSMatthias Ringwald btstack_memory_tracking_add(&buffer->tracking);
16632a95308bSMatthias Ringwald return &buffer->data;
1664b6269742SMatthias Ringwald } else {
1665b6269742SMatthias Ringwald return NULL;
1666f7434c1fSMatthias Ringwald }
1667f7434c1fSMatthias Ringwald }
btstack_memory_mesh_segmented_pdu_free(mesh_segmented_pdu_t * mesh_segmented_pdu)1668a4bbc09dSMatthias Ringwald void btstack_memory_mesh_segmented_pdu_free(mesh_segmented_pdu_t *mesh_segmented_pdu){
1669798bd46fSMatthias Ringwald // reconstruct buffer start
1670798bd46fSMatthias Ringwald btstack_memory_buffer_t * buffer = &((btstack_memory_buffer_t *) mesh_segmented_pdu)[-1];
1671798bd46fSMatthias Ringwald btstack_memory_tracking_remove(buffer);
1672b6269742SMatthias Ringwald free(buffer);
1673f7434c1fSMatthias Ringwald }
1674f7434c1fSMatthias Ringwald #endif
1675f7434c1fSMatthias Ringwald
1676f7434c1fSMatthias Ringwald
1677491f99b3SMatthias Ringwald // MARK: mesh_upper_transport_pdu_t
1678491f99b3SMatthias Ringwald #if !defined(HAVE_MALLOC) && !defined(MAX_NR_MESH_UPPER_TRANSPORT_PDUS)
1679491f99b3SMatthias Ringwald #if defined(MAX_NO_MESH_UPPER_TRANSPORT_PDUS)
1680491f99b3SMatthias Ringwald #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."
1681491f99b3SMatthias Ringwald #else
1682491f99b3SMatthias Ringwald #define MAX_NR_MESH_UPPER_TRANSPORT_PDUS 0
1683491f99b3SMatthias Ringwald #endif
1684491f99b3SMatthias Ringwald #endif
1685491f99b3SMatthias Ringwald
1686491f99b3SMatthias Ringwald #ifdef MAX_NR_MESH_UPPER_TRANSPORT_PDUS
1687491f99b3SMatthias Ringwald #if MAX_NR_MESH_UPPER_TRANSPORT_PDUS > 0
1688491f99b3SMatthias Ringwald static mesh_upper_transport_pdu_t mesh_upper_transport_pdu_storage[MAX_NR_MESH_UPPER_TRANSPORT_PDUS];
1689491f99b3SMatthias Ringwald static btstack_memory_pool_t mesh_upper_transport_pdu_pool;
btstack_memory_mesh_upper_transport_pdu_get(void)1690491f99b3SMatthias Ringwald mesh_upper_transport_pdu_t * btstack_memory_mesh_upper_transport_pdu_get(void){
1691491f99b3SMatthias Ringwald void * buffer = btstack_memory_pool_get(&mesh_upper_transport_pdu_pool);
1692491f99b3SMatthias Ringwald if (buffer){
1693491f99b3SMatthias Ringwald memset(buffer, 0, sizeof(mesh_upper_transport_pdu_t));
1694491f99b3SMatthias Ringwald }
1695491f99b3SMatthias Ringwald return (mesh_upper_transport_pdu_t *) buffer;
1696491f99b3SMatthias Ringwald }
btstack_memory_mesh_upper_transport_pdu_free(mesh_upper_transport_pdu_t * mesh_upper_transport_pdu)1697491f99b3SMatthias Ringwald void btstack_memory_mesh_upper_transport_pdu_free(mesh_upper_transport_pdu_t *mesh_upper_transport_pdu){
1698491f99b3SMatthias Ringwald btstack_memory_pool_free(&mesh_upper_transport_pdu_pool, mesh_upper_transport_pdu);
1699491f99b3SMatthias Ringwald }
1700491f99b3SMatthias Ringwald #else
btstack_memory_mesh_upper_transport_pdu_get(void)1701491f99b3SMatthias Ringwald mesh_upper_transport_pdu_t * btstack_memory_mesh_upper_transport_pdu_get(void){
1702491f99b3SMatthias Ringwald return NULL;
1703491f99b3SMatthias Ringwald }
btstack_memory_mesh_upper_transport_pdu_free(mesh_upper_transport_pdu_t * mesh_upper_transport_pdu)1704491f99b3SMatthias Ringwald void btstack_memory_mesh_upper_transport_pdu_free(mesh_upper_transport_pdu_t *mesh_upper_transport_pdu){
1705b6269742SMatthias Ringwald UNUSED(mesh_upper_transport_pdu);
1706*42a2bbebSMatthias Ringwald }
1707491f99b3SMatthias Ringwald #endif
1708491f99b3SMatthias Ringwald #elif defined(HAVE_MALLOC)
17092a95308bSMatthias Ringwald
17102a95308bSMatthias Ringwald typedef struct {
17112a95308bSMatthias Ringwald btstack_memory_buffer_t tracking;
1712798bd46fSMatthias Ringwald mesh_upper_transport_pdu_t data;
17132a95308bSMatthias Ringwald } btstack_memory_mesh_upper_transport_pdu_t;
17142a95308bSMatthias Ringwald
btstack_memory_mesh_upper_transport_pdu_get(void)1715491f99b3SMatthias Ringwald mesh_upper_transport_pdu_t * btstack_memory_mesh_upper_transport_pdu_get(void){
17162a95308bSMatthias Ringwald btstack_memory_mesh_upper_transport_pdu_t * buffer = (btstack_memory_mesh_upper_transport_pdu_t *) malloc(sizeof(btstack_memory_mesh_upper_transport_pdu_t));
1717491f99b3SMatthias Ringwald if (buffer){
1718798bd46fSMatthias Ringwald memset(buffer, 0, sizeof(btstack_memory_mesh_upper_transport_pdu_t));
17192a95308bSMatthias Ringwald btstack_memory_tracking_add(&buffer->tracking);
17202a95308bSMatthias Ringwald return &buffer->data;
1721b6269742SMatthias Ringwald } else {
1722b6269742SMatthias Ringwald return NULL;
1723491f99b3SMatthias Ringwald }
1724491f99b3SMatthias Ringwald }
btstack_memory_mesh_upper_transport_pdu_free(mesh_upper_transport_pdu_t * mesh_upper_transport_pdu)1725491f99b3SMatthias Ringwald void btstack_memory_mesh_upper_transport_pdu_free(mesh_upper_transport_pdu_t *mesh_upper_transport_pdu){
1726798bd46fSMatthias Ringwald // reconstruct buffer start
1727798bd46fSMatthias Ringwald btstack_memory_buffer_t * buffer = &((btstack_memory_buffer_t *) mesh_upper_transport_pdu)[-1];
1728798bd46fSMatthias Ringwald btstack_memory_tracking_remove(buffer);
1729b6269742SMatthias Ringwald free(buffer);
1730491f99b3SMatthias Ringwald }
1731491f99b3SMatthias Ringwald #endif
1732491f99b3SMatthias Ringwald
1733491f99b3SMatthias Ringwald
1734c0a711d9SMatthias Ringwald // MARK: mesh_network_key_t
1735c0a711d9SMatthias Ringwald #if !defined(HAVE_MALLOC) && !defined(MAX_NR_MESH_NETWORK_KEYS)
1736c0a711d9SMatthias Ringwald #if defined(MAX_NO_MESH_NETWORK_KEYS)
1737c0a711d9SMatthias Ringwald #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."
1738c0a711d9SMatthias Ringwald #else
1739c0a711d9SMatthias Ringwald #define MAX_NR_MESH_NETWORK_KEYS 0
1740c0a711d9SMatthias Ringwald #endif
1741c0a711d9SMatthias Ringwald #endif
1742c0a711d9SMatthias Ringwald
1743c0a711d9SMatthias Ringwald #ifdef MAX_NR_MESH_NETWORK_KEYS
1744c0a711d9SMatthias Ringwald #if MAX_NR_MESH_NETWORK_KEYS > 0
1745c0a711d9SMatthias Ringwald static mesh_network_key_t mesh_network_key_storage[MAX_NR_MESH_NETWORK_KEYS];
1746c0a711d9SMatthias Ringwald static btstack_memory_pool_t mesh_network_key_pool;
btstack_memory_mesh_network_key_get(void)1747c0a711d9SMatthias Ringwald mesh_network_key_t * btstack_memory_mesh_network_key_get(void){
17481c4e8084SMatthias Ringwald void * buffer = btstack_memory_pool_get(&mesh_network_key_pool);
17491c4e8084SMatthias Ringwald if (buffer){
17501c4e8084SMatthias Ringwald memset(buffer, 0, sizeof(mesh_network_key_t));
17511c4e8084SMatthias Ringwald }
17521c4e8084SMatthias Ringwald return (mesh_network_key_t *) buffer;
1753c0a711d9SMatthias Ringwald }
btstack_memory_mesh_network_key_free(mesh_network_key_t * mesh_network_key)1754c0a711d9SMatthias Ringwald void btstack_memory_mesh_network_key_free(mesh_network_key_t *mesh_network_key){
1755c0a711d9SMatthias Ringwald btstack_memory_pool_free(&mesh_network_key_pool, mesh_network_key);
1756c0a711d9SMatthias Ringwald }
1757c0a711d9SMatthias Ringwald #else
btstack_memory_mesh_network_key_get(void)1758c0a711d9SMatthias Ringwald mesh_network_key_t * btstack_memory_mesh_network_key_get(void){
1759c0a711d9SMatthias Ringwald return NULL;
1760c0a711d9SMatthias Ringwald }
btstack_memory_mesh_network_key_free(mesh_network_key_t * mesh_network_key)1761c0a711d9SMatthias Ringwald void btstack_memory_mesh_network_key_free(mesh_network_key_t *mesh_network_key){
1762b6269742SMatthias Ringwald UNUSED(mesh_network_key);
1763*42a2bbebSMatthias Ringwald }
1764c0a711d9SMatthias Ringwald #endif
1765c0a711d9SMatthias Ringwald #elif defined(HAVE_MALLOC)
17662a95308bSMatthias Ringwald
17672a95308bSMatthias Ringwald typedef struct {
17682a95308bSMatthias Ringwald btstack_memory_buffer_t tracking;
1769798bd46fSMatthias Ringwald mesh_network_key_t data;
17702a95308bSMatthias Ringwald } btstack_memory_mesh_network_key_t;
17712a95308bSMatthias Ringwald
btstack_memory_mesh_network_key_get(void)1772c0a711d9SMatthias Ringwald mesh_network_key_t * btstack_memory_mesh_network_key_get(void){
17732a95308bSMatthias Ringwald btstack_memory_mesh_network_key_t * buffer = (btstack_memory_mesh_network_key_t *) malloc(sizeof(btstack_memory_mesh_network_key_t));
17741c4e8084SMatthias Ringwald if (buffer){
1775798bd46fSMatthias Ringwald memset(buffer, 0, sizeof(btstack_memory_mesh_network_key_t));
17762a95308bSMatthias Ringwald btstack_memory_tracking_add(&buffer->tracking);
17772a95308bSMatthias Ringwald return &buffer->data;
1778b6269742SMatthias Ringwald } else {
1779b6269742SMatthias Ringwald return NULL;
17801c4e8084SMatthias Ringwald }
1781c0a711d9SMatthias Ringwald }
btstack_memory_mesh_network_key_free(mesh_network_key_t * mesh_network_key)1782c0a711d9SMatthias Ringwald void btstack_memory_mesh_network_key_free(mesh_network_key_t *mesh_network_key){
1783798bd46fSMatthias Ringwald // reconstruct buffer start
1784798bd46fSMatthias Ringwald btstack_memory_buffer_t * buffer = &((btstack_memory_buffer_t *) mesh_network_key)[-1];
1785798bd46fSMatthias Ringwald btstack_memory_tracking_remove(buffer);
1786b6269742SMatthias Ringwald free(buffer);
1787c0a711d9SMatthias Ringwald }
1788c0a711d9SMatthias Ringwald #endif
1789c0a711d9SMatthias Ringwald
1790c0a711d9SMatthias Ringwald
179101e2bf94SMatthias Ringwald // MARK: mesh_transport_key_t
179201e2bf94SMatthias Ringwald #if !defined(HAVE_MALLOC) && !defined(MAX_NR_MESH_TRANSPORT_KEYS)
179301e2bf94SMatthias Ringwald #if defined(MAX_NO_MESH_TRANSPORT_KEYS)
179401e2bf94SMatthias Ringwald #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."
179501e2bf94SMatthias Ringwald #else
179601e2bf94SMatthias Ringwald #define MAX_NR_MESH_TRANSPORT_KEYS 0
179701e2bf94SMatthias Ringwald #endif
179801e2bf94SMatthias Ringwald #endif
179901e2bf94SMatthias Ringwald
180001e2bf94SMatthias Ringwald #ifdef MAX_NR_MESH_TRANSPORT_KEYS
180101e2bf94SMatthias Ringwald #if MAX_NR_MESH_TRANSPORT_KEYS > 0
180201e2bf94SMatthias Ringwald static mesh_transport_key_t mesh_transport_key_storage[MAX_NR_MESH_TRANSPORT_KEYS];
180301e2bf94SMatthias Ringwald static btstack_memory_pool_t mesh_transport_key_pool;
btstack_memory_mesh_transport_key_get(void)180401e2bf94SMatthias Ringwald mesh_transport_key_t * btstack_memory_mesh_transport_key_get(void){
180501e2bf94SMatthias Ringwald void * buffer = btstack_memory_pool_get(&mesh_transport_key_pool);
180601e2bf94SMatthias Ringwald if (buffer){
180701e2bf94SMatthias Ringwald memset(buffer, 0, sizeof(mesh_transport_key_t));
180801e2bf94SMatthias Ringwald }
180901e2bf94SMatthias Ringwald return (mesh_transport_key_t *) buffer;
181001e2bf94SMatthias Ringwald }
btstack_memory_mesh_transport_key_free(mesh_transport_key_t * mesh_transport_key)181101e2bf94SMatthias Ringwald void btstack_memory_mesh_transport_key_free(mesh_transport_key_t *mesh_transport_key){
181201e2bf94SMatthias Ringwald btstack_memory_pool_free(&mesh_transport_key_pool, mesh_transport_key);
181301e2bf94SMatthias Ringwald }
181401e2bf94SMatthias Ringwald #else
btstack_memory_mesh_transport_key_get(void)181501e2bf94SMatthias Ringwald mesh_transport_key_t * btstack_memory_mesh_transport_key_get(void){
181601e2bf94SMatthias Ringwald return NULL;
181701e2bf94SMatthias Ringwald }
btstack_memory_mesh_transport_key_free(mesh_transport_key_t * mesh_transport_key)181801e2bf94SMatthias Ringwald void btstack_memory_mesh_transport_key_free(mesh_transport_key_t *mesh_transport_key){
1819b6269742SMatthias Ringwald UNUSED(mesh_transport_key);
1820*42a2bbebSMatthias Ringwald }
182101e2bf94SMatthias Ringwald #endif
182201e2bf94SMatthias Ringwald #elif defined(HAVE_MALLOC)
18232a95308bSMatthias Ringwald
18242a95308bSMatthias Ringwald typedef struct {
18252a95308bSMatthias Ringwald btstack_memory_buffer_t tracking;
1826798bd46fSMatthias Ringwald mesh_transport_key_t data;
18272a95308bSMatthias Ringwald } btstack_memory_mesh_transport_key_t;
18282a95308bSMatthias Ringwald
btstack_memory_mesh_transport_key_get(void)182901e2bf94SMatthias Ringwald mesh_transport_key_t * btstack_memory_mesh_transport_key_get(void){
18302a95308bSMatthias Ringwald btstack_memory_mesh_transport_key_t * buffer = (btstack_memory_mesh_transport_key_t *) malloc(sizeof(btstack_memory_mesh_transport_key_t));
183101e2bf94SMatthias Ringwald if (buffer){
1832798bd46fSMatthias Ringwald memset(buffer, 0, sizeof(btstack_memory_mesh_transport_key_t));
18332a95308bSMatthias Ringwald btstack_memory_tracking_add(&buffer->tracking);
18342a95308bSMatthias Ringwald return &buffer->data;
1835b6269742SMatthias Ringwald } else {
1836b6269742SMatthias Ringwald return NULL;
183701e2bf94SMatthias Ringwald }
183801e2bf94SMatthias Ringwald }
btstack_memory_mesh_transport_key_free(mesh_transport_key_t * mesh_transport_key)183901e2bf94SMatthias Ringwald void btstack_memory_mesh_transport_key_free(mesh_transport_key_t *mesh_transport_key){
1840798bd46fSMatthias Ringwald // reconstruct buffer start
1841798bd46fSMatthias Ringwald btstack_memory_buffer_t * buffer = &((btstack_memory_buffer_t *) mesh_transport_key)[-1];
1842798bd46fSMatthias Ringwald btstack_memory_tracking_remove(buffer);
1843b6269742SMatthias Ringwald free(buffer);
184401e2bf94SMatthias Ringwald }
184501e2bf94SMatthias Ringwald #endif
184601e2bf94SMatthias Ringwald
184701e2bf94SMatthias Ringwald
18481f45d603SMatthias Ringwald // MARK: mesh_virtual_address_t
18491f45d603SMatthias Ringwald #if !defined(HAVE_MALLOC) && !defined(MAX_NR_MESH_VIRTUAL_ADDRESSS)
18501f45d603SMatthias Ringwald #if defined(MAX_NO_MESH_VIRTUAL_ADDRESSS)
18511f45d603SMatthias Ringwald #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."
18521f45d603SMatthias Ringwald #else
18531f45d603SMatthias Ringwald #define MAX_NR_MESH_VIRTUAL_ADDRESSS 0
18541f45d603SMatthias Ringwald #endif
18551f45d603SMatthias Ringwald #endif
18561f45d603SMatthias Ringwald
18571f45d603SMatthias Ringwald #ifdef MAX_NR_MESH_VIRTUAL_ADDRESSS
18581f45d603SMatthias Ringwald #if MAX_NR_MESH_VIRTUAL_ADDRESSS > 0
18591f45d603SMatthias Ringwald static mesh_virtual_address_t mesh_virtual_address_storage[MAX_NR_MESH_VIRTUAL_ADDRESSS];
18601f45d603SMatthias Ringwald static btstack_memory_pool_t mesh_virtual_address_pool;
btstack_memory_mesh_virtual_address_get(void)18611f45d603SMatthias Ringwald mesh_virtual_address_t * btstack_memory_mesh_virtual_address_get(void){
18621f45d603SMatthias Ringwald void * buffer = btstack_memory_pool_get(&mesh_virtual_address_pool);
18631f45d603SMatthias Ringwald if (buffer){
18641f45d603SMatthias Ringwald memset(buffer, 0, sizeof(mesh_virtual_address_t));
18651f45d603SMatthias Ringwald }
18661f45d603SMatthias Ringwald return (mesh_virtual_address_t *) buffer;
18671f45d603SMatthias Ringwald }
btstack_memory_mesh_virtual_address_free(mesh_virtual_address_t * mesh_virtual_address)18681f45d603SMatthias Ringwald void btstack_memory_mesh_virtual_address_free(mesh_virtual_address_t *mesh_virtual_address){
18691f45d603SMatthias Ringwald btstack_memory_pool_free(&mesh_virtual_address_pool, mesh_virtual_address);
18701f45d603SMatthias Ringwald }
18711f45d603SMatthias Ringwald #else
btstack_memory_mesh_virtual_address_get(void)18721f45d603SMatthias Ringwald mesh_virtual_address_t * btstack_memory_mesh_virtual_address_get(void){
18731f45d603SMatthias Ringwald return NULL;
18741f45d603SMatthias Ringwald }
btstack_memory_mesh_virtual_address_free(mesh_virtual_address_t * mesh_virtual_address)18751f45d603SMatthias Ringwald void btstack_memory_mesh_virtual_address_free(mesh_virtual_address_t *mesh_virtual_address){
1876b6269742SMatthias Ringwald UNUSED(mesh_virtual_address);
1877*42a2bbebSMatthias Ringwald }
18781f45d603SMatthias Ringwald #endif
18791f45d603SMatthias Ringwald #elif defined(HAVE_MALLOC)
18802a95308bSMatthias Ringwald
18812a95308bSMatthias Ringwald typedef struct {
18822a95308bSMatthias Ringwald btstack_memory_buffer_t tracking;
1883798bd46fSMatthias Ringwald mesh_virtual_address_t data;
18842a95308bSMatthias Ringwald } btstack_memory_mesh_virtual_address_t;
18852a95308bSMatthias Ringwald
btstack_memory_mesh_virtual_address_get(void)18861f45d603SMatthias Ringwald mesh_virtual_address_t * btstack_memory_mesh_virtual_address_get(void){
18872a95308bSMatthias Ringwald btstack_memory_mesh_virtual_address_t * buffer = (btstack_memory_mesh_virtual_address_t *) malloc(sizeof(btstack_memory_mesh_virtual_address_t));
18881f45d603SMatthias Ringwald if (buffer){
1889798bd46fSMatthias Ringwald memset(buffer, 0, sizeof(btstack_memory_mesh_virtual_address_t));
18902a95308bSMatthias Ringwald btstack_memory_tracking_add(&buffer->tracking);
18912a95308bSMatthias Ringwald return &buffer->data;
1892b6269742SMatthias Ringwald } else {
1893b6269742SMatthias Ringwald return NULL;
18941f45d603SMatthias Ringwald }
18951f45d603SMatthias Ringwald }
btstack_memory_mesh_virtual_address_free(mesh_virtual_address_t * mesh_virtual_address)18961f45d603SMatthias Ringwald void btstack_memory_mesh_virtual_address_free(mesh_virtual_address_t *mesh_virtual_address){
1897798bd46fSMatthias Ringwald // reconstruct buffer start
1898798bd46fSMatthias Ringwald btstack_memory_buffer_t * buffer = &((btstack_memory_buffer_t *) mesh_virtual_address)[-1];
1899798bd46fSMatthias Ringwald btstack_memory_tracking_remove(buffer);
1900b6269742SMatthias Ringwald free(buffer);
19011f45d603SMatthias Ringwald }
19021f45d603SMatthias Ringwald #endif
19031f45d603SMatthias Ringwald
19041f45d603SMatthias Ringwald
190501122b73SMatthias Ringwald // MARK: mesh_subnet_t
190601122b73SMatthias Ringwald #if !defined(HAVE_MALLOC) && !defined(MAX_NR_MESH_SUBNETS)
190701122b73SMatthias Ringwald #if defined(MAX_NO_MESH_SUBNETS)
190801122b73SMatthias Ringwald #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."
190901122b73SMatthias Ringwald #else
191001122b73SMatthias Ringwald #define MAX_NR_MESH_SUBNETS 0
191101122b73SMatthias Ringwald #endif
191201122b73SMatthias Ringwald #endif
191301122b73SMatthias Ringwald
191401122b73SMatthias Ringwald #ifdef MAX_NR_MESH_SUBNETS
191501122b73SMatthias Ringwald #if MAX_NR_MESH_SUBNETS > 0
191601122b73SMatthias Ringwald static mesh_subnet_t mesh_subnet_storage[MAX_NR_MESH_SUBNETS];
191701122b73SMatthias Ringwald static btstack_memory_pool_t mesh_subnet_pool;
btstack_memory_mesh_subnet_get(void)191801122b73SMatthias Ringwald mesh_subnet_t * btstack_memory_mesh_subnet_get(void){
191901122b73SMatthias Ringwald void * buffer = btstack_memory_pool_get(&mesh_subnet_pool);
192001122b73SMatthias Ringwald if (buffer){
192101122b73SMatthias Ringwald memset(buffer, 0, sizeof(mesh_subnet_t));
192201122b73SMatthias Ringwald }
192301122b73SMatthias Ringwald return (mesh_subnet_t *) buffer;
192401122b73SMatthias Ringwald }
btstack_memory_mesh_subnet_free(mesh_subnet_t * mesh_subnet)192501122b73SMatthias Ringwald void btstack_memory_mesh_subnet_free(mesh_subnet_t *mesh_subnet){
192601122b73SMatthias Ringwald btstack_memory_pool_free(&mesh_subnet_pool, mesh_subnet);
192701122b73SMatthias Ringwald }
192801122b73SMatthias Ringwald #else
btstack_memory_mesh_subnet_get(void)192901122b73SMatthias Ringwald mesh_subnet_t * btstack_memory_mesh_subnet_get(void){
193001122b73SMatthias Ringwald return NULL;
193101122b73SMatthias Ringwald }
btstack_memory_mesh_subnet_free(mesh_subnet_t * mesh_subnet)193201122b73SMatthias Ringwald void btstack_memory_mesh_subnet_free(mesh_subnet_t *mesh_subnet){
1933b6269742SMatthias Ringwald UNUSED(mesh_subnet);
1934*42a2bbebSMatthias Ringwald }
193501122b73SMatthias Ringwald #endif
193601122b73SMatthias Ringwald #elif defined(HAVE_MALLOC)
19372a95308bSMatthias Ringwald
19382a95308bSMatthias Ringwald typedef struct {
19392a95308bSMatthias Ringwald btstack_memory_buffer_t tracking;
1940798bd46fSMatthias Ringwald mesh_subnet_t data;
19412a95308bSMatthias Ringwald } btstack_memory_mesh_subnet_t;
19422a95308bSMatthias Ringwald
btstack_memory_mesh_subnet_get(void)194301122b73SMatthias Ringwald mesh_subnet_t * btstack_memory_mesh_subnet_get(void){
19442a95308bSMatthias Ringwald btstack_memory_mesh_subnet_t * buffer = (btstack_memory_mesh_subnet_t *) malloc(sizeof(btstack_memory_mesh_subnet_t));
194501122b73SMatthias Ringwald if (buffer){
1946798bd46fSMatthias Ringwald memset(buffer, 0, sizeof(btstack_memory_mesh_subnet_t));
19472a95308bSMatthias Ringwald btstack_memory_tracking_add(&buffer->tracking);
19482a95308bSMatthias Ringwald return &buffer->data;
1949b6269742SMatthias Ringwald } else {
1950b6269742SMatthias Ringwald return NULL;
195101122b73SMatthias Ringwald }
195201122b73SMatthias Ringwald }
btstack_memory_mesh_subnet_free(mesh_subnet_t * mesh_subnet)195301122b73SMatthias Ringwald void btstack_memory_mesh_subnet_free(mesh_subnet_t *mesh_subnet){
1954798bd46fSMatthias Ringwald // reconstruct buffer start
1955798bd46fSMatthias Ringwald btstack_memory_buffer_t * buffer = &((btstack_memory_buffer_t *) mesh_subnet)[-1];
1956798bd46fSMatthias Ringwald btstack_memory_tracking_remove(buffer);
1957b6269742SMatthias Ringwald free(buffer);
195801122b73SMatthias Ringwald }
195901122b73SMatthias Ringwald #endif
196001122b73SMatthias Ringwald
196101122b73SMatthias Ringwald
19622e97c149S[email protected] #endif
1963b6ac006aSMatthias Ringwald #ifdef ENABLE_LE_ISOCHRONOUS_STREAMS
1964b6ac006aSMatthias Ringwald
1965b6ac006aSMatthias Ringwald // MARK: hci_iso_stream_t
1966b6ac006aSMatthias Ringwald #if !defined(HAVE_MALLOC) && !defined(MAX_NR_HCI_ISO_STREAMS)
1967b6ac006aSMatthias Ringwald #if defined(MAX_NO_HCI_ISO_STREAMS)
1968b6ac006aSMatthias Ringwald #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."
1969b6ac006aSMatthias Ringwald #else
1970b6ac006aSMatthias Ringwald #define MAX_NR_HCI_ISO_STREAMS 0
1971b6ac006aSMatthias Ringwald #endif
1972b6ac006aSMatthias Ringwald #endif
1973b6ac006aSMatthias Ringwald
1974b6ac006aSMatthias Ringwald #ifdef MAX_NR_HCI_ISO_STREAMS
1975b6ac006aSMatthias Ringwald #if MAX_NR_HCI_ISO_STREAMS > 0
1976b6ac006aSMatthias Ringwald static hci_iso_stream_t hci_iso_stream_storage[MAX_NR_HCI_ISO_STREAMS];
1977b6ac006aSMatthias Ringwald static btstack_memory_pool_t hci_iso_stream_pool;
btstack_memory_hci_iso_stream_get(void)1978b6ac006aSMatthias Ringwald hci_iso_stream_t * btstack_memory_hci_iso_stream_get(void){
1979b6ac006aSMatthias Ringwald void * buffer = btstack_memory_pool_get(&hci_iso_stream_pool);
1980b6ac006aSMatthias Ringwald if (buffer){
1981b6ac006aSMatthias Ringwald memset(buffer, 0, sizeof(hci_iso_stream_t));
1982b6ac006aSMatthias Ringwald }
1983b6ac006aSMatthias Ringwald return (hci_iso_stream_t *) buffer;
1984b6ac006aSMatthias Ringwald }
btstack_memory_hci_iso_stream_free(hci_iso_stream_t * hci_iso_stream)1985b6ac006aSMatthias Ringwald void btstack_memory_hci_iso_stream_free(hci_iso_stream_t *hci_iso_stream){
1986b6ac006aSMatthias Ringwald btstack_memory_pool_free(&hci_iso_stream_pool, hci_iso_stream);
1987b6ac006aSMatthias Ringwald }
1988b6ac006aSMatthias Ringwald #else
btstack_memory_hci_iso_stream_get(void)1989b6ac006aSMatthias Ringwald hci_iso_stream_t * btstack_memory_hci_iso_stream_get(void){
1990b6ac006aSMatthias Ringwald return NULL;
1991b6ac006aSMatthias Ringwald }
btstack_memory_hci_iso_stream_free(hci_iso_stream_t * hci_iso_stream)1992b6ac006aSMatthias Ringwald void btstack_memory_hci_iso_stream_free(hci_iso_stream_t *hci_iso_stream){
1993b6ac006aSMatthias Ringwald UNUSED(hci_iso_stream);
1994*42a2bbebSMatthias Ringwald }
1995b6ac006aSMatthias Ringwald #endif
1996b6ac006aSMatthias Ringwald #elif defined(HAVE_MALLOC)
1997b6ac006aSMatthias Ringwald
1998b6ac006aSMatthias Ringwald typedef struct {
1999b6ac006aSMatthias Ringwald btstack_memory_buffer_t tracking;
2000b6ac006aSMatthias Ringwald hci_iso_stream_t data;
2001b6ac006aSMatthias Ringwald } btstack_memory_hci_iso_stream_t;
2002b6ac006aSMatthias Ringwald
btstack_memory_hci_iso_stream_get(void)2003b6ac006aSMatthias Ringwald hci_iso_stream_t * btstack_memory_hci_iso_stream_get(void){
2004b6ac006aSMatthias Ringwald btstack_memory_hci_iso_stream_t * buffer = (btstack_memory_hci_iso_stream_t *) malloc(sizeof(btstack_memory_hci_iso_stream_t));
2005b6ac006aSMatthias Ringwald if (buffer){
2006b6ac006aSMatthias Ringwald memset(buffer, 0, sizeof(btstack_memory_hci_iso_stream_t));
2007b6ac006aSMatthias Ringwald btstack_memory_tracking_add(&buffer->tracking);
2008b6ac006aSMatthias Ringwald return &buffer->data;
2009b6ac006aSMatthias Ringwald } else {
2010b6ac006aSMatthias Ringwald return NULL;
2011b6ac006aSMatthias Ringwald }
2012b6ac006aSMatthias Ringwald }
btstack_memory_hci_iso_stream_free(hci_iso_stream_t * hci_iso_stream)2013b6ac006aSMatthias Ringwald void btstack_memory_hci_iso_stream_free(hci_iso_stream_t *hci_iso_stream){
2014b6ac006aSMatthias Ringwald // reconstruct buffer start
2015b6ac006aSMatthias Ringwald btstack_memory_buffer_t * buffer = &((btstack_memory_buffer_t *) hci_iso_stream)[-1];
2016b6ac006aSMatthias Ringwald btstack_memory_tracking_remove(buffer);
2017b6ac006aSMatthias Ringwald free(buffer);
2018b6ac006aSMatthias Ringwald }
2019b6ac006aSMatthias Ringwald #endif
2020b6ac006aSMatthias Ringwald
2021b6ac006aSMatthias Ringwald
2022b6ac006aSMatthias Ringwald #endif
2023798bd46fSMatthias Ringwald
2024a3b02b71Smatthias.ringwald // init
btstack_memory_init(void)2025a3b02b71Smatthias.ringwald void btstack_memory_init(void){
2026798bd46fSMatthias Ringwald #ifdef HAVE_MALLOC
2027798bd46fSMatthias Ringwald // assert that there is no unexpected padding for combined buffer
2028798bd46fSMatthias Ringwald btstack_assert(sizeof(test_buffer_t) == sizeof(btstack_memory_buffer_t) + sizeof(void *));
2029798bd46fSMatthias Ringwald #endif
2030798bd46fSMatthias Ringwald
2031a265b909SMatthias Ringwald #if MAX_NR_HCI_CONNECTIONS > 0
2032a265b909SMatthias Ringwald btstack_memory_pool_create(&hci_connection_pool, hci_connection_storage, MAX_NR_HCI_CONNECTIONS, sizeof(hci_connection_t));
2033a3b02b71Smatthias.ringwald #endif
20342281ada7SMatthias Ringwald
2035a265b909SMatthias Ringwald #if MAX_NR_L2CAP_SERVICES > 0
2036a265b909SMatthias Ringwald btstack_memory_pool_create(&l2cap_service_pool, l2cap_service_storage, MAX_NR_L2CAP_SERVICES, sizeof(l2cap_service_t));
2037a3b02b71Smatthias.ringwald #endif
2038a265b909SMatthias Ringwald #if MAX_NR_L2CAP_CHANNELS > 0
2039a265b909SMatthias Ringwald btstack_memory_pool_create(&l2cap_channel_pool, l2cap_channel_storage, MAX_NR_L2CAP_CHANNELS, sizeof(l2cap_channel_t));
2040a3b02b71Smatthias.ringwald #endif
20412281ada7SMatthias Ringwald
204244c5d856SMatthias Ringwald #ifdef ENABLE_CLASSIC
204350dc57fcSMatthias Ringwald #if MAX_NR_RFCOMM_MULTIPLEXERS > 0
204450dc57fcSMatthias Ringwald btstack_memory_pool_create(&rfcomm_multiplexer_pool, rfcomm_multiplexer_storage, MAX_NR_RFCOMM_MULTIPLEXERS, sizeof(rfcomm_multiplexer_t));
2045a3b02b71Smatthias.ringwald #endif
204650dc57fcSMatthias Ringwald #if MAX_NR_RFCOMM_SERVICES > 0
204750dc57fcSMatthias Ringwald btstack_memory_pool_create(&rfcomm_service_pool, rfcomm_service_storage, MAX_NR_RFCOMM_SERVICES, sizeof(rfcomm_service_t));
2048a3b02b71Smatthias.ringwald #endif
204950dc57fcSMatthias Ringwald #if MAX_NR_RFCOMM_CHANNELS > 0
205050dc57fcSMatthias Ringwald btstack_memory_pool_create(&rfcomm_channel_pool, rfcomm_channel_storage, MAX_NR_RFCOMM_CHANNELS, sizeof(rfcomm_channel_t));
205150dc57fcSMatthias Ringwald #endif
20522281ada7SMatthias Ringwald
205350dc57fcSMatthias Ringwald #if MAX_NR_BTSTACK_LINK_KEY_DB_MEMORY_ENTRIES > 0
205450dc57fcSMatthias Ringwald btstack_memory_pool_create(&btstack_link_key_db_memory_entry_pool, btstack_link_key_db_memory_entry_storage, MAX_NR_BTSTACK_LINK_KEY_DB_MEMORY_ENTRIES, sizeof(btstack_link_key_db_memory_entry_t));
205550dc57fcSMatthias Ringwald #endif
20562281ada7SMatthias Ringwald
205750dc57fcSMatthias Ringwald #if MAX_NR_BNEP_SERVICES > 0
205850dc57fcSMatthias Ringwald btstack_memory_pool_create(&bnep_service_pool, bnep_service_storage, MAX_NR_BNEP_SERVICES, sizeof(bnep_service_t));
205950dc57fcSMatthias Ringwald #endif
206050dc57fcSMatthias Ringwald #if MAX_NR_BNEP_CHANNELS > 0
206150dc57fcSMatthias Ringwald btstack_memory_pool_create(&bnep_channel_pool, bnep_channel_storage, MAX_NR_BNEP_CHANNELS, sizeof(bnep_channel_t));
206250dc57fcSMatthias Ringwald #endif
20632281ada7SMatthias Ringwald
2064b8c00949SMatthias Ringwald #if MAX_NR_GOEP_SERVER_SERVICES > 0
2065b8c00949SMatthias Ringwald btstack_memory_pool_create(&goep_server_service_pool, goep_server_service_storage, MAX_NR_GOEP_SERVER_SERVICES, sizeof(goep_server_service_t));
2066b8c00949SMatthias Ringwald #endif
2067b8c00949SMatthias Ringwald #if MAX_NR_GOEP_SERVER_CONNECTIONS > 0
2068b8c00949SMatthias Ringwald btstack_memory_pool_create(&goep_server_connection_pool, goep_server_connection_storage, MAX_NR_GOEP_SERVER_CONNECTIONS, sizeof(goep_server_connection_t));
2069b8c00949SMatthias Ringwald #endif
20702281ada7SMatthias Ringwald
207150dc57fcSMatthias Ringwald #if MAX_NR_HFP_CONNECTIONS > 0
207250dc57fcSMatthias Ringwald btstack_memory_pool_create(&hfp_connection_pool, hfp_connection_storage, MAX_NR_HFP_CONNECTIONS, sizeof(hfp_connection_t));
207350dc57fcSMatthias Ringwald #endif
20742281ada7SMatthias Ringwald
2075f399f7fbSMilanka Ringwald #if MAX_NR_HID_HOST_CONNECTIONS > 0
2076f399f7fbSMilanka Ringwald btstack_memory_pool_create(&hid_host_connection_pool, hid_host_connection_storage, MAX_NR_HID_HOST_CONNECTIONS, sizeof(hid_host_connection_t));
2077f399f7fbSMilanka Ringwald #endif
20782281ada7SMatthias Ringwald
20796fd2a92aSMatthias Ringwald #if MAX_NR_SERVICE_RECORD_ITEMS > 0
20806fd2a92aSMatthias Ringwald btstack_memory_pool_create(&service_record_item_pool, service_record_item_storage, MAX_NR_SERVICE_RECORD_ITEMS, sizeof(service_record_item_t));
20816fd2a92aSMatthias Ringwald #endif
20822281ada7SMatthias Ringwald
208350dc57fcSMatthias Ringwald #if MAX_NR_AVDTP_STREAM_ENDPOINTS > 0
208450dc57fcSMatthias Ringwald btstack_memory_pool_create(&avdtp_stream_endpoint_pool, avdtp_stream_endpoint_storage, MAX_NR_AVDTP_STREAM_ENDPOINTS, sizeof(avdtp_stream_endpoint_t));
208550dc57fcSMatthias Ringwald #endif
20862281ada7SMatthias Ringwald
208750dc57fcSMatthias Ringwald #if MAX_NR_AVDTP_CONNECTIONS > 0
208850dc57fcSMatthias Ringwald btstack_memory_pool_create(&avdtp_connection_pool, avdtp_connection_storage, MAX_NR_AVDTP_CONNECTIONS, sizeof(avdtp_connection_t));
208950dc57fcSMatthias Ringwald #endif
20902281ada7SMatthias Ringwald
209150dc57fcSMatthias Ringwald #if MAX_NR_AVRCP_CONNECTIONS > 0
209250dc57fcSMatthias Ringwald btstack_memory_pool_create(&avrcp_connection_pool, avrcp_connection_storage, MAX_NR_AVRCP_CONNECTIONS, sizeof(avrcp_connection_t));
209350dc57fcSMatthias Ringwald #endif
20942281ada7SMatthias Ringwald
209550dc57fcSMatthias Ringwald #if MAX_NR_AVRCP_BROWSING_CONNECTIONS > 0
209650dc57fcSMatthias Ringwald btstack_memory_pool_create(&avrcp_browsing_connection_pool, avrcp_browsing_connection_storage, MAX_NR_AVRCP_BROWSING_CONNECTIONS, sizeof(avrcp_browsing_connection_t));
2097a3b02b71Smatthias.ringwald #endif
20982281ada7SMatthias Ringwald
2099f12a3722SMilanka Ringwald #endif
2100a9a4c409SMatthias Ringwald #ifdef ENABLE_BLE
2101174a0c1cSMilanka Ringwald #if MAX_NR_BATTERY_SERVICE_CLIENTS > 0
2102174a0c1cSMilanka Ringwald btstack_memory_pool_create(&battery_service_client_pool, battery_service_client_storage, MAX_NR_BATTERY_SERVICE_CLIENTS, sizeof(battery_service_client_t));
2103174a0c1cSMilanka Ringwald #endif
2104a265b909SMatthias Ringwald #if MAX_NR_GATT_CLIENTS > 0
2105a265b909SMatthias Ringwald btstack_memory_pool_create(&gatt_client_pool, gatt_client_storage, MAX_NR_GATT_CLIENTS, sizeof(gatt_client_t));
2106d0fdae3cS[email protected] #endif
2107cf26c8fbSMilanka Ringwald #if MAX_NR_HIDS_CLIENTS > 0
2108cf26c8fbSMilanka Ringwald btstack_memory_pool_create(&hids_client_pool, hids_client_storage, MAX_NR_HIDS_CLIENTS, sizeof(hids_client_t));
2109cf26c8fbSMilanka Ringwald #endif
2110cf26c8fbSMilanka Ringwald #if MAX_NR_SCAN_PARAMETERS_SERVICE_CLIENTS > 0
2111cf26c8fbSMilanka Ringwald 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));
2112cf26c8fbSMilanka Ringwald #endif
2113a265b909SMatthias Ringwald #if MAX_NR_SM_LOOKUP_ENTRIES > 0
2114a265b909SMatthias Ringwald btstack_memory_pool_create(&sm_lookup_entry_pool, sm_lookup_entry_storage, MAX_NR_SM_LOOKUP_ENTRIES, sizeof(sm_lookup_entry_t));
2115cf49570bSMatthias Ringwald #endif
2116174a0c1cSMilanka Ringwald #if MAX_NR_WHITELIST_ENTRIES > 0
2117174a0c1cSMilanka Ringwald btstack_memory_pool_create(&whitelist_entry_pool, whitelist_entry_storage, MAX_NR_WHITELIST_ENTRIES, sizeof(whitelist_entry_t));
2118174a0c1cSMilanka Ringwald #endif
2119dbca66ffSMatthias Ringwald #if MAX_NR_PERIODIC_ADVERTISER_LIST_ENTRIES > 0
2120dbca66ffSMatthias Ringwald 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));
2121dbca66ffSMatthias Ringwald #endif
21222281ada7SMatthias Ringwald
2123ebb73e1fSMatthias Ringwald #endif
212444c5d856SMatthias Ringwald #ifdef ENABLE_MESH
212550dc57fcSMatthias Ringwald #if MAX_NR_MESH_NETWORK_PDUS > 0
212650dc57fcSMatthias Ringwald btstack_memory_pool_create(&mesh_network_pdu_pool, mesh_network_pdu_storage, MAX_NR_MESH_NETWORK_PDUS, sizeof(mesh_network_pdu_t));
212744c5d856SMatthias Ringwald #endif
2128a4bbc09dSMatthias Ringwald #if MAX_NR_MESH_SEGMENTED_PDUS > 0
2129a4bbc09dSMatthias Ringwald btstack_memory_pool_create(&mesh_segmented_pdu_pool, mesh_segmented_pdu_storage, MAX_NR_MESH_SEGMENTED_PDUS, sizeof(mesh_segmented_pdu_t));
2130f7434c1fSMatthias Ringwald #endif
2131491f99b3SMatthias Ringwald #if MAX_NR_MESH_UPPER_TRANSPORT_PDUS > 0
2132491f99b3SMatthias Ringwald 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));
2133491f99b3SMatthias Ringwald #endif
213450dc57fcSMatthias Ringwald #if MAX_NR_MESH_NETWORK_KEYS > 0
213550dc57fcSMatthias Ringwald btstack_memory_pool_create(&mesh_network_key_pool, mesh_network_key_storage, MAX_NR_MESH_NETWORK_KEYS, sizeof(mesh_network_key_t));
2136c0a711d9SMatthias Ringwald #endif
213701e2bf94SMatthias Ringwald #if MAX_NR_MESH_TRANSPORT_KEYS > 0
213801e2bf94SMatthias Ringwald btstack_memory_pool_create(&mesh_transport_key_pool, mesh_transport_key_storage, MAX_NR_MESH_TRANSPORT_KEYS, sizeof(mesh_transport_key_t));
213901e2bf94SMatthias Ringwald #endif
21401f45d603SMatthias Ringwald #if MAX_NR_MESH_VIRTUAL_ADDRESSS > 0
21411f45d603SMatthias Ringwald btstack_memory_pool_create(&mesh_virtual_address_pool, mesh_virtual_address_storage, MAX_NR_MESH_VIRTUAL_ADDRESSS, sizeof(mesh_virtual_address_t));
21421f45d603SMatthias Ringwald #endif
214301122b73SMatthias Ringwald #if MAX_NR_MESH_SUBNETS > 0
214401122b73SMatthias Ringwald btstack_memory_pool_create(&mesh_subnet_pool, mesh_subnet_storage, MAX_NR_MESH_SUBNETS, sizeof(mesh_subnet_t));
214501122b73SMatthias Ringwald #endif
21462281ada7SMatthias Ringwald
2147a7d12effS[email protected] #endif
2148b6ac006aSMatthias Ringwald #ifdef ENABLE_LE_ISOCHRONOUS_STREAMS
2149b6ac006aSMatthias Ringwald #if MAX_NR_HCI_ISO_STREAMS > 0
2150b6ac006aSMatthias Ringwald btstack_memory_pool_create(&hci_iso_stream_pool, hci_iso_stream_storage, MAX_NR_HCI_ISO_STREAMS, sizeof(hci_iso_stream_t));
2151b6ac006aSMatthias Ringwald #endif
2152b6ac006aSMatthias Ringwald
2153b6ac006aSMatthias Ringwald #endif
2154a3b02b71Smatthias.ringwald }
2155