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 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 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 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; 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 } 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 1436527a633S[email protected] hci_connection_t * btstack_memory_hci_connection_get(void){ 144c4d3f927Smatthias.ringwald return NULL; 145c4d3f927Smatthias.ringwald } 1466527a633S[email protected] void btstack_memory_hci_connection_free(hci_connection_t *hci_connection){ 147b6269742SMatthias Ringwald UNUSED(hci_connection); 148c4d3f927Smatthias.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 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 } 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; 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 } 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 2016527a633S[email protected] l2cap_service_t * btstack_memory_l2cap_service_get(void){ 202c4d3f927Smatthias.ringwald return NULL; 203c4d3f927Smatthias.ringwald } 2046527a633S[email protected] void btstack_memory_l2cap_service_free(l2cap_service_t *l2cap_service){ 205b6269742SMatthias Ringwald UNUSED(l2cap_service); 206c4d3f927Smatthias.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 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 } 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; 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 } 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 2586527a633S[email protected] l2cap_channel_t * btstack_memory_l2cap_channel_get(void){ 259c4d3f927Smatthias.ringwald return NULL; 260c4d3f927Smatthias.ringwald } 2616527a633S[email protected] void btstack_memory_l2cap_channel_free(l2cap_channel_t *l2cap_channel){ 262b6269742SMatthias Ringwald UNUSED(l2cap_channel); 263c4d3f927Smatthias.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 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 } 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; 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 } 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 3176527a633S[email protected] rfcomm_multiplexer_t * btstack_memory_rfcomm_multiplexer_get(void){ 318c4d3f927Smatthias.ringwald return NULL; 319c4d3f927Smatthias.ringwald } 3206527a633S[email protected] void btstack_memory_rfcomm_multiplexer_free(rfcomm_multiplexer_t *rfcomm_multiplexer){ 321b6269742SMatthias Ringwald UNUSED(rfcomm_multiplexer); 322c4d3f927Smatthias.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 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 } 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; 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 } 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 3746527a633S[email protected] rfcomm_service_t * btstack_memory_rfcomm_service_get(void){ 375c4d3f927Smatthias.ringwald return NULL; 376c4d3f927Smatthias.ringwald } 3776527a633S[email protected] void btstack_memory_rfcomm_service_free(rfcomm_service_t *rfcomm_service){ 378b6269742SMatthias Ringwald UNUSED(rfcomm_service); 379c4d3f927Smatthias.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 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 } 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; 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 } 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 4316527a633S[email protected] rfcomm_channel_t * btstack_memory_rfcomm_channel_get(void){ 432c4d3f927Smatthias.ringwald return NULL; 433c4d3f927Smatthias.ringwald } 4346527a633S[email protected] void btstack_memory_rfcomm_channel_free(rfcomm_channel_t *rfcomm_channel){ 435b6269742SMatthias Ringwald UNUSED(rfcomm_channel); 436c4d3f927Smatthias.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 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 } 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; 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 } 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 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 } 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); 494c4d3f927Smatthias.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 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 } 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; 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] } 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 5472e97c149S[email protected] bnep_service_t * btstack_memory_bnep_service_get(void){ 5482e97c149S[email protected] return NULL; 5492e97c149S[email protected] } 5502e97c149S[email protected] void btstack_memory_bnep_service_free(bnep_service_t *bnep_service){ 551b6269742SMatthias Ringwald UNUSED(bnep_service); 5522e97c149S[email protected] }; 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 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] } 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; 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] } 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 6042e97c149S[email protected] bnep_channel_t * btstack_memory_bnep_channel_get(void){ 6052e97c149S[email protected] return NULL; 6062e97c149S[email protected] } 6072e97c149S[email protected] void btstack_memory_bnep_channel_free(bnep_channel_t *bnep_channel){ 608b6269742SMatthias Ringwald UNUSED(bnep_channel); 6092e97c149S[email protected] }; 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 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] } 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 638*b8c00949SMatthias Ringwald // MARK: goep_server_service_t 639*b8c00949SMatthias Ringwald #if !defined(HAVE_MALLOC) && !defined(MAX_NR_GOEP_SERVER_SERVICES) 640*b8c00949SMatthias Ringwald #if defined(MAX_NO_GOEP_SERVER_SERVICES) 641*b8c00949SMatthias 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." 642*b8c00949SMatthias Ringwald #else 643*b8c00949SMatthias Ringwald #define MAX_NR_GOEP_SERVER_SERVICES 0 644*b8c00949SMatthias Ringwald #endif 645*b8c00949SMatthias Ringwald #endif 646*b8c00949SMatthias Ringwald 647*b8c00949SMatthias Ringwald #ifdef MAX_NR_GOEP_SERVER_SERVICES 648*b8c00949SMatthias Ringwald #if MAX_NR_GOEP_SERVER_SERVICES > 0 649*b8c00949SMatthias Ringwald static goep_server_service_t goep_server_service_storage[MAX_NR_GOEP_SERVER_SERVICES]; 650*b8c00949SMatthias Ringwald static btstack_memory_pool_t goep_server_service_pool; 651*b8c00949SMatthias Ringwald goep_server_service_t * btstack_memory_goep_server_service_get(void){ 652*b8c00949SMatthias Ringwald void * buffer = btstack_memory_pool_get(&goep_server_service_pool); 653*b8c00949SMatthias Ringwald if (buffer){ 654*b8c00949SMatthias Ringwald memset(buffer, 0, sizeof(goep_server_service_t)); 655*b8c00949SMatthias Ringwald } 656*b8c00949SMatthias Ringwald return (goep_server_service_t *) buffer; 657*b8c00949SMatthias Ringwald } 658*b8c00949SMatthias Ringwald void btstack_memory_goep_server_service_free(goep_server_service_t *goep_server_service){ 659*b8c00949SMatthias Ringwald btstack_memory_pool_free(&goep_server_service_pool, goep_server_service); 660*b8c00949SMatthias Ringwald } 661*b8c00949SMatthias Ringwald #else 662*b8c00949SMatthias Ringwald goep_server_service_t * btstack_memory_goep_server_service_get(void){ 663*b8c00949SMatthias Ringwald return NULL; 664*b8c00949SMatthias Ringwald } 665*b8c00949SMatthias Ringwald void btstack_memory_goep_server_service_free(goep_server_service_t *goep_server_service){ 666*b8c00949SMatthias Ringwald UNUSED(goep_server_service); 667*b8c00949SMatthias Ringwald }; 668*b8c00949SMatthias Ringwald #endif 669*b8c00949SMatthias Ringwald #elif defined(HAVE_MALLOC) 670*b8c00949SMatthias Ringwald 671*b8c00949SMatthias Ringwald typedef struct { 672*b8c00949SMatthias Ringwald btstack_memory_buffer_t tracking; 673*b8c00949SMatthias Ringwald goep_server_service_t data; 674*b8c00949SMatthias Ringwald } btstack_memory_goep_server_service_t; 675*b8c00949SMatthias Ringwald 676*b8c00949SMatthias Ringwald goep_server_service_t * btstack_memory_goep_server_service_get(void){ 677*b8c00949SMatthias Ringwald btstack_memory_goep_server_service_t * buffer = (btstack_memory_goep_server_service_t *) malloc(sizeof(btstack_memory_goep_server_service_t)); 678*b8c00949SMatthias Ringwald if (buffer){ 679*b8c00949SMatthias Ringwald memset(buffer, 0, sizeof(btstack_memory_goep_server_service_t)); 680*b8c00949SMatthias Ringwald btstack_memory_tracking_add(&buffer->tracking); 681*b8c00949SMatthias Ringwald return &buffer->data; 682*b8c00949SMatthias Ringwald } else { 683*b8c00949SMatthias Ringwald return NULL; 684*b8c00949SMatthias Ringwald } 685*b8c00949SMatthias Ringwald } 686*b8c00949SMatthias Ringwald void btstack_memory_goep_server_service_free(goep_server_service_t *goep_server_service){ 687*b8c00949SMatthias Ringwald // reconstruct buffer start 688*b8c00949SMatthias Ringwald btstack_memory_buffer_t * buffer = &((btstack_memory_buffer_t *) goep_server_service)[-1]; 689*b8c00949SMatthias Ringwald btstack_memory_tracking_remove(buffer); 690*b8c00949SMatthias Ringwald free(buffer); 691*b8c00949SMatthias Ringwald } 692*b8c00949SMatthias Ringwald #endif 693*b8c00949SMatthias Ringwald 694*b8c00949SMatthias Ringwald 695*b8c00949SMatthias Ringwald // MARK: goep_server_connection_t 696*b8c00949SMatthias Ringwald #if !defined(HAVE_MALLOC) && !defined(MAX_NR_GOEP_SERVER_CONNECTIONS) 697*b8c00949SMatthias Ringwald #if defined(MAX_NO_GOEP_SERVER_CONNECTIONS) 698*b8c00949SMatthias 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." 699*b8c00949SMatthias Ringwald #else 700*b8c00949SMatthias Ringwald #define MAX_NR_GOEP_SERVER_CONNECTIONS 0 701*b8c00949SMatthias Ringwald #endif 702*b8c00949SMatthias Ringwald #endif 703*b8c00949SMatthias Ringwald 704*b8c00949SMatthias Ringwald #ifdef MAX_NR_GOEP_SERVER_CONNECTIONS 705*b8c00949SMatthias Ringwald #if MAX_NR_GOEP_SERVER_CONNECTIONS > 0 706*b8c00949SMatthias Ringwald static goep_server_connection_t goep_server_connection_storage[MAX_NR_GOEP_SERVER_CONNECTIONS]; 707*b8c00949SMatthias Ringwald static btstack_memory_pool_t goep_server_connection_pool; 708*b8c00949SMatthias Ringwald goep_server_connection_t * btstack_memory_goep_server_connection_get(void){ 709*b8c00949SMatthias Ringwald void * buffer = btstack_memory_pool_get(&goep_server_connection_pool); 710*b8c00949SMatthias Ringwald if (buffer){ 711*b8c00949SMatthias Ringwald memset(buffer, 0, sizeof(goep_server_connection_t)); 712*b8c00949SMatthias Ringwald } 713*b8c00949SMatthias Ringwald return (goep_server_connection_t *) buffer; 714*b8c00949SMatthias Ringwald } 715*b8c00949SMatthias Ringwald void btstack_memory_goep_server_connection_free(goep_server_connection_t *goep_server_connection){ 716*b8c00949SMatthias Ringwald btstack_memory_pool_free(&goep_server_connection_pool, goep_server_connection); 717*b8c00949SMatthias Ringwald } 718*b8c00949SMatthias Ringwald #else 719*b8c00949SMatthias Ringwald goep_server_connection_t * btstack_memory_goep_server_connection_get(void){ 720*b8c00949SMatthias Ringwald return NULL; 721*b8c00949SMatthias Ringwald } 722*b8c00949SMatthias Ringwald void btstack_memory_goep_server_connection_free(goep_server_connection_t *goep_server_connection){ 723*b8c00949SMatthias Ringwald UNUSED(goep_server_connection); 724*b8c00949SMatthias Ringwald }; 725*b8c00949SMatthias Ringwald #endif 726*b8c00949SMatthias Ringwald #elif defined(HAVE_MALLOC) 727*b8c00949SMatthias Ringwald 728*b8c00949SMatthias Ringwald typedef struct { 729*b8c00949SMatthias Ringwald btstack_memory_buffer_t tracking; 730*b8c00949SMatthias Ringwald goep_server_connection_t data; 731*b8c00949SMatthias Ringwald } btstack_memory_goep_server_connection_t; 732*b8c00949SMatthias Ringwald 733*b8c00949SMatthias Ringwald goep_server_connection_t * btstack_memory_goep_server_connection_get(void){ 734*b8c00949SMatthias Ringwald btstack_memory_goep_server_connection_t * buffer = (btstack_memory_goep_server_connection_t *) malloc(sizeof(btstack_memory_goep_server_connection_t)); 735*b8c00949SMatthias Ringwald if (buffer){ 736*b8c00949SMatthias Ringwald memset(buffer, 0, sizeof(btstack_memory_goep_server_connection_t)); 737*b8c00949SMatthias Ringwald btstack_memory_tracking_add(&buffer->tracking); 738*b8c00949SMatthias Ringwald return &buffer->data; 739*b8c00949SMatthias Ringwald } else { 740*b8c00949SMatthias Ringwald return NULL; 741*b8c00949SMatthias Ringwald } 742*b8c00949SMatthias Ringwald } 743*b8c00949SMatthias Ringwald void btstack_memory_goep_server_connection_free(goep_server_connection_t *goep_server_connection){ 744*b8c00949SMatthias Ringwald // reconstruct buffer start 745*b8c00949SMatthias Ringwald btstack_memory_buffer_t * buffer = &((btstack_memory_buffer_t *) goep_server_connection)[-1]; 746*b8c00949SMatthias Ringwald btstack_memory_tracking_remove(buffer); 747*b8c00949SMatthias Ringwald free(buffer); 748*b8c00949SMatthias Ringwald } 749*b8c00949SMatthias Ringwald #endif 750*b8c00949SMatthias Ringwald 751*b8c00949SMatthias Ringwald 752*b8c00949SMatthias 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; 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 } 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 777ea5029c9SMilanka Ringwald hfp_connection_t * btstack_memory_hfp_connection_get(void){ 778ea5029c9SMilanka Ringwald return NULL; 779ea5029c9SMilanka Ringwald } 780ea5029c9SMilanka Ringwald void btstack_memory_hfp_connection_free(hfp_connection_t *hfp_connection){ 781b6269742SMatthias Ringwald UNUSED(hfp_connection); 782ea5029c9SMilanka 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 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 } 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; 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 } 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 835f399f7fbSMilanka Ringwald hid_host_connection_t * btstack_memory_hid_host_connection_get(void){ 836f399f7fbSMilanka Ringwald return NULL; 837f399f7fbSMilanka Ringwald } 838f399f7fbSMilanka Ringwald void btstack_memory_hid_host_connection_free(hid_host_connection_t *hid_host_connection){ 839174a0c1cSMilanka Ringwald UNUSED(hid_host_connection); 840f399f7fbSMilanka 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 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 } 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 8690e826a17SMilanka Ringwald // MARK: avdtp_stream_endpoint_t 8700e826a17SMilanka Ringwald #if !defined(HAVE_MALLOC) && !defined(MAX_NR_AVDTP_STREAM_ENDPOINTS) 8710e826a17SMilanka Ringwald #if defined(MAX_NO_AVDTP_STREAM_ENDPOINTS) 8720e826a17SMilanka 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." 87327faf85aSMilanka Ringwald #else 8740e826a17SMilanka Ringwald #define MAX_NR_AVDTP_STREAM_ENDPOINTS 0 87527faf85aSMilanka Ringwald #endif 87627faf85aSMilanka Ringwald #endif 87727faf85aSMilanka Ringwald 8780e826a17SMilanka Ringwald #ifdef MAX_NR_AVDTP_STREAM_ENDPOINTS 8790e826a17SMilanka Ringwald #if MAX_NR_AVDTP_STREAM_ENDPOINTS > 0 8800e826a17SMilanka Ringwald static avdtp_stream_endpoint_t avdtp_stream_endpoint_storage[MAX_NR_AVDTP_STREAM_ENDPOINTS]; 8810e826a17SMilanka Ringwald static btstack_memory_pool_t avdtp_stream_endpoint_pool; 8820e826a17SMilanka Ringwald avdtp_stream_endpoint_t * btstack_memory_avdtp_stream_endpoint_get(void){ 883a2673d88SMatthias Ringwald void * buffer = btstack_memory_pool_get(&avdtp_stream_endpoint_pool); 884a2673d88SMatthias Ringwald if (buffer){ 885a2673d88SMatthias Ringwald memset(buffer, 0, sizeof(avdtp_stream_endpoint_t)); 886a2673d88SMatthias Ringwald } 887a2673d88SMatthias Ringwald return (avdtp_stream_endpoint_t *) buffer; 88827faf85aSMilanka Ringwald } 8890e826a17SMilanka Ringwald void btstack_memory_avdtp_stream_endpoint_free(avdtp_stream_endpoint_t *avdtp_stream_endpoint){ 8900e826a17SMilanka Ringwald btstack_memory_pool_free(&avdtp_stream_endpoint_pool, avdtp_stream_endpoint); 89127faf85aSMilanka Ringwald } 89227faf85aSMilanka Ringwald #else 8930e826a17SMilanka Ringwald avdtp_stream_endpoint_t * btstack_memory_avdtp_stream_endpoint_get(void){ 89427faf85aSMilanka Ringwald return NULL; 89527faf85aSMilanka Ringwald } 8960e826a17SMilanka Ringwald void btstack_memory_avdtp_stream_endpoint_free(avdtp_stream_endpoint_t *avdtp_stream_endpoint){ 897b6269742SMatthias Ringwald UNUSED(avdtp_stream_endpoint); 89827faf85aSMilanka Ringwald }; 89927faf85aSMilanka Ringwald #endif 90027faf85aSMilanka Ringwald #elif defined(HAVE_MALLOC) 9012a95308bSMatthias Ringwald 9022a95308bSMatthias Ringwald typedef struct { 9032a95308bSMatthias Ringwald btstack_memory_buffer_t tracking; 904798bd46fSMatthias Ringwald avdtp_stream_endpoint_t data; 9052a95308bSMatthias Ringwald } btstack_memory_avdtp_stream_endpoint_t; 9062a95308bSMatthias Ringwald 9070e826a17SMilanka Ringwald avdtp_stream_endpoint_t * btstack_memory_avdtp_stream_endpoint_get(void){ 9082a95308bSMatthias Ringwald btstack_memory_avdtp_stream_endpoint_t * buffer = (btstack_memory_avdtp_stream_endpoint_t *) malloc(sizeof(btstack_memory_avdtp_stream_endpoint_t)); 909a2673d88SMatthias Ringwald if (buffer){ 910798bd46fSMatthias Ringwald memset(buffer, 0, sizeof(btstack_memory_avdtp_stream_endpoint_t)); 9112a95308bSMatthias Ringwald btstack_memory_tracking_add(&buffer->tracking); 9122a95308bSMatthias Ringwald return &buffer->data; 913b6269742SMatthias Ringwald } else { 914b6269742SMatthias Ringwald return NULL; 915a2673d88SMatthias Ringwald } 91627faf85aSMilanka Ringwald } 9170e826a17SMilanka Ringwald void btstack_memory_avdtp_stream_endpoint_free(avdtp_stream_endpoint_t *avdtp_stream_endpoint){ 918798bd46fSMatthias Ringwald // reconstruct buffer start 919798bd46fSMatthias Ringwald btstack_memory_buffer_t * buffer = &((btstack_memory_buffer_t *) avdtp_stream_endpoint)[-1]; 920798bd46fSMatthias Ringwald btstack_memory_tracking_remove(buffer); 921b6269742SMatthias Ringwald free(buffer); 92227faf85aSMilanka Ringwald } 92327faf85aSMilanka Ringwald #endif 92427faf85aSMilanka Ringwald 92527faf85aSMilanka Ringwald 92612e7f38cSMilanka Ringwald 92712e7f38cSMilanka Ringwald // MARK: avdtp_connection_t 92812e7f38cSMilanka Ringwald #if !defined(HAVE_MALLOC) && !defined(MAX_NR_AVDTP_CONNECTIONS) 92912e7f38cSMilanka Ringwald #if defined(MAX_NO_AVDTP_CONNECTIONS) 93012e7f38cSMilanka 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." 93112e7f38cSMilanka Ringwald #else 93212e7f38cSMilanka Ringwald #define MAX_NR_AVDTP_CONNECTIONS 0 93312e7f38cSMilanka Ringwald #endif 93412e7f38cSMilanka Ringwald #endif 93512e7f38cSMilanka Ringwald 93612e7f38cSMilanka Ringwald #ifdef MAX_NR_AVDTP_CONNECTIONS 93712e7f38cSMilanka Ringwald #if MAX_NR_AVDTP_CONNECTIONS > 0 93812e7f38cSMilanka Ringwald static avdtp_connection_t avdtp_connection_storage[MAX_NR_AVDTP_CONNECTIONS]; 93912e7f38cSMilanka Ringwald static btstack_memory_pool_t avdtp_connection_pool; 94012e7f38cSMilanka Ringwald avdtp_connection_t * btstack_memory_avdtp_connection_get(void){ 941a2673d88SMatthias Ringwald void * buffer = btstack_memory_pool_get(&avdtp_connection_pool); 942a2673d88SMatthias Ringwald if (buffer){ 943a2673d88SMatthias Ringwald memset(buffer, 0, sizeof(avdtp_connection_t)); 944a2673d88SMatthias Ringwald } 945a2673d88SMatthias Ringwald return (avdtp_connection_t *) buffer; 94612e7f38cSMilanka Ringwald } 94712e7f38cSMilanka Ringwald void btstack_memory_avdtp_connection_free(avdtp_connection_t *avdtp_connection){ 94812e7f38cSMilanka Ringwald btstack_memory_pool_free(&avdtp_connection_pool, avdtp_connection); 94912e7f38cSMilanka Ringwald } 95012e7f38cSMilanka Ringwald #else 95112e7f38cSMilanka Ringwald avdtp_connection_t * btstack_memory_avdtp_connection_get(void){ 95212e7f38cSMilanka Ringwald return NULL; 95312e7f38cSMilanka Ringwald } 95412e7f38cSMilanka Ringwald void btstack_memory_avdtp_connection_free(avdtp_connection_t *avdtp_connection){ 955b6269742SMatthias Ringwald UNUSED(avdtp_connection); 95612e7f38cSMilanka Ringwald }; 95712e7f38cSMilanka Ringwald #endif 95812e7f38cSMilanka Ringwald #elif defined(HAVE_MALLOC) 9592a95308bSMatthias Ringwald 9602a95308bSMatthias Ringwald typedef struct { 9612a95308bSMatthias Ringwald btstack_memory_buffer_t tracking; 962798bd46fSMatthias Ringwald avdtp_connection_t data; 9632a95308bSMatthias Ringwald } btstack_memory_avdtp_connection_t; 9642a95308bSMatthias Ringwald 96512e7f38cSMilanka Ringwald avdtp_connection_t * btstack_memory_avdtp_connection_get(void){ 9662a95308bSMatthias Ringwald btstack_memory_avdtp_connection_t * buffer = (btstack_memory_avdtp_connection_t *) malloc(sizeof(btstack_memory_avdtp_connection_t)); 967a2673d88SMatthias Ringwald if (buffer){ 968798bd46fSMatthias Ringwald memset(buffer, 0, sizeof(btstack_memory_avdtp_connection_t)); 9692a95308bSMatthias Ringwald btstack_memory_tracking_add(&buffer->tracking); 9702a95308bSMatthias Ringwald return &buffer->data; 971b6269742SMatthias Ringwald } else { 972b6269742SMatthias Ringwald return NULL; 973a2673d88SMatthias Ringwald } 97412e7f38cSMilanka Ringwald } 97512e7f38cSMilanka Ringwald void btstack_memory_avdtp_connection_free(avdtp_connection_t *avdtp_connection){ 976798bd46fSMatthias Ringwald // reconstruct buffer start 977798bd46fSMatthias Ringwald btstack_memory_buffer_t * buffer = &((btstack_memory_buffer_t *) avdtp_connection)[-1]; 978798bd46fSMatthias Ringwald btstack_memory_tracking_remove(buffer); 979b6269742SMatthias Ringwald free(buffer); 98012e7f38cSMilanka Ringwald } 98112e7f38cSMilanka Ringwald #endif 98212e7f38cSMilanka Ringwald 98312e7f38cSMilanka Ringwald 98491451a2bSMilanka Ringwald 98591451a2bSMilanka Ringwald // MARK: avrcp_connection_t 98691451a2bSMilanka Ringwald #if !defined(HAVE_MALLOC) && !defined(MAX_NR_AVRCP_CONNECTIONS) 98791451a2bSMilanka Ringwald #if defined(MAX_NO_AVRCP_CONNECTIONS) 98891451a2bSMilanka 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." 98991451a2bSMilanka Ringwald #else 99091451a2bSMilanka Ringwald #define MAX_NR_AVRCP_CONNECTIONS 0 99191451a2bSMilanka Ringwald #endif 99291451a2bSMilanka Ringwald #endif 99391451a2bSMilanka Ringwald 99491451a2bSMilanka Ringwald #ifdef MAX_NR_AVRCP_CONNECTIONS 99591451a2bSMilanka Ringwald #if MAX_NR_AVRCP_CONNECTIONS > 0 99691451a2bSMilanka Ringwald static avrcp_connection_t avrcp_connection_storage[MAX_NR_AVRCP_CONNECTIONS]; 99791451a2bSMilanka Ringwald static btstack_memory_pool_t avrcp_connection_pool; 99891451a2bSMilanka Ringwald avrcp_connection_t * btstack_memory_avrcp_connection_get(void){ 999a2673d88SMatthias Ringwald void * buffer = btstack_memory_pool_get(&avrcp_connection_pool); 1000a2673d88SMatthias Ringwald if (buffer){ 1001a2673d88SMatthias Ringwald memset(buffer, 0, sizeof(avrcp_connection_t)); 1002a2673d88SMatthias Ringwald } 1003a2673d88SMatthias Ringwald return (avrcp_connection_t *) buffer; 100491451a2bSMilanka Ringwald } 100591451a2bSMilanka Ringwald void btstack_memory_avrcp_connection_free(avrcp_connection_t *avrcp_connection){ 100691451a2bSMilanka Ringwald btstack_memory_pool_free(&avrcp_connection_pool, avrcp_connection); 100791451a2bSMilanka Ringwald } 100891451a2bSMilanka Ringwald #else 100991451a2bSMilanka Ringwald avrcp_connection_t * btstack_memory_avrcp_connection_get(void){ 101091451a2bSMilanka Ringwald return NULL; 101191451a2bSMilanka Ringwald } 101291451a2bSMilanka Ringwald void btstack_memory_avrcp_connection_free(avrcp_connection_t *avrcp_connection){ 1013b6269742SMatthias Ringwald UNUSED(avrcp_connection); 101491451a2bSMilanka Ringwald }; 101591451a2bSMilanka Ringwald #endif 101691451a2bSMilanka Ringwald #elif defined(HAVE_MALLOC) 10172a95308bSMatthias Ringwald 10182a95308bSMatthias Ringwald typedef struct { 10192a95308bSMatthias Ringwald btstack_memory_buffer_t tracking; 1020798bd46fSMatthias Ringwald avrcp_connection_t data; 10212a95308bSMatthias Ringwald } btstack_memory_avrcp_connection_t; 10222a95308bSMatthias Ringwald 102391451a2bSMilanka Ringwald avrcp_connection_t * btstack_memory_avrcp_connection_get(void){ 10242a95308bSMatthias Ringwald btstack_memory_avrcp_connection_t * buffer = (btstack_memory_avrcp_connection_t *) malloc(sizeof(btstack_memory_avrcp_connection_t)); 1025a2673d88SMatthias Ringwald if (buffer){ 1026798bd46fSMatthias Ringwald memset(buffer, 0, sizeof(btstack_memory_avrcp_connection_t)); 10272a95308bSMatthias Ringwald btstack_memory_tracking_add(&buffer->tracking); 10282a95308bSMatthias Ringwald return &buffer->data; 1029b6269742SMatthias Ringwald } else { 1030b6269742SMatthias Ringwald return NULL; 1031a2673d88SMatthias Ringwald } 103291451a2bSMilanka Ringwald } 103391451a2bSMilanka Ringwald void btstack_memory_avrcp_connection_free(avrcp_connection_t *avrcp_connection){ 1034798bd46fSMatthias Ringwald // reconstruct buffer start 1035798bd46fSMatthias Ringwald btstack_memory_buffer_t * buffer = &((btstack_memory_buffer_t *) avrcp_connection)[-1]; 1036798bd46fSMatthias Ringwald btstack_memory_tracking_remove(buffer); 1037b6269742SMatthias Ringwald free(buffer); 103891451a2bSMilanka Ringwald } 103991451a2bSMilanka Ringwald #endif 104091451a2bSMilanka Ringwald 104191451a2bSMilanka Ringwald 1042f12a3722SMilanka Ringwald 1043f12a3722SMilanka Ringwald // MARK: avrcp_browsing_connection_t 1044f12a3722SMilanka Ringwald #if !defined(HAVE_MALLOC) && !defined(MAX_NR_AVRCP_BROWSING_CONNECTIONS) 1045f12a3722SMilanka Ringwald #if defined(MAX_NO_AVRCP_BROWSING_CONNECTIONS) 1046f12a3722SMilanka 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." 1047f12a3722SMilanka Ringwald #else 1048f12a3722SMilanka Ringwald #define MAX_NR_AVRCP_BROWSING_CONNECTIONS 0 1049f12a3722SMilanka Ringwald #endif 1050f12a3722SMilanka Ringwald #endif 1051f12a3722SMilanka Ringwald 1052f12a3722SMilanka Ringwald #ifdef MAX_NR_AVRCP_BROWSING_CONNECTIONS 1053f12a3722SMilanka Ringwald #if MAX_NR_AVRCP_BROWSING_CONNECTIONS > 0 1054f12a3722SMilanka Ringwald static avrcp_browsing_connection_t avrcp_browsing_connection_storage[MAX_NR_AVRCP_BROWSING_CONNECTIONS]; 1055f12a3722SMilanka Ringwald static btstack_memory_pool_t avrcp_browsing_connection_pool; 1056f12a3722SMilanka Ringwald avrcp_browsing_connection_t * btstack_memory_avrcp_browsing_connection_get(void){ 1057a2673d88SMatthias Ringwald void * buffer = btstack_memory_pool_get(&avrcp_browsing_connection_pool); 1058a2673d88SMatthias Ringwald if (buffer){ 1059a2673d88SMatthias Ringwald memset(buffer, 0, sizeof(avrcp_browsing_connection_t)); 1060a2673d88SMatthias Ringwald } 1061a2673d88SMatthias Ringwald return (avrcp_browsing_connection_t *) buffer; 1062f12a3722SMilanka Ringwald } 1063f12a3722SMilanka Ringwald void btstack_memory_avrcp_browsing_connection_free(avrcp_browsing_connection_t *avrcp_browsing_connection){ 1064f12a3722SMilanka Ringwald btstack_memory_pool_free(&avrcp_browsing_connection_pool, avrcp_browsing_connection); 1065f12a3722SMilanka Ringwald } 1066f12a3722SMilanka Ringwald #else 1067f12a3722SMilanka Ringwald avrcp_browsing_connection_t * btstack_memory_avrcp_browsing_connection_get(void){ 1068f12a3722SMilanka Ringwald return NULL; 1069f12a3722SMilanka Ringwald } 1070f12a3722SMilanka Ringwald void btstack_memory_avrcp_browsing_connection_free(avrcp_browsing_connection_t *avrcp_browsing_connection){ 1071b6269742SMatthias Ringwald UNUSED(avrcp_browsing_connection); 1072f12a3722SMilanka Ringwald }; 1073f12a3722SMilanka Ringwald #endif 1074f12a3722SMilanka Ringwald #elif defined(HAVE_MALLOC) 10752a95308bSMatthias Ringwald 10762a95308bSMatthias Ringwald typedef struct { 10772a95308bSMatthias Ringwald btstack_memory_buffer_t tracking; 1078798bd46fSMatthias Ringwald avrcp_browsing_connection_t data; 10792a95308bSMatthias Ringwald } btstack_memory_avrcp_browsing_connection_t; 10802a95308bSMatthias Ringwald 1081f12a3722SMilanka Ringwald avrcp_browsing_connection_t * btstack_memory_avrcp_browsing_connection_get(void){ 10822a95308bSMatthias Ringwald btstack_memory_avrcp_browsing_connection_t * buffer = (btstack_memory_avrcp_browsing_connection_t *) malloc(sizeof(btstack_memory_avrcp_browsing_connection_t)); 1083a2673d88SMatthias Ringwald if (buffer){ 1084798bd46fSMatthias Ringwald memset(buffer, 0, sizeof(btstack_memory_avrcp_browsing_connection_t)); 10852a95308bSMatthias Ringwald btstack_memory_tracking_add(&buffer->tracking); 10862a95308bSMatthias Ringwald return &buffer->data; 1087b6269742SMatthias Ringwald } else { 1088b6269742SMatthias Ringwald return NULL; 1089a2673d88SMatthias Ringwald } 1090f12a3722SMilanka Ringwald } 1091f12a3722SMilanka Ringwald void btstack_memory_avrcp_browsing_connection_free(avrcp_browsing_connection_t *avrcp_browsing_connection){ 1092798bd46fSMatthias Ringwald // reconstruct buffer start 1093798bd46fSMatthias Ringwald btstack_memory_buffer_t * buffer = &((btstack_memory_buffer_t *) avrcp_browsing_connection)[-1]; 1094798bd46fSMatthias Ringwald btstack_memory_tracking_remove(buffer); 1095b6269742SMatthias Ringwald free(buffer); 1096f12a3722SMilanka Ringwald } 1097f12a3722SMilanka Ringwald #endif 1098f12a3722SMilanka Ringwald 1099f12a3722SMilanka Ringwald 1100*b8c00949SMatthias Ringwald 1101*b8c00949SMatthias Ringwald // MARK: service_record_item_t 1102*b8c00949SMatthias Ringwald #if !defined(HAVE_MALLOC) && !defined(MAX_NR_SERVICE_RECORD_ITEMS) 1103*b8c00949SMatthias Ringwald #if defined(MAX_NO_SERVICE_RECORD_ITEMS) 1104*b8c00949SMatthias 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." 1105*b8c00949SMatthias Ringwald #else 1106*b8c00949SMatthias Ringwald #define MAX_NR_SERVICE_RECORD_ITEMS 0 1107*b8c00949SMatthias Ringwald #endif 1108*b8c00949SMatthias Ringwald #endif 1109*b8c00949SMatthias Ringwald 1110*b8c00949SMatthias Ringwald #ifdef MAX_NR_SERVICE_RECORD_ITEMS 1111*b8c00949SMatthias Ringwald #if MAX_NR_SERVICE_RECORD_ITEMS > 0 1112*b8c00949SMatthias Ringwald static service_record_item_t service_record_item_storage[MAX_NR_SERVICE_RECORD_ITEMS]; 1113*b8c00949SMatthias Ringwald static btstack_memory_pool_t service_record_item_pool; 1114*b8c00949SMatthias Ringwald service_record_item_t * btstack_memory_service_record_item_get(void){ 1115*b8c00949SMatthias Ringwald void * buffer = btstack_memory_pool_get(&service_record_item_pool); 1116*b8c00949SMatthias Ringwald if (buffer){ 1117*b8c00949SMatthias Ringwald memset(buffer, 0, sizeof(service_record_item_t)); 1118*b8c00949SMatthias Ringwald } 1119*b8c00949SMatthias Ringwald return (service_record_item_t *) buffer; 1120*b8c00949SMatthias Ringwald } 1121*b8c00949SMatthias Ringwald void btstack_memory_service_record_item_free(service_record_item_t *service_record_item){ 1122*b8c00949SMatthias Ringwald btstack_memory_pool_free(&service_record_item_pool, service_record_item); 1123*b8c00949SMatthias Ringwald } 1124*b8c00949SMatthias Ringwald #else 1125*b8c00949SMatthias Ringwald service_record_item_t * btstack_memory_service_record_item_get(void){ 1126*b8c00949SMatthias Ringwald return NULL; 1127*b8c00949SMatthias Ringwald } 1128*b8c00949SMatthias Ringwald void btstack_memory_service_record_item_free(service_record_item_t *service_record_item){ 1129*b8c00949SMatthias Ringwald UNUSED(service_record_item); 1130*b8c00949SMatthias Ringwald }; 1131*b8c00949SMatthias Ringwald #endif 1132*b8c00949SMatthias Ringwald #elif defined(HAVE_MALLOC) 1133*b8c00949SMatthias Ringwald 1134*b8c00949SMatthias Ringwald typedef struct { 1135*b8c00949SMatthias Ringwald btstack_memory_buffer_t tracking; 1136*b8c00949SMatthias Ringwald service_record_item_t data; 1137*b8c00949SMatthias Ringwald } btstack_memory_service_record_item_t; 1138*b8c00949SMatthias Ringwald 1139*b8c00949SMatthias Ringwald service_record_item_t * btstack_memory_service_record_item_get(void){ 1140*b8c00949SMatthias Ringwald btstack_memory_service_record_item_t * buffer = (btstack_memory_service_record_item_t *) malloc(sizeof(btstack_memory_service_record_item_t)); 1141*b8c00949SMatthias Ringwald if (buffer){ 1142*b8c00949SMatthias Ringwald memset(buffer, 0, sizeof(btstack_memory_service_record_item_t)); 1143*b8c00949SMatthias Ringwald btstack_memory_tracking_add(&buffer->tracking); 1144*b8c00949SMatthias Ringwald return &buffer->data; 1145*b8c00949SMatthias Ringwald } else { 1146*b8c00949SMatthias Ringwald return NULL; 1147*b8c00949SMatthias Ringwald } 1148*b8c00949SMatthias Ringwald } 1149*b8c00949SMatthias Ringwald void btstack_memory_service_record_item_free(service_record_item_t *service_record_item){ 1150*b8c00949SMatthias Ringwald // reconstruct buffer start 1151*b8c00949SMatthias Ringwald btstack_memory_buffer_t * buffer = &((btstack_memory_buffer_t *) service_record_item)[-1]; 1152*b8c00949SMatthias Ringwald btstack_memory_tracking_remove(buffer); 1153*b8c00949SMatthias Ringwald free(buffer); 1154*b8c00949SMatthias Ringwald } 1155*b8c00949SMatthias Ringwald #endif 1156*b8c00949SMatthias Ringwald 1157*b8c00949SMatthias 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; 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 } 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 1185174a0c1cSMilanka Ringwald battery_service_client_t * btstack_memory_battery_service_client_get(void){ 1186174a0c1cSMilanka Ringwald return NULL; 1187174a0c1cSMilanka Ringwald } 1188174a0c1cSMilanka Ringwald void btstack_memory_battery_service_client_free(battery_service_client_t *battery_service_client){ 1189174a0c1cSMilanka Ringwald UNUSED(battery_service_client); 1190174a0c1cSMilanka 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 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 } 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; 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] } 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 1242d0fdae3cS[email protected] gatt_client_t * btstack_memory_gatt_client_get(void){ 1243d0fdae3cS[email protected] return NULL; 1244d0fdae3cS[email protected] } 1245d0fdae3cS[email protected] void btstack_memory_gatt_client_free(gatt_client_t *gatt_client){ 1246b6269742SMatthias Ringwald UNUSED(gatt_client); 1247d0fdae3cS[email protected] }; 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 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] } 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; 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 } 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 1299cf26c8fbSMilanka Ringwald hids_client_t * btstack_memory_hids_client_get(void){ 1300cf26c8fbSMilanka Ringwald return NULL; 1301cf26c8fbSMilanka Ringwald } 1302cf26c8fbSMilanka Ringwald void btstack_memory_hids_client_free(hids_client_t *hids_client){ 1303cf26c8fbSMilanka Ringwald UNUSED(hids_client); 1304cf26c8fbSMilanka 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 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 } 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; 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 } 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 1356cf26c8fbSMilanka Ringwald scan_parameters_service_client_t * btstack_memory_scan_parameters_service_client_get(void){ 1357cf26c8fbSMilanka Ringwald return NULL; 1358cf26c8fbSMilanka Ringwald } 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); 1361cf26c8fbSMilanka 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 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 } 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; 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 } 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 1413cf49570bSMatthias Ringwald sm_lookup_entry_t * btstack_memory_sm_lookup_entry_get(void){ 1414cf49570bSMatthias Ringwald return NULL; 1415cf49570bSMatthias Ringwald } 1416cf49570bSMatthias Ringwald void btstack_memory_sm_lookup_entry_free(sm_lookup_entry_t *sm_lookup_entry){ 1417b6269742SMatthias Ringwald UNUSED(sm_lookup_entry); 1418cf49570bSMatthias 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 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 } 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; 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 } 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 1470174a0c1cSMilanka Ringwald whitelist_entry_t * btstack_memory_whitelist_entry_get(void){ 1471174a0c1cSMilanka Ringwald return NULL; 1472174a0c1cSMilanka Ringwald } 1473174a0c1cSMilanka Ringwald void btstack_memory_whitelist_entry_free(whitelist_entry_t *whitelist_entry){ 1474174a0c1cSMilanka Ringwald UNUSED(whitelist_entry); 1475174a0c1cSMilanka 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 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 } 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; 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 } 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 1527dbca66ffSMatthias Ringwald periodic_advertiser_list_entry_t * btstack_memory_periodic_advertiser_list_entry_get(void){ 1528dbca66ffSMatthias Ringwald return NULL; 1529dbca66ffSMatthias Ringwald } 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); 1532dbca66ffSMatthias 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 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 } 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; 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 } 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 1587ebb73e1fSMatthias Ringwald mesh_network_pdu_t * btstack_memory_mesh_network_pdu_get(void){ 1588ebb73e1fSMatthias Ringwald return NULL; 1589ebb73e1fSMatthias Ringwald } 1590ebb73e1fSMatthias Ringwald void btstack_memory_mesh_network_pdu_free(mesh_network_pdu_t *mesh_network_pdu){ 1591b6269742SMatthias Ringwald UNUSED(mesh_network_pdu); 1592ebb73e1fSMatthias 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 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 } 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; 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 } 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 1644a4bbc09dSMatthias Ringwald mesh_segmented_pdu_t * btstack_memory_mesh_segmented_pdu_get(void){ 1645f7434c1fSMatthias Ringwald return NULL; 1646f7434c1fSMatthias Ringwald } 1647a4bbc09dSMatthias Ringwald void btstack_memory_mesh_segmented_pdu_free(mesh_segmented_pdu_t *mesh_segmented_pdu){ 1648b6269742SMatthias Ringwald UNUSED(mesh_segmented_pdu); 1649f7434c1fSMatthias 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 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 } 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; 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 } 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 1701491f99b3SMatthias Ringwald mesh_upper_transport_pdu_t * btstack_memory_mesh_upper_transport_pdu_get(void){ 1702491f99b3SMatthias Ringwald return NULL; 1703491f99b3SMatthias Ringwald } 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); 1706491f99b3SMatthias 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 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 } 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; 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 } 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 1758c0a711d9SMatthias Ringwald mesh_network_key_t * btstack_memory_mesh_network_key_get(void){ 1759c0a711d9SMatthias Ringwald return NULL; 1760c0a711d9SMatthias Ringwald } 1761c0a711d9SMatthias Ringwald void btstack_memory_mesh_network_key_free(mesh_network_key_t *mesh_network_key){ 1762b6269742SMatthias Ringwald UNUSED(mesh_network_key); 1763c0a711d9SMatthias 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 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 } 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; 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 } 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 181501e2bf94SMatthias Ringwald mesh_transport_key_t * btstack_memory_mesh_transport_key_get(void){ 181601e2bf94SMatthias Ringwald return NULL; 181701e2bf94SMatthias Ringwald } 181801e2bf94SMatthias Ringwald void btstack_memory_mesh_transport_key_free(mesh_transport_key_t *mesh_transport_key){ 1819b6269742SMatthias Ringwald UNUSED(mesh_transport_key); 182001e2bf94SMatthias 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 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 } 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; 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 } 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 18721f45d603SMatthias Ringwald mesh_virtual_address_t * btstack_memory_mesh_virtual_address_get(void){ 18731f45d603SMatthias Ringwald return NULL; 18741f45d603SMatthias Ringwald } 18751f45d603SMatthias Ringwald void btstack_memory_mesh_virtual_address_free(mesh_virtual_address_t *mesh_virtual_address){ 1876b6269742SMatthias Ringwald UNUSED(mesh_virtual_address); 18771f45d603SMatthias 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 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 } 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; 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 } 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 192901122b73SMatthias Ringwald mesh_subnet_t * btstack_memory_mesh_subnet_get(void){ 193001122b73SMatthias Ringwald return NULL; 193101122b73SMatthias Ringwald } 193201122b73SMatthias Ringwald void btstack_memory_mesh_subnet_free(mesh_subnet_t *mesh_subnet){ 1933b6269742SMatthias Ringwald UNUSED(mesh_subnet); 193401122b73SMatthias 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 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 } 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 1963798bd46fSMatthias Ringwald 1964a3b02b71Smatthias.ringwald // init 1965a3b02b71Smatthias.ringwald void btstack_memory_init(void){ 1966798bd46fSMatthias Ringwald #ifdef HAVE_MALLOC 1967798bd46fSMatthias Ringwald // assert that there is no unexpected padding for combined buffer 1968798bd46fSMatthias Ringwald btstack_assert(sizeof(test_buffer_t) == sizeof(btstack_memory_buffer_t) + sizeof(void *)); 1969798bd46fSMatthias Ringwald #endif 1970798bd46fSMatthias Ringwald 1971a265b909SMatthias Ringwald #if MAX_NR_HCI_CONNECTIONS > 0 1972a265b909SMatthias Ringwald btstack_memory_pool_create(&hci_connection_pool, hci_connection_storage, MAX_NR_HCI_CONNECTIONS, sizeof(hci_connection_t)); 1973a3b02b71Smatthias.ringwald #endif 1974a265b909SMatthias Ringwald #if MAX_NR_L2CAP_SERVICES > 0 1975a265b909SMatthias Ringwald btstack_memory_pool_create(&l2cap_service_pool, l2cap_service_storage, MAX_NR_L2CAP_SERVICES, sizeof(l2cap_service_t)); 1976a3b02b71Smatthias.ringwald #endif 1977a265b909SMatthias Ringwald #if MAX_NR_L2CAP_CHANNELS > 0 1978a265b909SMatthias Ringwald btstack_memory_pool_create(&l2cap_channel_pool, l2cap_channel_storage, MAX_NR_L2CAP_CHANNELS, sizeof(l2cap_channel_t)); 1979a3b02b71Smatthias.ringwald #endif 198044c5d856SMatthias Ringwald #ifdef ENABLE_CLASSIC 198150dc57fcSMatthias Ringwald #if MAX_NR_RFCOMM_MULTIPLEXERS > 0 198250dc57fcSMatthias Ringwald btstack_memory_pool_create(&rfcomm_multiplexer_pool, rfcomm_multiplexer_storage, MAX_NR_RFCOMM_MULTIPLEXERS, sizeof(rfcomm_multiplexer_t)); 1983a3b02b71Smatthias.ringwald #endif 198450dc57fcSMatthias Ringwald #if MAX_NR_RFCOMM_SERVICES > 0 198550dc57fcSMatthias Ringwald btstack_memory_pool_create(&rfcomm_service_pool, rfcomm_service_storage, MAX_NR_RFCOMM_SERVICES, sizeof(rfcomm_service_t)); 1986a3b02b71Smatthias.ringwald #endif 198750dc57fcSMatthias Ringwald #if MAX_NR_RFCOMM_CHANNELS > 0 198850dc57fcSMatthias Ringwald btstack_memory_pool_create(&rfcomm_channel_pool, rfcomm_channel_storage, MAX_NR_RFCOMM_CHANNELS, sizeof(rfcomm_channel_t)); 198950dc57fcSMatthias Ringwald #endif 199050dc57fcSMatthias Ringwald #if MAX_NR_BTSTACK_LINK_KEY_DB_MEMORY_ENTRIES > 0 199150dc57fcSMatthias 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)); 199250dc57fcSMatthias Ringwald #endif 199350dc57fcSMatthias Ringwald #if MAX_NR_BNEP_SERVICES > 0 199450dc57fcSMatthias Ringwald btstack_memory_pool_create(&bnep_service_pool, bnep_service_storage, MAX_NR_BNEP_SERVICES, sizeof(bnep_service_t)); 199550dc57fcSMatthias Ringwald #endif 199650dc57fcSMatthias Ringwald #if MAX_NR_BNEP_CHANNELS > 0 199750dc57fcSMatthias Ringwald btstack_memory_pool_create(&bnep_channel_pool, bnep_channel_storage, MAX_NR_BNEP_CHANNELS, sizeof(bnep_channel_t)); 199850dc57fcSMatthias Ringwald #endif 1999*b8c00949SMatthias Ringwald #if MAX_NR_GOEP_SERVER_SERVICES > 0 2000*b8c00949SMatthias Ringwald btstack_memory_pool_create(&goep_server_service_pool, goep_server_service_storage, MAX_NR_GOEP_SERVER_SERVICES, sizeof(goep_server_service_t)); 2001*b8c00949SMatthias Ringwald #endif 2002*b8c00949SMatthias Ringwald #if MAX_NR_GOEP_SERVER_CONNECTIONS > 0 2003*b8c00949SMatthias Ringwald btstack_memory_pool_create(&goep_server_connection_pool, goep_server_connection_storage, MAX_NR_GOEP_SERVER_CONNECTIONS, sizeof(goep_server_connection_t)); 2004*b8c00949SMatthias Ringwald #endif 200550dc57fcSMatthias Ringwald #if MAX_NR_HFP_CONNECTIONS > 0 200650dc57fcSMatthias Ringwald btstack_memory_pool_create(&hfp_connection_pool, hfp_connection_storage, MAX_NR_HFP_CONNECTIONS, sizeof(hfp_connection_t)); 200750dc57fcSMatthias Ringwald #endif 2008f399f7fbSMilanka Ringwald #if MAX_NR_HID_HOST_CONNECTIONS > 0 2009f399f7fbSMilanka Ringwald btstack_memory_pool_create(&hid_host_connection_pool, hid_host_connection_storage, MAX_NR_HID_HOST_CONNECTIONS, sizeof(hid_host_connection_t)); 2010f399f7fbSMilanka Ringwald #endif 201150dc57fcSMatthias Ringwald #if MAX_NR_AVDTP_STREAM_ENDPOINTS > 0 201250dc57fcSMatthias Ringwald btstack_memory_pool_create(&avdtp_stream_endpoint_pool, avdtp_stream_endpoint_storage, MAX_NR_AVDTP_STREAM_ENDPOINTS, sizeof(avdtp_stream_endpoint_t)); 201350dc57fcSMatthias Ringwald #endif 201450dc57fcSMatthias Ringwald #if MAX_NR_AVDTP_CONNECTIONS > 0 201550dc57fcSMatthias Ringwald btstack_memory_pool_create(&avdtp_connection_pool, avdtp_connection_storage, MAX_NR_AVDTP_CONNECTIONS, sizeof(avdtp_connection_t)); 201650dc57fcSMatthias Ringwald #endif 201750dc57fcSMatthias Ringwald #if MAX_NR_AVRCP_CONNECTIONS > 0 201850dc57fcSMatthias Ringwald btstack_memory_pool_create(&avrcp_connection_pool, avrcp_connection_storage, MAX_NR_AVRCP_CONNECTIONS, sizeof(avrcp_connection_t)); 201950dc57fcSMatthias Ringwald #endif 202050dc57fcSMatthias Ringwald #if MAX_NR_AVRCP_BROWSING_CONNECTIONS > 0 202150dc57fcSMatthias Ringwald btstack_memory_pool_create(&avrcp_browsing_connection_pool, avrcp_browsing_connection_storage, MAX_NR_AVRCP_BROWSING_CONNECTIONS, sizeof(avrcp_browsing_connection_t)); 2022a3b02b71Smatthias.ringwald #endif 2023*b8c00949SMatthias Ringwald #if MAX_NR_SERVICE_RECORD_ITEMS > 0 2024*b8c00949SMatthias Ringwald btstack_memory_pool_create(&service_record_item_pool, service_record_item_storage, MAX_NR_SERVICE_RECORD_ITEMS, sizeof(service_record_item_t)); 2025*b8c00949SMatthias Ringwald #endif 2026f12a3722SMilanka Ringwald #endif 2027a9a4c409SMatthias Ringwald #ifdef ENABLE_BLE 2028174a0c1cSMilanka Ringwald #if MAX_NR_BATTERY_SERVICE_CLIENTS > 0 2029174a0c1cSMilanka Ringwald btstack_memory_pool_create(&battery_service_client_pool, battery_service_client_storage, MAX_NR_BATTERY_SERVICE_CLIENTS, sizeof(battery_service_client_t)); 2030174a0c1cSMilanka Ringwald #endif 2031a265b909SMatthias Ringwald #if MAX_NR_GATT_CLIENTS > 0 2032a265b909SMatthias Ringwald btstack_memory_pool_create(&gatt_client_pool, gatt_client_storage, MAX_NR_GATT_CLIENTS, sizeof(gatt_client_t)); 2033d0fdae3cS[email protected] #endif 2034cf26c8fbSMilanka Ringwald #if MAX_NR_HIDS_CLIENTS > 0 2035cf26c8fbSMilanka Ringwald btstack_memory_pool_create(&hids_client_pool, hids_client_storage, MAX_NR_HIDS_CLIENTS, sizeof(hids_client_t)); 2036cf26c8fbSMilanka Ringwald #endif 2037cf26c8fbSMilanka Ringwald #if MAX_NR_SCAN_PARAMETERS_SERVICE_CLIENTS > 0 2038cf26c8fbSMilanka 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)); 2039cf26c8fbSMilanka Ringwald #endif 2040a265b909SMatthias Ringwald #if MAX_NR_SM_LOOKUP_ENTRIES > 0 2041a265b909SMatthias Ringwald btstack_memory_pool_create(&sm_lookup_entry_pool, sm_lookup_entry_storage, MAX_NR_SM_LOOKUP_ENTRIES, sizeof(sm_lookup_entry_t)); 2042cf49570bSMatthias Ringwald #endif 2043174a0c1cSMilanka Ringwald #if MAX_NR_WHITELIST_ENTRIES > 0 2044174a0c1cSMilanka Ringwald btstack_memory_pool_create(&whitelist_entry_pool, whitelist_entry_storage, MAX_NR_WHITELIST_ENTRIES, sizeof(whitelist_entry_t)); 2045174a0c1cSMilanka Ringwald #endif 2046dbca66ffSMatthias Ringwald #if MAX_NR_PERIODIC_ADVERTISER_LIST_ENTRIES > 0 2047dbca66ffSMatthias 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)); 2048dbca66ffSMatthias Ringwald #endif 2049ebb73e1fSMatthias Ringwald #endif 205044c5d856SMatthias Ringwald #ifdef ENABLE_MESH 205150dc57fcSMatthias Ringwald #if MAX_NR_MESH_NETWORK_PDUS > 0 205250dc57fcSMatthias Ringwald btstack_memory_pool_create(&mesh_network_pdu_pool, mesh_network_pdu_storage, MAX_NR_MESH_NETWORK_PDUS, sizeof(mesh_network_pdu_t)); 205344c5d856SMatthias Ringwald #endif 2054a4bbc09dSMatthias Ringwald #if MAX_NR_MESH_SEGMENTED_PDUS > 0 2055a4bbc09dSMatthias Ringwald btstack_memory_pool_create(&mesh_segmented_pdu_pool, mesh_segmented_pdu_storage, MAX_NR_MESH_SEGMENTED_PDUS, sizeof(mesh_segmented_pdu_t)); 2056f7434c1fSMatthias Ringwald #endif 2057491f99b3SMatthias Ringwald #if MAX_NR_MESH_UPPER_TRANSPORT_PDUS > 0 2058491f99b3SMatthias 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)); 2059491f99b3SMatthias Ringwald #endif 206050dc57fcSMatthias Ringwald #if MAX_NR_MESH_NETWORK_KEYS > 0 206150dc57fcSMatthias Ringwald btstack_memory_pool_create(&mesh_network_key_pool, mesh_network_key_storage, MAX_NR_MESH_NETWORK_KEYS, sizeof(mesh_network_key_t)); 2062c0a711d9SMatthias Ringwald #endif 206301e2bf94SMatthias Ringwald #if MAX_NR_MESH_TRANSPORT_KEYS > 0 206401e2bf94SMatthias Ringwald btstack_memory_pool_create(&mesh_transport_key_pool, mesh_transport_key_storage, MAX_NR_MESH_TRANSPORT_KEYS, sizeof(mesh_transport_key_t)); 206501e2bf94SMatthias Ringwald #endif 20661f45d603SMatthias Ringwald #if MAX_NR_MESH_VIRTUAL_ADDRESSS > 0 20671f45d603SMatthias Ringwald btstack_memory_pool_create(&mesh_virtual_address_pool, mesh_virtual_address_storage, MAX_NR_MESH_VIRTUAL_ADDRESSS, sizeof(mesh_virtual_address_t)); 20681f45d603SMatthias Ringwald #endif 206901122b73SMatthias Ringwald #if MAX_NR_MESH_SUBNETS > 0 207001122b73SMatthias Ringwald btstack_memory_pool_create(&mesh_subnet_pool, mesh_subnet_storage, MAX_NR_MESH_SUBNETS, sizeof(mesh_subnet_t)); 207101122b73SMatthias Ringwald #endif 2072a7d12effS[email protected] #endif 2073a3b02b71Smatthias.ringwald } 2074