btstack_memory.c (f12a3722fc85b5ee7c999fffc84d872d20325944) btstack_memory.c (a2673d881087910a9937a97706356e76c5cc5ab6)
1/*
2 * Copyright (C) 2014 BlueKitchen GmbH
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
6 * are met:
7 *
8 * 1. Redistributions of source code must retain the above copyright

--- 28 unchanged lines hidden (view full) ---

37
38
39/*
40 * btstack_memory.h
41 *
42 * @brief BTstack memory management via configurable memory pools
43 *
44 * @note code generated by tool/btstack_memory_generator.py
1/*
2 * Copyright (C) 2014 BlueKitchen GmbH
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
6 * are met:
7 *
8 * 1. Redistributions of source code must retain the above copyright

--- 28 unchanged lines hidden (view full) ---

37
38
39/*
40 * btstack_memory.h
41 *
42 * @brief BTstack memory management via configurable memory pools
43 *
44 * @note code generated by tool/btstack_memory_generator.py
45 * @note returnes buffers are initialized with 0
45 *
46 */
47
48#include "btstack_memory.h"
49#include "btstack_memory_pool.h"
50
51#include <stdlib.h>
52

--- 8 unchanged lines hidden (view full) ---

61 #endif
62#endif
63
64#ifdef MAX_NR_HCI_CONNECTIONS
65#if MAX_NR_HCI_CONNECTIONS > 0
66static hci_connection_t hci_connection_storage[MAX_NR_HCI_CONNECTIONS];
67static btstack_memory_pool_t hci_connection_pool;
68hci_connection_t * btstack_memory_hci_connection_get(void){
46 *
47 */
48
49#include "btstack_memory.h"
50#include "btstack_memory_pool.h"
51
52#include <stdlib.h>
53

--- 8 unchanged lines hidden (view full) ---

62 #endif
63#endif
64
65#ifdef MAX_NR_HCI_CONNECTIONS
66#if MAX_NR_HCI_CONNECTIONS > 0
67static hci_connection_t hci_connection_storage[MAX_NR_HCI_CONNECTIONS];
68static btstack_memory_pool_t hci_connection_pool;
69hci_connection_t * btstack_memory_hci_connection_get(void){
69 return (hci_connection_t *) btstack_memory_pool_get(&hci_connection_pool);
70 void * buffer = btstack_memory_pool_get(&hci_connection_pool);
71 if (buffer){
72 memset(buffer, 0, sizeof(hci_connection_t));
73 }
74 return (hci_connection_t *) buffer;
70}
71void btstack_memory_hci_connection_free(hci_connection_t *hci_connection){
72 btstack_memory_pool_free(&hci_connection_pool, hci_connection);
73}
74#else
75hci_connection_t * btstack_memory_hci_connection_get(void){
76 return NULL;
77}
78void btstack_memory_hci_connection_free(hci_connection_t *hci_connection){
79 // silence compiler warning about unused parameter in a portable way
80 (void) hci_connection;
81};
82#endif
83#elif defined(HAVE_MALLOC)
84hci_connection_t * btstack_memory_hci_connection_get(void){
75}
76void btstack_memory_hci_connection_free(hci_connection_t *hci_connection){
77 btstack_memory_pool_free(&hci_connection_pool, hci_connection);
78}
79#else
80hci_connection_t * btstack_memory_hci_connection_get(void){
81 return NULL;
82}
83void btstack_memory_hci_connection_free(hci_connection_t *hci_connection){
84 // silence compiler warning about unused parameter in a portable way
85 (void) hci_connection;
86};
87#endif
88#elif defined(HAVE_MALLOC)
89hci_connection_t * btstack_memory_hci_connection_get(void){
85 return (hci_connection_t*) malloc(sizeof(hci_connection_t));
90 void * buffer = malloc(sizeof(hci_connection_t));
91 if (buffer){
92 memset(buffer, 0, sizeof(hci_connection_t));
93 }
94 return (hci_connection_t *) buffer;
86}
87void btstack_memory_hci_connection_free(hci_connection_t *hci_connection){
88 free(hci_connection);
89}
90#endif
91
92
93

--- 6 unchanged lines hidden (view full) ---

100 #endif
101#endif
102
103#ifdef MAX_NR_L2CAP_SERVICES
104#if MAX_NR_L2CAP_SERVICES > 0
105static l2cap_service_t l2cap_service_storage[MAX_NR_L2CAP_SERVICES];
106static btstack_memory_pool_t l2cap_service_pool;
107l2cap_service_t * btstack_memory_l2cap_service_get(void){
95}
96void btstack_memory_hci_connection_free(hci_connection_t *hci_connection){
97 free(hci_connection);
98}
99#endif
100
101
102

--- 6 unchanged lines hidden (view full) ---

109 #endif
110#endif
111
112#ifdef MAX_NR_L2CAP_SERVICES
113#if MAX_NR_L2CAP_SERVICES > 0
114static l2cap_service_t l2cap_service_storage[MAX_NR_L2CAP_SERVICES];
115static btstack_memory_pool_t l2cap_service_pool;
116l2cap_service_t * btstack_memory_l2cap_service_get(void){
108 return (l2cap_service_t *) btstack_memory_pool_get(&l2cap_service_pool);
117 void * buffer = btstack_memory_pool_get(&l2cap_service_pool);
118 if (buffer){
119 memset(buffer, 0, sizeof(l2cap_service_t));
120 }
121 return (l2cap_service_t *) buffer;
109}
110void btstack_memory_l2cap_service_free(l2cap_service_t *l2cap_service){
111 btstack_memory_pool_free(&l2cap_service_pool, l2cap_service);
112}
113#else
114l2cap_service_t * btstack_memory_l2cap_service_get(void){
115 return NULL;
116}
117void btstack_memory_l2cap_service_free(l2cap_service_t *l2cap_service){
118 // silence compiler warning about unused parameter in a portable way
119 (void) l2cap_service;
120};
121#endif
122#elif defined(HAVE_MALLOC)
123l2cap_service_t * btstack_memory_l2cap_service_get(void){
122}
123void btstack_memory_l2cap_service_free(l2cap_service_t *l2cap_service){
124 btstack_memory_pool_free(&l2cap_service_pool, l2cap_service);
125}
126#else
127l2cap_service_t * btstack_memory_l2cap_service_get(void){
128 return NULL;
129}
130void btstack_memory_l2cap_service_free(l2cap_service_t *l2cap_service){
131 // silence compiler warning about unused parameter in a portable way
132 (void) l2cap_service;
133};
134#endif
135#elif defined(HAVE_MALLOC)
136l2cap_service_t * btstack_memory_l2cap_service_get(void){
124 return (l2cap_service_t*) malloc(sizeof(l2cap_service_t));
137 void * buffer = malloc(sizeof(l2cap_service_t));
138 if (buffer){
139 memset(buffer, 0, sizeof(l2cap_service_t));
140 }
141 return (l2cap_service_t *) buffer;
125}
126void btstack_memory_l2cap_service_free(l2cap_service_t *l2cap_service){
127 free(l2cap_service);
128}
129#endif
130
131
132// MARK: l2cap_channel_t

--- 5 unchanged lines hidden (view full) ---

138 #endif
139#endif
140
141#ifdef MAX_NR_L2CAP_CHANNELS
142#if MAX_NR_L2CAP_CHANNELS > 0
143static l2cap_channel_t l2cap_channel_storage[MAX_NR_L2CAP_CHANNELS];
144static btstack_memory_pool_t l2cap_channel_pool;
145l2cap_channel_t * btstack_memory_l2cap_channel_get(void){
142}
143void btstack_memory_l2cap_service_free(l2cap_service_t *l2cap_service){
144 free(l2cap_service);
145}
146#endif
147
148
149// MARK: l2cap_channel_t

--- 5 unchanged lines hidden (view full) ---

155 #endif
156#endif
157
158#ifdef MAX_NR_L2CAP_CHANNELS
159#if MAX_NR_L2CAP_CHANNELS > 0
160static l2cap_channel_t l2cap_channel_storage[MAX_NR_L2CAP_CHANNELS];
161static btstack_memory_pool_t l2cap_channel_pool;
162l2cap_channel_t * btstack_memory_l2cap_channel_get(void){
146 return (l2cap_channel_t *) btstack_memory_pool_get(&l2cap_channel_pool);
163 void * buffer = btstack_memory_pool_get(&l2cap_channel_pool);
164 if (buffer){
165 memset(buffer, 0, sizeof(l2cap_channel_t));
166 }
167 return (l2cap_channel_t *) buffer;
147}
148void btstack_memory_l2cap_channel_free(l2cap_channel_t *l2cap_channel){
149 btstack_memory_pool_free(&l2cap_channel_pool, l2cap_channel);
150}
151#else
152l2cap_channel_t * btstack_memory_l2cap_channel_get(void){
153 return NULL;
154}
155void btstack_memory_l2cap_channel_free(l2cap_channel_t *l2cap_channel){
156 // silence compiler warning about unused parameter in a portable way
157 (void) l2cap_channel;
158};
159#endif
160#elif defined(HAVE_MALLOC)
161l2cap_channel_t * btstack_memory_l2cap_channel_get(void){
168}
169void btstack_memory_l2cap_channel_free(l2cap_channel_t *l2cap_channel){
170 btstack_memory_pool_free(&l2cap_channel_pool, l2cap_channel);
171}
172#else
173l2cap_channel_t * btstack_memory_l2cap_channel_get(void){
174 return NULL;
175}
176void btstack_memory_l2cap_channel_free(l2cap_channel_t *l2cap_channel){
177 // silence compiler warning about unused parameter in a portable way
178 (void) l2cap_channel;
179};
180#endif
181#elif defined(HAVE_MALLOC)
182l2cap_channel_t * btstack_memory_l2cap_channel_get(void){
162 return (l2cap_channel_t*) malloc(sizeof(l2cap_channel_t));
183 void * buffer = malloc(sizeof(l2cap_channel_t));
184 if (buffer){
185 memset(buffer, 0, sizeof(l2cap_channel_t));
186 }
187 return (l2cap_channel_t *) buffer;
163}
164void btstack_memory_l2cap_channel_free(l2cap_channel_t *l2cap_channel){
165 free(l2cap_channel);
166}
167#endif
168
169
170

--- 6 unchanged lines hidden (view full) ---

177 #endif
178#endif
179
180#ifdef MAX_NR_RFCOMM_MULTIPLEXERS
181#if MAX_NR_RFCOMM_MULTIPLEXERS > 0
182static rfcomm_multiplexer_t rfcomm_multiplexer_storage[MAX_NR_RFCOMM_MULTIPLEXERS];
183static btstack_memory_pool_t rfcomm_multiplexer_pool;
184rfcomm_multiplexer_t * btstack_memory_rfcomm_multiplexer_get(void){
188}
189void btstack_memory_l2cap_channel_free(l2cap_channel_t *l2cap_channel){
190 free(l2cap_channel);
191}
192#endif
193
194
195

--- 6 unchanged lines hidden (view full) ---

202 #endif
203#endif
204
205#ifdef MAX_NR_RFCOMM_MULTIPLEXERS
206#if MAX_NR_RFCOMM_MULTIPLEXERS > 0
207static rfcomm_multiplexer_t rfcomm_multiplexer_storage[MAX_NR_RFCOMM_MULTIPLEXERS];
208static btstack_memory_pool_t rfcomm_multiplexer_pool;
209rfcomm_multiplexer_t * btstack_memory_rfcomm_multiplexer_get(void){
185 return (rfcomm_multiplexer_t *) btstack_memory_pool_get(&rfcomm_multiplexer_pool);
210 void * buffer = btstack_memory_pool_get(&rfcomm_multiplexer_pool);
211 if (buffer){
212 memset(buffer, 0, sizeof(rfcomm_multiplexer_t));
213 }
214 return (rfcomm_multiplexer_t *) buffer;
186}
187void btstack_memory_rfcomm_multiplexer_free(rfcomm_multiplexer_t *rfcomm_multiplexer){
188 btstack_memory_pool_free(&rfcomm_multiplexer_pool, rfcomm_multiplexer);
189}
190#else
191rfcomm_multiplexer_t * btstack_memory_rfcomm_multiplexer_get(void){
192 return NULL;
193}
194void btstack_memory_rfcomm_multiplexer_free(rfcomm_multiplexer_t *rfcomm_multiplexer){
195 // silence compiler warning about unused parameter in a portable way
196 (void) rfcomm_multiplexer;
197};
198#endif
199#elif defined(HAVE_MALLOC)
200rfcomm_multiplexer_t * btstack_memory_rfcomm_multiplexer_get(void){
215}
216void btstack_memory_rfcomm_multiplexer_free(rfcomm_multiplexer_t *rfcomm_multiplexer){
217 btstack_memory_pool_free(&rfcomm_multiplexer_pool, rfcomm_multiplexer);
218}
219#else
220rfcomm_multiplexer_t * btstack_memory_rfcomm_multiplexer_get(void){
221 return NULL;
222}
223void btstack_memory_rfcomm_multiplexer_free(rfcomm_multiplexer_t *rfcomm_multiplexer){
224 // silence compiler warning about unused parameter in a portable way
225 (void) rfcomm_multiplexer;
226};
227#endif
228#elif defined(HAVE_MALLOC)
229rfcomm_multiplexer_t * btstack_memory_rfcomm_multiplexer_get(void){
201 return (rfcomm_multiplexer_t*) malloc(sizeof(rfcomm_multiplexer_t));
230 void * buffer = malloc(sizeof(rfcomm_multiplexer_t));
231 if (buffer){
232 memset(buffer, 0, sizeof(rfcomm_multiplexer_t));
233 }
234 return (rfcomm_multiplexer_t *) buffer;
202}
203void btstack_memory_rfcomm_multiplexer_free(rfcomm_multiplexer_t *rfcomm_multiplexer){
204 free(rfcomm_multiplexer);
205}
206#endif
207
208
209// MARK: rfcomm_service_t

--- 5 unchanged lines hidden (view full) ---

215 #endif
216#endif
217
218#ifdef MAX_NR_RFCOMM_SERVICES
219#if MAX_NR_RFCOMM_SERVICES > 0
220static rfcomm_service_t rfcomm_service_storage[MAX_NR_RFCOMM_SERVICES];
221static btstack_memory_pool_t rfcomm_service_pool;
222rfcomm_service_t * btstack_memory_rfcomm_service_get(void){
235}
236void btstack_memory_rfcomm_multiplexer_free(rfcomm_multiplexer_t *rfcomm_multiplexer){
237 free(rfcomm_multiplexer);
238}
239#endif
240
241
242// MARK: rfcomm_service_t

--- 5 unchanged lines hidden (view full) ---

248 #endif
249#endif
250
251#ifdef MAX_NR_RFCOMM_SERVICES
252#if MAX_NR_RFCOMM_SERVICES > 0
253static rfcomm_service_t rfcomm_service_storage[MAX_NR_RFCOMM_SERVICES];
254static btstack_memory_pool_t rfcomm_service_pool;
255rfcomm_service_t * btstack_memory_rfcomm_service_get(void){
223 return (rfcomm_service_t *) btstack_memory_pool_get(&rfcomm_service_pool);
256 void * buffer = btstack_memory_pool_get(&rfcomm_service_pool);
257 if (buffer){
258 memset(buffer, 0, sizeof(rfcomm_service_t));
259 }
260 return (rfcomm_service_t *) buffer;
224}
225void btstack_memory_rfcomm_service_free(rfcomm_service_t *rfcomm_service){
226 btstack_memory_pool_free(&rfcomm_service_pool, rfcomm_service);
227}
228#else
229rfcomm_service_t * btstack_memory_rfcomm_service_get(void){
230 return NULL;
231}
232void btstack_memory_rfcomm_service_free(rfcomm_service_t *rfcomm_service){
233 // silence compiler warning about unused parameter in a portable way
234 (void) rfcomm_service;
235};
236#endif
237#elif defined(HAVE_MALLOC)
238rfcomm_service_t * btstack_memory_rfcomm_service_get(void){
261}
262void btstack_memory_rfcomm_service_free(rfcomm_service_t *rfcomm_service){
263 btstack_memory_pool_free(&rfcomm_service_pool, rfcomm_service);
264}
265#else
266rfcomm_service_t * btstack_memory_rfcomm_service_get(void){
267 return NULL;
268}
269void btstack_memory_rfcomm_service_free(rfcomm_service_t *rfcomm_service){
270 // silence compiler warning about unused parameter in a portable way
271 (void) rfcomm_service;
272};
273#endif
274#elif defined(HAVE_MALLOC)
275rfcomm_service_t * btstack_memory_rfcomm_service_get(void){
239 return (rfcomm_service_t*) malloc(sizeof(rfcomm_service_t));
276 void * buffer = malloc(sizeof(rfcomm_service_t));
277 if (buffer){
278 memset(buffer, 0, sizeof(rfcomm_service_t));
279 }
280 return (rfcomm_service_t *) buffer;
240}
241void btstack_memory_rfcomm_service_free(rfcomm_service_t *rfcomm_service){
242 free(rfcomm_service);
243}
244#endif
245
246
247// MARK: rfcomm_channel_t

--- 5 unchanged lines hidden (view full) ---

253 #endif
254#endif
255
256#ifdef MAX_NR_RFCOMM_CHANNELS
257#if MAX_NR_RFCOMM_CHANNELS > 0
258static rfcomm_channel_t rfcomm_channel_storage[MAX_NR_RFCOMM_CHANNELS];
259static btstack_memory_pool_t rfcomm_channel_pool;
260rfcomm_channel_t * btstack_memory_rfcomm_channel_get(void){
281}
282void btstack_memory_rfcomm_service_free(rfcomm_service_t *rfcomm_service){
283 free(rfcomm_service);
284}
285#endif
286
287
288// MARK: rfcomm_channel_t

--- 5 unchanged lines hidden (view full) ---

294 #endif
295#endif
296
297#ifdef MAX_NR_RFCOMM_CHANNELS
298#if MAX_NR_RFCOMM_CHANNELS > 0
299static rfcomm_channel_t rfcomm_channel_storage[MAX_NR_RFCOMM_CHANNELS];
300static btstack_memory_pool_t rfcomm_channel_pool;
301rfcomm_channel_t * btstack_memory_rfcomm_channel_get(void){
261 return (rfcomm_channel_t *) btstack_memory_pool_get(&rfcomm_channel_pool);
302 void * buffer = btstack_memory_pool_get(&rfcomm_channel_pool);
303 if (buffer){
304 memset(buffer, 0, sizeof(rfcomm_channel_t));
305 }
306 return (rfcomm_channel_t *) buffer;
262}
263void btstack_memory_rfcomm_channel_free(rfcomm_channel_t *rfcomm_channel){
264 btstack_memory_pool_free(&rfcomm_channel_pool, rfcomm_channel);
265}
266#else
267rfcomm_channel_t * btstack_memory_rfcomm_channel_get(void){
268 return NULL;
269}
270void btstack_memory_rfcomm_channel_free(rfcomm_channel_t *rfcomm_channel){
271 // silence compiler warning about unused parameter in a portable way
272 (void) rfcomm_channel;
273};
274#endif
275#elif defined(HAVE_MALLOC)
276rfcomm_channel_t * btstack_memory_rfcomm_channel_get(void){
307}
308void btstack_memory_rfcomm_channel_free(rfcomm_channel_t *rfcomm_channel){
309 btstack_memory_pool_free(&rfcomm_channel_pool, rfcomm_channel);
310}
311#else
312rfcomm_channel_t * btstack_memory_rfcomm_channel_get(void){
313 return NULL;
314}
315void btstack_memory_rfcomm_channel_free(rfcomm_channel_t *rfcomm_channel){
316 // silence compiler warning about unused parameter in a portable way
317 (void) rfcomm_channel;
318};
319#endif
320#elif defined(HAVE_MALLOC)
321rfcomm_channel_t * btstack_memory_rfcomm_channel_get(void){
277 return (rfcomm_channel_t*) malloc(sizeof(rfcomm_channel_t));
322 void * buffer = malloc(sizeof(rfcomm_channel_t));
323 if (buffer){
324 memset(buffer, 0, sizeof(rfcomm_channel_t));
325 }
326 return (rfcomm_channel_t *) buffer;
278}
279void btstack_memory_rfcomm_channel_free(rfcomm_channel_t *rfcomm_channel){
280 free(rfcomm_channel);
281}
282#endif
283
284
285

--- 6 unchanged lines hidden (view full) ---

292 #endif
293#endif
294
295#ifdef MAX_NR_BTSTACK_LINK_KEY_DB_MEMORY_ENTRIES
296#if MAX_NR_BTSTACK_LINK_KEY_DB_MEMORY_ENTRIES > 0
297static btstack_link_key_db_memory_entry_t btstack_link_key_db_memory_entry_storage[MAX_NR_BTSTACK_LINK_KEY_DB_MEMORY_ENTRIES];
298static btstack_memory_pool_t btstack_link_key_db_memory_entry_pool;
299btstack_link_key_db_memory_entry_t * btstack_memory_btstack_link_key_db_memory_entry_get(void){
327}
328void btstack_memory_rfcomm_channel_free(rfcomm_channel_t *rfcomm_channel){
329 free(rfcomm_channel);
330}
331#endif
332
333
334

--- 6 unchanged lines hidden (view full) ---

341 #endif
342#endif
343
344#ifdef MAX_NR_BTSTACK_LINK_KEY_DB_MEMORY_ENTRIES
345#if MAX_NR_BTSTACK_LINK_KEY_DB_MEMORY_ENTRIES > 0
346static btstack_link_key_db_memory_entry_t btstack_link_key_db_memory_entry_storage[MAX_NR_BTSTACK_LINK_KEY_DB_MEMORY_ENTRIES];
347static btstack_memory_pool_t btstack_link_key_db_memory_entry_pool;
348btstack_link_key_db_memory_entry_t * btstack_memory_btstack_link_key_db_memory_entry_get(void){
300 return (btstack_link_key_db_memory_entry_t *) btstack_memory_pool_get(&btstack_link_key_db_memory_entry_pool);
349 void * buffer = btstack_memory_pool_get(&btstack_link_key_db_memory_entry_pool);
350 if (buffer){
351 memset(buffer, 0, sizeof(btstack_link_key_db_memory_entry_t));
352 }
353 return (btstack_link_key_db_memory_entry_t *) buffer;
301}
302void btstack_memory_btstack_link_key_db_memory_entry_free(btstack_link_key_db_memory_entry_t *btstack_link_key_db_memory_entry){
303 btstack_memory_pool_free(&btstack_link_key_db_memory_entry_pool, btstack_link_key_db_memory_entry);
304}
305#else
306btstack_link_key_db_memory_entry_t * btstack_memory_btstack_link_key_db_memory_entry_get(void){
307 return NULL;
308}
309void btstack_memory_btstack_link_key_db_memory_entry_free(btstack_link_key_db_memory_entry_t *btstack_link_key_db_memory_entry){
310 // silence compiler warning about unused parameter in a portable way
311 (void) btstack_link_key_db_memory_entry;
312};
313#endif
314#elif defined(HAVE_MALLOC)
315btstack_link_key_db_memory_entry_t * btstack_memory_btstack_link_key_db_memory_entry_get(void){
354}
355void btstack_memory_btstack_link_key_db_memory_entry_free(btstack_link_key_db_memory_entry_t *btstack_link_key_db_memory_entry){
356 btstack_memory_pool_free(&btstack_link_key_db_memory_entry_pool, btstack_link_key_db_memory_entry);
357}
358#else
359btstack_link_key_db_memory_entry_t * btstack_memory_btstack_link_key_db_memory_entry_get(void){
360 return NULL;
361}
362void btstack_memory_btstack_link_key_db_memory_entry_free(btstack_link_key_db_memory_entry_t *btstack_link_key_db_memory_entry){
363 // silence compiler warning about unused parameter in a portable way
364 (void) btstack_link_key_db_memory_entry;
365};
366#endif
367#elif defined(HAVE_MALLOC)
368btstack_link_key_db_memory_entry_t * btstack_memory_btstack_link_key_db_memory_entry_get(void){
316 return (btstack_link_key_db_memory_entry_t*) malloc(sizeof(btstack_link_key_db_memory_entry_t));
369 void * buffer = malloc(sizeof(btstack_link_key_db_memory_entry_t));
370 if (buffer){
371 memset(buffer, 0, sizeof(btstack_link_key_db_memory_entry_t));
372 }
373 return (btstack_link_key_db_memory_entry_t *) buffer;
317}
318void btstack_memory_btstack_link_key_db_memory_entry_free(btstack_link_key_db_memory_entry_t *btstack_link_key_db_memory_entry){
319 free(btstack_link_key_db_memory_entry);
320}
321#endif
322
323
324

--- 6 unchanged lines hidden (view full) ---

331 #endif
332#endif
333
334#ifdef MAX_NR_BNEP_SERVICES
335#if MAX_NR_BNEP_SERVICES > 0
336static bnep_service_t bnep_service_storage[MAX_NR_BNEP_SERVICES];
337static btstack_memory_pool_t bnep_service_pool;
338bnep_service_t * btstack_memory_bnep_service_get(void){
374}
375void btstack_memory_btstack_link_key_db_memory_entry_free(btstack_link_key_db_memory_entry_t *btstack_link_key_db_memory_entry){
376 free(btstack_link_key_db_memory_entry);
377}
378#endif
379
380
381

--- 6 unchanged lines hidden (view full) ---

388 #endif
389#endif
390
391#ifdef MAX_NR_BNEP_SERVICES
392#if MAX_NR_BNEP_SERVICES > 0
393static bnep_service_t bnep_service_storage[MAX_NR_BNEP_SERVICES];
394static btstack_memory_pool_t bnep_service_pool;
395bnep_service_t * btstack_memory_bnep_service_get(void){
339 return (bnep_service_t *) btstack_memory_pool_get(&bnep_service_pool);
396 void * buffer = btstack_memory_pool_get(&bnep_service_pool);
397 if (buffer){
398 memset(buffer, 0, sizeof(bnep_service_t));
399 }
400 return (bnep_service_t *) buffer;
340}
341void btstack_memory_bnep_service_free(bnep_service_t *bnep_service){
342 btstack_memory_pool_free(&bnep_service_pool, bnep_service);
343}
344#else
345bnep_service_t * btstack_memory_bnep_service_get(void){
346 return NULL;
347}
348void btstack_memory_bnep_service_free(bnep_service_t *bnep_service){
349 // silence compiler warning about unused parameter in a portable way
350 (void) bnep_service;
351};
352#endif
353#elif defined(HAVE_MALLOC)
354bnep_service_t * btstack_memory_bnep_service_get(void){
401}
402void btstack_memory_bnep_service_free(bnep_service_t *bnep_service){
403 btstack_memory_pool_free(&bnep_service_pool, bnep_service);
404}
405#else
406bnep_service_t * btstack_memory_bnep_service_get(void){
407 return NULL;
408}
409void btstack_memory_bnep_service_free(bnep_service_t *bnep_service){
410 // silence compiler warning about unused parameter in a portable way
411 (void) bnep_service;
412};
413#endif
414#elif defined(HAVE_MALLOC)
415bnep_service_t * btstack_memory_bnep_service_get(void){
355 return (bnep_service_t*) malloc(sizeof(bnep_service_t));
416 void * buffer = malloc(sizeof(bnep_service_t));
417 if (buffer){
418 memset(buffer, 0, sizeof(bnep_service_t));
419 }
420 return (bnep_service_t *) buffer;
356}
357void btstack_memory_bnep_service_free(bnep_service_t *bnep_service){
358 free(bnep_service);
359}
360#endif
361
362
363// MARK: bnep_channel_t

--- 5 unchanged lines hidden (view full) ---

369 #endif
370#endif
371
372#ifdef MAX_NR_BNEP_CHANNELS
373#if MAX_NR_BNEP_CHANNELS > 0
374static bnep_channel_t bnep_channel_storage[MAX_NR_BNEP_CHANNELS];
375static btstack_memory_pool_t bnep_channel_pool;
376bnep_channel_t * btstack_memory_bnep_channel_get(void){
421}
422void btstack_memory_bnep_service_free(bnep_service_t *bnep_service){
423 free(bnep_service);
424}
425#endif
426
427
428// MARK: bnep_channel_t

--- 5 unchanged lines hidden (view full) ---

434 #endif
435#endif
436
437#ifdef MAX_NR_BNEP_CHANNELS
438#if MAX_NR_BNEP_CHANNELS > 0
439static bnep_channel_t bnep_channel_storage[MAX_NR_BNEP_CHANNELS];
440static btstack_memory_pool_t bnep_channel_pool;
441bnep_channel_t * btstack_memory_bnep_channel_get(void){
377 return (bnep_channel_t *) btstack_memory_pool_get(&bnep_channel_pool);
442 void * buffer = btstack_memory_pool_get(&bnep_channel_pool);
443 if (buffer){
444 memset(buffer, 0, sizeof(bnep_channel_t));
445 }
446 return (bnep_channel_t *) buffer;
378}
379void btstack_memory_bnep_channel_free(bnep_channel_t *bnep_channel){
380 btstack_memory_pool_free(&bnep_channel_pool, bnep_channel);
381}
382#else
383bnep_channel_t * btstack_memory_bnep_channel_get(void){
384 return NULL;
385}
386void btstack_memory_bnep_channel_free(bnep_channel_t *bnep_channel){
387 // silence compiler warning about unused parameter in a portable way
388 (void) bnep_channel;
389};
390#endif
391#elif defined(HAVE_MALLOC)
392bnep_channel_t * btstack_memory_bnep_channel_get(void){
447}
448void btstack_memory_bnep_channel_free(bnep_channel_t *bnep_channel){
449 btstack_memory_pool_free(&bnep_channel_pool, bnep_channel);
450}
451#else
452bnep_channel_t * btstack_memory_bnep_channel_get(void){
453 return NULL;
454}
455void btstack_memory_bnep_channel_free(bnep_channel_t *bnep_channel){
456 // silence compiler warning about unused parameter in a portable way
457 (void) bnep_channel;
458};
459#endif
460#elif defined(HAVE_MALLOC)
461bnep_channel_t * btstack_memory_bnep_channel_get(void){
393 return (bnep_channel_t*) malloc(sizeof(bnep_channel_t));
462 void * buffer = malloc(sizeof(bnep_channel_t));
463 if (buffer){
464 memset(buffer, 0, sizeof(bnep_channel_t));
465 }
466 return (bnep_channel_t *) buffer;
394}
395void btstack_memory_bnep_channel_free(bnep_channel_t *bnep_channel){
396 free(bnep_channel);
397}
398#endif
399
400
401

--- 6 unchanged lines hidden (view full) ---

408 #endif
409#endif
410
411#ifdef MAX_NR_HFP_CONNECTIONS
412#if MAX_NR_HFP_CONNECTIONS > 0
413static hfp_connection_t hfp_connection_storage[MAX_NR_HFP_CONNECTIONS];
414static btstack_memory_pool_t hfp_connection_pool;
415hfp_connection_t * btstack_memory_hfp_connection_get(void){
467}
468void btstack_memory_bnep_channel_free(bnep_channel_t *bnep_channel){
469 free(bnep_channel);
470}
471#endif
472
473
474

--- 6 unchanged lines hidden (view full) ---

481 #endif
482#endif
483
484#ifdef MAX_NR_HFP_CONNECTIONS
485#if MAX_NR_HFP_CONNECTIONS > 0
486static hfp_connection_t hfp_connection_storage[MAX_NR_HFP_CONNECTIONS];
487static btstack_memory_pool_t hfp_connection_pool;
488hfp_connection_t * btstack_memory_hfp_connection_get(void){
416 return (hfp_connection_t *) btstack_memory_pool_get(&hfp_connection_pool);
489 void * buffer = btstack_memory_pool_get(&hfp_connection_pool);
490 if (buffer){
491 memset(buffer, 0, sizeof(hfp_connection_t));
492 }
493 return (hfp_connection_t *) buffer;
417}
418void btstack_memory_hfp_connection_free(hfp_connection_t *hfp_connection){
419 btstack_memory_pool_free(&hfp_connection_pool, hfp_connection);
420}
421#else
422hfp_connection_t * btstack_memory_hfp_connection_get(void){
423 return NULL;
424}
425void btstack_memory_hfp_connection_free(hfp_connection_t *hfp_connection){
426 // silence compiler warning about unused parameter in a portable way
427 (void) hfp_connection;
428};
429#endif
430#elif defined(HAVE_MALLOC)
431hfp_connection_t * btstack_memory_hfp_connection_get(void){
494}
495void btstack_memory_hfp_connection_free(hfp_connection_t *hfp_connection){
496 btstack_memory_pool_free(&hfp_connection_pool, hfp_connection);
497}
498#else
499hfp_connection_t * btstack_memory_hfp_connection_get(void){
500 return NULL;
501}
502void btstack_memory_hfp_connection_free(hfp_connection_t *hfp_connection){
503 // silence compiler warning about unused parameter in a portable way
504 (void) hfp_connection;
505};
506#endif
507#elif defined(HAVE_MALLOC)
508hfp_connection_t * btstack_memory_hfp_connection_get(void){
432 return (hfp_connection_t*) malloc(sizeof(hfp_connection_t));
509 void * buffer = malloc(sizeof(hfp_connection_t));
510 if (buffer){
511 memset(buffer, 0, sizeof(hfp_connection_t));
512 }
513 return (hfp_connection_t *) buffer;
433}
434void btstack_memory_hfp_connection_free(hfp_connection_t *hfp_connection){
435 free(hfp_connection);
436}
437#endif
438
439
440

--- 6 unchanged lines hidden (view full) ---

447 #endif
448#endif
449
450#ifdef MAX_NR_SERVICE_RECORD_ITEMS
451#if MAX_NR_SERVICE_RECORD_ITEMS > 0
452static service_record_item_t service_record_item_storage[MAX_NR_SERVICE_RECORD_ITEMS];
453static btstack_memory_pool_t service_record_item_pool;
454service_record_item_t * btstack_memory_service_record_item_get(void){
514}
515void btstack_memory_hfp_connection_free(hfp_connection_t *hfp_connection){
516 free(hfp_connection);
517}
518#endif
519
520
521

--- 6 unchanged lines hidden (view full) ---

528 #endif
529#endif
530
531#ifdef MAX_NR_SERVICE_RECORD_ITEMS
532#if MAX_NR_SERVICE_RECORD_ITEMS > 0
533static service_record_item_t service_record_item_storage[MAX_NR_SERVICE_RECORD_ITEMS];
534static btstack_memory_pool_t service_record_item_pool;
535service_record_item_t * btstack_memory_service_record_item_get(void){
455 return (service_record_item_t *) btstack_memory_pool_get(&service_record_item_pool);
536 void * buffer = btstack_memory_pool_get(&service_record_item_pool);
537 if (buffer){
538 memset(buffer, 0, sizeof(service_record_item_t));
539 }
540 return (service_record_item_t *) buffer;
456}
457void btstack_memory_service_record_item_free(service_record_item_t *service_record_item){
458 btstack_memory_pool_free(&service_record_item_pool, service_record_item);
459}
460#else
461service_record_item_t * btstack_memory_service_record_item_get(void){
462 return NULL;
463}
464void btstack_memory_service_record_item_free(service_record_item_t *service_record_item){
465 // silence compiler warning about unused parameter in a portable way
466 (void) service_record_item;
467};
468#endif
469#elif defined(HAVE_MALLOC)
470service_record_item_t * btstack_memory_service_record_item_get(void){
541}
542void btstack_memory_service_record_item_free(service_record_item_t *service_record_item){
543 btstack_memory_pool_free(&service_record_item_pool, service_record_item);
544}
545#else
546service_record_item_t * btstack_memory_service_record_item_get(void){
547 return NULL;
548}
549void btstack_memory_service_record_item_free(service_record_item_t *service_record_item){
550 // silence compiler warning about unused parameter in a portable way
551 (void) service_record_item;
552};
553#endif
554#elif defined(HAVE_MALLOC)
555service_record_item_t * btstack_memory_service_record_item_get(void){
471 return (service_record_item_t*) malloc(sizeof(service_record_item_t));
556 void * buffer = malloc(sizeof(service_record_item_t));
557 if (buffer){
558 memset(buffer, 0, sizeof(service_record_item_t));
559 }
560 return (service_record_item_t *) buffer;
472}
473void btstack_memory_service_record_item_free(service_record_item_t *service_record_item){
474 free(service_record_item);
475}
476#endif
477
478
479

--- 6 unchanged lines hidden (view full) ---

486 #endif
487#endif
488
489#ifdef MAX_NR_AVDTP_STREAM_ENDPOINTS
490#if MAX_NR_AVDTP_STREAM_ENDPOINTS > 0
491static avdtp_stream_endpoint_t avdtp_stream_endpoint_storage[MAX_NR_AVDTP_STREAM_ENDPOINTS];
492static btstack_memory_pool_t avdtp_stream_endpoint_pool;
493avdtp_stream_endpoint_t * btstack_memory_avdtp_stream_endpoint_get(void){
561}
562void btstack_memory_service_record_item_free(service_record_item_t *service_record_item){
563 free(service_record_item);
564}
565#endif
566
567
568

--- 6 unchanged lines hidden (view full) ---

575 #endif
576#endif
577
578#ifdef MAX_NR_AVDTP_STREAM_ENDPOINTS
579#if MAX_NR_AVDTP_STREAM_ENDPOINTS > 0
580static avdtp_stream_endpoint_t avdtp_stream_endpoint_storage[MAX_NR_AVDTP_STREAM_ENDPOINTS];
581static btstack_memory_pool_t avdtp_stream_endpoint_pool;
582avdtp_stream_endpoint_t * btstack_memory_avdtp_stream_endpoint_get(void){
494 return (avdtp_stream_endpoint_t *) btstack_memory_pool_get(&avdtp_stream_endpoint_pool);
583 void * buffer = btstack_memory_pool_get(&avdtp_stream_endpoint_pool);
584 if (buffer){
585 memset(buffer, 0, sizeof(avdtp_stream_endpoint_t));
586 }
587 return (avdtp_stream_endpoint_t *) buffer;
495}
496void btstack_memory_avdtp_stream_endpoint_free(avdtp_stream_endpoint_t *avdtp_stream_endpoint){
497 btstack_memory_pool_free(&avdtp_stream_endpoint_pool, avdtp_stream_endpoint);
498}
499#else
500avdtp_stream_endpoint_t * btstack_memory_avdtp_stream_endpoint_get(void){
501 return NULL;
502}
503void btstack_memory_avdtp_stream_endpoint_free(avdtp_stream_endpoint_t *avdtp_stream_endpoint){
504 // silence compiler warning about unused parameter in a portable way
505 (void) avdtp_stream_endpoint;
506};
507#endif
508#elif defined(HAVE_MALLOC)
509avdtp_stream_endpoint_t * btstack_memory_avdtp_stream_endpoint_get(void){
588}
589void btstack_memory_avdtp_stream_endpoint_free(avdtp_stream_endpoint_t *avdtp_stream_endpoint){
590 btstack_memory_pool_free(&avdtp_stream_endpoint_pool, avdtp_stream_endpoint);
591}
592#else
593avdtp_stream_endpoint_t * btstack_memory_avdtp_stream_endpoint_get(void){
594 return NULL;
595}
596void btstack_memory_avdtp_stream_endpoint_free(avdtp_stream_endpoint_t *avdtp_stream_endpoint){
597 // silence compiler warning about unused parameter in a portable way
598 (void) avdtp_stream_endpoint;
599};
600#endif
601#elif defined(HAVE_MALLOC)
602avdtp_stream_endpoint_t * btstack_memory_avdtp_stream_endpoint_get(void){
510 return (avdtp_stream_endpoint_t*) malloc(sizeof(avdtp_stream_endpoint_t));
603 void * buffer = malloc(sizeof(avdtp_stream_endpoint_t));
604 if (buffer){
605 memset(buffer, 0, sizeof(avdtp_stream_endpoint_t));
606 }
607 return (avdtp_stream_endpoint_t *) buffer;
511}
512void btstack_memory_avdtp_stream_endpoint_free(avdtp_stream_endpoint_t *avdtp_stream_endpoint){
513 free(avdtp_stream_endpoint);
514}
515#endif
516
517
518

--- 6 unchanged lines hidden (view full) ---

525 #endif
526#endif
527
528#ifdef MAX_NR_AVDTP_CONNECTIONS
529#if MAX_NR_AVDTP_CONNECTIONS > 0
530static avdtp_connection_t avdtp_connection_storage[MAX_NR_AVDTP_CONNECTIONS];
531static btstack_memory_pool_t avdtp_connection_pool;
532avdtp_connection_t * btstack_memory_avdtp_connection_get(void){
608}
609void btstack_memory_avdtp_stream_endpoint_free(avdtp_stream_endpoint_t *avdtp_stream_endpoint){
610 free(avdtp_stream_endpoint);
611}
612#endif
613
614
615

--- 6 unchanged lines hidden (view full) ---

622 #endif
623#endif
624
625#ifdef MAX_NR_AVDTP_CONNECTIONS
626#if MAX_NR_AVDTP_CONNECTIONS > 0
627static avdtp_connection_t avdtp_connection_storage[MAX_NR_AVDTP_CONNECTIONS];
628static btstack_memory_pool_t avdtp_connection_pool;
629avdtp_connection_t * btstack_memory_avdtp_connection_get(void){
533 return (avdtp_connection_t *) btstack_memory_pool_get(&avdtp_connection_pool);
630 void * buffer = btstack_memory_pool_get(&avdtp_connection_pool);
631 if (buffer){
632 memset(buffer, 0, sizeof(avdtp_connection_t));
633 }
634 return (avdtp_connection_t *) buffer;
534}
535void btstack_memory_avdtp_connection_free(avdtp_connection_t *avdtp_connection){
536 btstack_memory_pool_free(&avdtp_connection_pool, avdtp_connection);
537}
538#else
539avdtp_connection_t * btstack_memory_avdtp_connection_get(void){
540 return NULL;
541}
542void btstack_memory_avdtp_connection_free(avdtp_connection_t *avdtp_connection){
543 // silence compiler warning about unused parameter in a portable way
544 (void) avdtp_connection;
545};
546#endif
547#elif defined(HAVE_MALLOC)
548avdtp_connection_t * btstack_memory_avdtp_connection_get(void){
635}
636void btstack_memory_avdtp_connection_free(avdtp_connection_t *avdtp_connection){
637 btstack_memory_pool_free(&avdtp_connection_pool, avdtp_connection);
638}
639#else
640avdtp_connection_t * btstack_memory_avdtp_connection_get(void){
641 return NULL;
642}
643void btstack_memory_avdtp_connection_free(avdtp_connection_t *avdtp_connection){
644 // silence compiler warning about unused parameter in a portable way
645 (void) avdtp_connection;
646};
647#endif
648#elif defined(HAVE_MALLOC)
649avdtp_connection_t * btstack_memory_avdtp_connection_get(void){
549 return (avdtp_connection_t*) malloc(sizeof(avdtp_connection_t));
650 void * buffer = malloc(sizeof(avdtp_connection_t));
651 if (buffer){
652 memset(buffer, 0, sizeof(avdtp_connection_t));
653 }
654 return (avdtp_connection_t *) buffer;
550}
551void btstack_memory_avdtp_connection_free(avdtp_connection_t *avdtp_connection){
552 free(avdtp_connection);
553}
554#endif
555
556
557

--- 6 unchanged lines hidden (view full) ---

564 #endif
565#endif
566
567#ifdef MAX_NR_AVRCP_CONNECTIONS
568#if MAX_NR_AVRCP_CONNECTIONS > 0
569static avrcp_connection_t avrcp_connection_storage[MAX_NR_AVRCP_CONNECTIONS];
570static btstack_memory_pool_t avrcp_connection_pool;
571avrcp_connection_t * btstack_memory_avrcp_connection_get(void){
655}
656void btstack_memory_avdtp_connection_free(avdtp_connection_t *avdtp_connection){
657 free(avdtp_connection);
658}
659#endif
660
661
662

--- 6 unchanged lines hidden (view full) ---

669 #endif
670#endif
671
672#ifdef MAX_NR_AVRCP_CONNECTIONS
673#if MAX_NR_AVRCP_CONNECTIONS > 0
674static avrcp_connection_t avrcp_connection_storage[MAX_NR_AVRCP_CONNECTIONS];
675static btstack_memory_pool_t avrcp_connection_pool;
676avrcp_connection_t * btstack_memory_avrcp_connection_get(void){
572 return (avrcp_connection_t *) btstack_memory_pool_get(&avrcp_connection_pool);
677 void * buffer = btstack_memory_pool_get(&avrcp_connection_pool);
678 if (buffer){
679 memset(buffer, 0, sizeof(avrcp_connection_t));
680 }
681 return (avrcp_connection_t *) buffer;
573}
574void btstack_memory_avrcp_connection_free(avrcp_connection_t *avrcp_connection){
575 btstack_memory_pool_free(&avrcp_connection_pool, avrcp_connection);
576}
577#else
578avrcp_connection_t * btstack_memory_avrcp_connection_get(void){
579 return NULL;
580}
581void btstack_memory_avrcp_connection_free(avrcp_connection_t *avrcp_connection){
582 // silence compiler warning about unused parameter in a portable way
583 (void) avrcp_connection;
584};
585#endif
586#elif defined(HAVE_MALLOC)
587avrcp_connection_t * btstack_memory_avrcp_connection_get(void){
682}
683void btstack_memory_avrcp_connection_free(avrcp_connection_t *avrcp_connection){
684 btstack_memory_pool_free(&avrcp_connection_pool, avrcp_connection);
685}
686#else
687avrcp_connection_t * btstack_memory_avrcp_connection_get(void){
688 return NULL;
689}
690void btstack_memory_avrcp_connection_free(avrcp_connection_t *avrcp_connection){
691 // silence compiler warning about unused parameter in a portable way
692 (void) avrcp_connection;
693};
694#endif
695#elif defined(HAVE_MALLOC)
696avrcp_connection_t * btstack_memory_avrcp_connection_get(void){
588 return (avrcp_connection_t*) malloc(sizeof(avrcp_connection_t));
697 void * buffer = malloc(sizeof(avrcp_connection_t));
698 if (buffer){
699 memset(buffer, 0, sizeof(avrcp_connection_t));
700 }
701 return (avrcp_connection_t *) buffer;
589}
590void btstack_memory_avrcp_connection_free(avrcp_connection_t *avrcp_connection){
591 free(avrcp_connection);
592}
593#endif
594
595
596

--- 6 unchanged lines hidden (view full) ---

603 #endif
604#endif
605
606#ifdef MAX_NR_AVRCP_BROWSING_CONNECTIONS
607#if MAX_NR_AVRCP_BROWSING_CONNECTIONS > 0
608static avrcp_browsing_connection_t avrcp_browsing_connection_storage[MAX_NR_AVRCP_BROWSING_CONNECTIONS];
609static btstack_memory_pool_t avrcp_browsing_connection_pool;
610avrcp_browsing_connection_t * btstack_memory_avrcp_browsing_connection_get(void){
702}
703void btstack_memory_avrcp_connection_free(avrcp_connection_t *avrcp_connection){
704 free(avrcp_connection);
705}
706#endif
707
708
709

--- 6 unchanged lines hidden (view full) ---

716 #endif
717#endif
718
719#ifdef MAX_NR_AVRCP_BROWSING_CONNECTIONS
720#if MAX_NR_AVRCP_BROWSING_CONNECTIONS > 0
721static avrcp_browsing_connection_t avrcp_browsing_connection_storage[MAX_NR_AVRCP_BROWSING_CONNECTIONS];
722static btstack_memory_pool_t avrcp_browsing_connection_pool;
723avrcp_browsing_connection_t * btstack_memory_avrcp_browsing_connection_get(void){
611 return (avrcp_browsing_connection_t *) btstack_memory_pool_get(&avrcp_browsing_connection_pool);
724 void * buffer = btstack_memory_pool_get(&avrcp_browsing_connection_pool);
725 if (buffer){
726 memset(buffer, 0, sizeof(avrcp_browsing_connection_t));
727 }
728 return (avrcp_browsing_connection_t *) buffer;
612}
613void btstack_memory_avrcp_browsing_connection_free(avrcp_browsing_connection_t *avrcp_browsing_connection){
614 btstack_memory_pool_free(&avrcp_browsing_connection_pool, avrcp_browsing_connection);
615}
616#else
617avrcp_browsing_connection_t * btstack_memory_avrcp_browsing_connection_get(void){
618 return NULL;
619}
620void btstack_memory_avrcp_browsing_connection_free(avrcp_browsing_connection_t *avrcp_browsing_connection){
621 // silence compiler warning about unused parameter in a portable way
622 (void) avrcp_browsing_connection;
623};
624#endif
625#elif defined(HAVE_MALLOC)
626avrcp_browsing_connection_t * btstack_memory_avrcp_browsing_connection_get(void){
729}
730void btstack_memory_avrcp_browsing_connection_free(avrcp_browsing_connection_t *avrcp_browsing_connection){
731 btstack_memory_pool_free(&avrcp_browsing_connection_pool, avrcp_browsing_connection);
732}
733#else
734avrcp_browsing_connection_t * btstack_memory_avrcp_browsing_connection_get(void){
735 return NULL;
736}
737void btstack_memory_avrcp_browsing_connection_free(avrcp_browsing_connection_t *avrcp_browsing_connection){
738 // silence compiler warning about unused parameter in a portable way
739 (void) avrcp_browsing_connection;
740};
741#endif
742#elif defined(HAVE_MALLOC)
743avrcp_browsing_connection_t * btstack_memory_avrcp_browsing_connection_get(void){
627 return (avrcp_browsing_connection_t*) malloc(sizeof(avrcp_browsing_connection_t));
744 void * buffer = malloc(sizeof(avrcp_browsing_connection_t));
745 if (buffer){
746 memset(buffer, 0, sizeof(avrcp_browsing_connection_t));
747 }
748 return (avrcp_browsing_connection_t *) buffer;
628}
629void btstack_memory_avrcp_browsing_connection_free(avrcp_browsing_connection_t *avrcp_browsing_connection){
630 free(avrcp_browsing_connection);
631}
632#endif
633
634
635#ifdef ENABLE_BLE

--- 7 unchanged lines hidden (view full) ---

643 #endif
644#endif
645
646#ifdef MAX_NR_GATT_CLIENTS
647#if MAX_NR_GATT_CLIENTS > 0
648static gatt_client_t gatt_client_storage[MAX_NR_GATT_CLIENTS];
649static btstack_memory_pool_t gatt_client_pool;
650gatt_client_t * btstack_memory_gatt_client_get(void){
749}
750void btstack_memory_avrcp_browsing_connection_free(avrcp_browsing_connection_t *avrcp_browsing_connection){
751 free(avrcp_browsing_connection);
752}
753#endif
754
755
756#ifdef ENABLE_BLE

--- 7 unchanged lines hidden (view full) ---

764 #endif
765#endif
766
767#ifdef MAX_NR_GATT_CLIENTS
768#if MAX_NR_GATT_CLIENTS > 0
769static gatt_client_t gatt_client_storage[MAX_NR_GATT_CLIENTS];
770static btstack_memory_pool_t gatt_client_pool;
771gatt_client_t * btstack_memory_gatt_client_get(void){
651 return (gatt_client_t *) btstack_memory_pool_get(&gatt_client_pool);
772 void * buffer = btstack_memory_pool_get(&gatt_client_pool);
773 if (buffer){
774 memset(buffer, 0, sizeof(gatt_client_t));
775 }
776 return (gatt_client_t *) buffer;
652}
653void btstack_memory_gatt_client_free(gatt_client_t *gatt_client){
654 btstack_memory_pool_free(&gatt_client_pool, gatt_client);
655}
656#else
657gatt_client_t * btstack_memory_gatt_client_get(void){
658 return NULL;
659}
660void btstack_memory_gatt_client_free(gatt_client_t *gatt_client){
661 // silence compiler warning about unused parameter in a portable way
662 (void) gatt_client;
663};
664#endif
665#elif defined(HAVE_MALLOC)
666gatt_client_t * btstack_memory_gatt_client_get(void){
777}
778void btstack_memory_gatt_client_free(gatt_client_t *gatt_client){
779 btstack_memory_pool_free(&gatt_client_pool, gatt_client);
780}
781#else
782gatt_client_t * btstack_memory_gatt_client_get(void){
783 return NULL;
784}
785void btstack_memory_gatt_client_free(gatt_client_t *gatt_client){
786 // silence compiler warning about unused parameter in a portable way
787 (void) gatt_client;
788};
789#endif
790#elif defined(HAVE_MALLOC)
791gatt_client_t * btstack_memory_gatt_client_get(void){
667 return (gatt_client_t*) malloc(sizeof(gatt_client_t));
792 void * buffer = malloc(sizeof(gatt_client_t));
793 if (buffer){
794 memset(buffer, 0, sizeof(gatt_client_t));
795 }
796 return (gatt_client_t *) buffer;
668}
669void btstack_memory_gatt_client_free(gatt_client_t *gatt_client){
670 free(gatt_client);
671}
672#endif
673
674
675// MARK: whitelist_entry_t

--- 5 unchanged lines hidden (view full) ---

681 #endif
682#endif
683
684#ifdef MAX_NR_WHITELIST_ENTRIES
685#if MAX_NR_WHITELIST_ENTRIES > 0
686static whitelist_entry_t whitelist_entry_storage[MAX_NR_WHITELIST_ENTRIES];
687static btstack_memory_pool_t whitelist_entry_pool;
688whitelist_entry_t * btstack_memory_whitelist_entry_get(void){
797}
798void btstack_memory_gatt_client_free(gatt_client_t *gatt_client){
799 free(gatt_client);
800}
801#endif
802
803
804// MARK: whitelist_entry_t

--- 5 unchanged lines hidden (view full) ---

810 #endif
811#endif
812
813#ifdef MAX_NR_WHITELIST_ENTRIES
814#if MAX_NR_WHITELIST_ENTRIES > 0
815static whitelist_entry_t whitelist_entry_storage[MAX_NR_WHITELIST_ENTRIES];
816static btstack_memory_pool_t whitelist_entry_pool;
817whitelist_entry_t * btstack_memory_whitelist_entry_get(void){
689 return (whitelist_entry_t *) btstack_memory_pool_get(&whitelist_entry_pool);
818 void * buffer = btstack_memory_pool_get(&whitelist_entry_pool);
819 if (buffer){
820 memset(buffer, 0, sizeof(whitelist_entry_t));
821 }
822 return (whitelist_entry_t *) buffer;
690}
691void btstack_memory_whitelist_entry_free(whitelist_entry_t *whitelist_entry){
692 btstack_memory_pool_free(&whitelist_entry_pool, whitelist_entry);
693}
694#else
695whitelist_entry_t * btstack_memory_whitelist_entry_get(void){
696 return NULL;
697}
698void btstack_memory_whitelist_entry_free(whitelist_entry_t *whitelist_entry){
699 // silence compiler warning about unused parameter in a portable way
700 (void) whitelist_entry;
701};
702#endif
703#elif defined(HAVE_MALLOC)
704whitelist_entry_t * btstack_memory_whitelist_entry_get(void){
823}
824void btstack_memory_whitelist_entry_free(whitelist_entry_t *whitelist_entry){
825 btstack_memory_pool_free(&whitelist_entry_pool, whitelist_entry);
826}
827#else
828whitelist_entry_t * btstack_memory_whitelist_entry_get(void){
829 return NULL;
830}
831void btstack_memory_whitelist_entry_free(whitelist_entry_t *whitelist_entry){
832 // silence compiler warning about unused parameter in a portable way
833 (void) whitelist_entry;
834};
835#endif
836#elif defined(HAVE_MALLOC)
837whitelist_entry_t * btstack_memory_whitelist_entry_get(void){
705 return (whitelist_entry_t*) malloc(sizeof(whitelist_entry_t));
838 void * buffer = malloc(sizeof(whitelist_entry_t));
839 if (buffer){
840 memset(buffer, 0, sizeof(whitelist_entry_t));
841 }
842 return (whitelist_entry_t *) buffer;
706}
707void btstack_memory_whitelist_entry_free(whitelist_entry_t *whitelist_entry){
708 free(whitelist_entry);
709}
710#endif
711
712
713// MARK: sm_lookup_entry_t

--- 5 unchanged lines hidden (view full) ---

719 #endif
720#endif
721
722#ifdef MAX_NR_SM_LOOKUP_ENTRIES
723#if MAX_NR_SM_LOOKUP_ENTRIES > 0
724static sm_lookup_entry_t sm_lookup_entry_storage[MAX_NR_SM_LOOKUP_ENTRIES];
725static btstack_memory_pool_t sm_lookup_entry_pool;
726sm_lookup_entry_t * btstack_memory_sm_lookup_entry_get(void){
843}
844void btstack_memory_whitelist_entry_free(whitelist_entry_t *whitelist_entry){
845 free(whitelist_entry);
846}
847#endif
848
849
850// MARK: sm_lookup_entry_t

--- 5 unchanged lines hidden (view full) ---

856 #endif
857#endif
858
859#ifdef MAX_NR_SM_LOOKUP_ENTRIES
860#if MAX_NR_SM_LOOKUP_ENTRIES > 0
861static sm_lookup_entry_t sm_lookup_entry_storage[MAX_NR_SM_LOOKUP_ENTRIES];
862static btstack_memory_pool_t sm_lookup_entry_pool;
863sm_lookup_entry_t * btstack_memory_sm_lookup_entry_get(void){
727 return (sm_lookup_entry_t *) btstack_memory_pool_get(&sm_lookup_entry_pool);
864 void * buffer = btstack_memory_pool_get(&sm_lookup_entry_pool);
865 if (buffer){
866 memset(buffer, 0, sizeof(sm_lookup_entry_t));
867 }
868 return (sm_lookup_entry_t *) buffer;
728}
729void btstack_memory_sm_lookup_entry_free(sm_lookup_entry_t *sm_lookup_entry){
730 btstack_memory_pool_free(&sm_lookup_entry_pool, sm_lookup_entry);
731}
732#else
733sm_lookup_entry_t * btstack_memory_sm_lookup_entry_get(void){
734 return NULL;
735}
736void btstack_memory_sm_lookup_entry_free(sm_lookup_entry_t *sm_lookup_entry){
737 // silence compiler warning about unused parameter in a portable way
738 (void) sm_lookup_entry;
739};
740#endif
741#elif defined(HAVE_MALLOC)
742sm_lookup_entry_t * btstack_memory_sm_lookup_entry_get(void){
869}
870void btstack_memory_sm_lookup_entry_free(sm_lookup_entry_t *sm_lookup_entry){
871 btstack_memory_pool_free(&sm_lookup_entry_pool, sm_lookup_entry);
872}
873#else
874sm_lookup_entry_t * btstack_memory_sm_lookup_entry_get(void){
875 return NULL;
876}
877void btstack_memory_sm_lookup_entry_free(sm_lookup_entry_t *sm_lookup_entry){
878 // silence compiler warning about unused parameter in a portable way
879 (void) sm_lookup_entry;
880};
881#endif
882#elif defined(HAVE_MALLOC)
883sm_lookup_entry_t * btstack_memory_sm_lookup_entry_get(void){
743 return (sm_lookup_entry_t*) malloc(sizeof(sm_lookup_entry_t));
884 void * buffer = malloc(sizeof(sm_lookup_entry_t));
885 if (buffer){
886 memset(buffer, 0, sizeof(sm_lookup_entry_t));
887 }
888 return (sm_lookup_entry_t *) buffer;
744}
745void btstack_memory_sm_lookup_entry_free(sm_lookup_entry_t *sm_lookup_entry){
746 free(sm_lookup_entry);
747}
748#endif
749
750
751#endif

--- 59 unchanged lines hidden ---
889}
890void btstack_memory_sm_lookup_entry_free(sm_lookup_entry_t *sm_lookup_entry){
891 free(sm_lookup_entry);
892}
893#endif
894
895
896#endif

--- 59 unchanged lines hidden ---