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 59*4490dd1dSMatthias 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 638ea5029c9SMilanka Ringwald // MARK: hfp_connection_t 639a265b909SMatthias Ringwald #if !defined(HAVE_MALLOC) && !defined(MAX_NR_HFP_CONNECTIONS) 640a265b909SMatthias Ringwald #if defined(MAX_NO_HFP_CONNECTIONS) 64127faf85aSMilanka 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." 642a265b909SMatthias Ringwald #else 643a265b909SMatthias Ringwald #define MAX_NR_HFP_CONNECTIONS 0 644a265b909SMatthias Ringwald #endif 645a265b909SMatthias Ringwald #endif 646a265b909SMatthias Ringwald 647a265b909SMatthias Ringwald #ifdef MAX_NR_HFP_CONNECTIONS 648a265b909SMatthias Ringwald #if MAX_NR_HFP_CONNECTIONS > 0 649a265b909SMatthias Ringwald static hfp_connection_t hfp_connection_storage[MAX_NR_HFP_CONNECTIONS]; 65029d0c4f7SMatthias Ringwald static btstack_memory_pool_t hfp_connection_pool; 651ea5029c9SMilanka Ringwald hfp_connection_t * btstack_memory_hfp_connection_get(void){ 652a2673d88SMatthias Ringwald void * buffer = btstack_memory_pool_get(&hfp_connection_pool); 653a2673d88SMatthias Ringwald if (buffer){ 654a2673d88SMatthias Ringwald memset(buffer, 0, sizeof(hfp_connection_t)); 655a2673d88SMatthias Ringwald } 656a2673d88SMatthias Ringwald return (hfp_connection_t *) buffer; 657ea5029c9SMilanka Ringwald } 658ea5029c9SMilanka Ringwald void btstack_memory_hfp_connection_free(hfp_connection_t *hfp_connection){ 65929d0c4f7SMatthias Ringwald btstack_memory_pool_free(&hfp_connection_pool, hfp_connection); 660ea5029c9SMilanka Ringwald } 661ea5029c9SMilanka Ringwald #else 662ea5029c9SMilanka Ringwald hfp_connection_t * btstack_memory_hfp_connection_get(void){ 663ea5029c9SMilanka Ringwald return NULL; 664ea5029c9SMilanka Ringwald } 665ea5029c9SMilanka Ringwald void btstack_memory_hfp_connection_free(hfp_connection_t *hfp_connection){ 666b6269742SMatthias Ringwald UNUSED(hfp_connection); 667ea5029c9SMilanka Ringwald }; 668ea5029c9SMilanka Ringwald #endif 669ea5029c9SMilanka Ringwald #elif defined(HAVE_MALLOC) 6702a95308bSMatthias Ringwald 6712a95308bSMatthias Ringwald typedef struct { 6722a95308bSMatthias Ringwald btstack_memory_buffer_t tracking; 673798bd46fSMatthias Ringwald hfp_connection_t data; 6742a95308bSMatthias Ringwald } btstack_memory_hfp_connection_t; 6752a95308bSMatthias Ringwald 676ea5029c9SMilanka Ringwald hfp_connection_t * btstack_memory_hfp_connection_get(void){ 6772a95308bSMatthias Ringwald btstack_memory_hfp_connection_t * buffer = (btstack_memory_hfp_connection_t *) malloc(sizeof(btstack_memory_hfp_connection_t)); 678a2673d88SMatthias Ringwald if (buffer){ 679798bd46fSMatthias Ringwald memset(buffer, 0, sizeof(btstack_memory_hfp_connection_t)); 6802a95308bSMatthias Ringwald btstack_memory_tracking_add(&buffer->tracking); 6812a95308bSMatthias Ringwald return &buffer->data; 682b6269742SMatthias Ringwald } else { 683b6269742SMatthias Ringwald return NULL; 684a2673d88SMatthias Ringwald } 685ea5029c9SMilanka Ringwald } 686ea5029c9SMilanka Ringwald void btstack_memory_hfp_connection_free(hfp_connection_t *hfp_connection){ 687798bd46fSMatthias Ringwald // reconstruct buffer start 688798bd46fSMatthias Ringwald btstack_memory_buffer_t * buffer = &((btstack_memory_buffer_t *) hfp_connection)[-1]; 689798bd46fSMatthias Ringwald btstack_memory_tracking_remove(buffer); 690b6269742SMatthias Ringwald free(buffer); 691ea5029c9SMilanka Ringwald } 692ea5029c9SMilanka Ringwald #endif 693ea5029c9SMilanka Ringwald 694ea5029c9SMilanka Ringwald 695cd9ee144SMatthias Ringwald 696f399f7fbSMilanka Ringwald // MARK: hid_host_connection_t 697f399f7fbSMilanka Ringwald #if !defined(HAVE_MALLOC) && !defined(MAX_NR_HID_HOST_CONNECTIONS) 698f399f7fbSMilanka Ringwald #if defined(MAX_NO_HID_HOST_CONNECTIONS) 699f399f7fbSMilanka 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." 700f399f7fbSMilanka Ringwald #else 701f399f7fbSMilanka Ringwald #define MAX_NR_HID_HOST_CONNECTIONS 0 702f399f7fbSMilanka Ringwald #endif 703f399f7fbSMilanka Ringwald #endif 704f399f7fbSMilanka Ringwald 705f399f7fbSMilanka Ringwald #ifdef MAX_NR_HID_HOST_CONNECTIONS 706f399f7fbSMilanka Ringwald #if MAX_NR_HID_HOST_CONNECTIONS > 0 707f399f7fbSMilanka Ringwald static hid_host_connection_t hid_host_connection_storage[MAX_NR_HID_HOST_CONNECTIONS]; 708f399f7fbSMilanka Ringwald static btstack_memory_pool_t hid_host_connection_pool; 709f399f7fbSMilanka Ringwald hid_host_connection_t * btstack_memory_hid_host_connection_get(void){ 710f399f7fbSMilanka Ringwald void * buffer = btstack_memory_pool_get(&hid_host_connection_pool); 711f399f7fbSMilanka Ringwald if (buffer){ 712f399f7fbSMilanka Ringwald memset(buffer, 0, sizeof(hid_host_connection_t)); 713f399f7fbSMilanka Ringwald } 714f399f7fbSMilanka Ringwald return (hid_host_connection_t *) buffer; 715f399f7fbSMilanka Ringwald } 716f399f7fbSMilanka Ringwald void btstack_memory_hid_host_connection_free(hid_host_connection_t *hid_host_connection){ 717f399f7fbSMilanka Ringwald btstack_memory_pool_free(&hid_host_connection_pool, hid_host_connection); 718f399f7fbSMilanka Ringwald } 719f399f7fbSMilanka Ringwald #else 720f399f7fbSMilanka Ringwald hid_host_connection_t * btstack_memory_hid_host_connection_get(void){ 721f399f7fbSMilanka Ringwald return NULL; 722f399f7fbSMilanka Ringwald } 723f399f7fbSMilanka Ringwald void btstack_memory_hid_host_connection_free(hid_host_connection_t *hid_host_connection){ 724174a0c1cSMilanka Ringwald UNUSED(hid_host_connection); 725f399f7fbSMilanka Ringwald }; 726f399f7fbSMilanka Ringwald #endif 727f399f7fbSMilanka Ringwald #elif defined(HAVE_MALLOC) 728174a0c1cSMilanka Ringwald 729174a0c1cSMilanka Ringwald typedef struct { 730174a0c1cSMilanka Ringwald btstack_memory_buffer_t tracking; 731174a0c1cSMilanka Ringwald hid_host_connection_t data; 732174a0c1cSMilanka Ringwald } btstack_memory_hid_host_connection_t; 733174a0c1cSMilanka Ringwald 734f399f7fbSMilanka Ringwald hid_host_connection_t * btstack_memory_hid_host_connection_get(void){ 735174a0c1cSMilanka Ringwald btstack_memory_hid_host_connection_t * buffer = (btstack_memory_hid_host_connection_t *) malloc(sizeof(btstack_memory_hid_host_connection_t)); 736f399f7fbSMilanka Ringwald if (buffer){ 737174a0c1cSMilanka Ringwald memset(buffer, 0, sizeof(btstack_memory_hid_host_connection_t)); 738174a0c1cSMilanka Ringwald btstack_memory_tracking_add(&buffer->tracking); 739174a0c1cSMilanka Ringwald return &buffer->data; 740174a0c1cSMilanka Ringwald } else { 741174a0c1cSMilanka Ringwald return NULL; 742f399f7fbSMilanka Ringwald } 743f399f7fbSMilanka Ringwald } 744f399f7fbSMilanka Ringwald void btstack_memory_hid_host_connection_free(hid_host_connection_t *hid_host_connection){ 745174a0c1cSMilanka Ringwald // reconstruct buffer start 746174a0c1cSMilanka Ringwald btstack_memory_buffer_t * buffer = &((btstack_memory_buffer_t *) hid_host_connection)[-1]; 747174a0c1cSMilanka Ringwald btstack_memory_tracking_remove(buffer); 748174a0c1cSMilanka Ringwald free(buffer); 749f399f7fbSMilanka Ringwald } 750f399f7fbSMilanka Ringwald #endif 751f399f7fbSMilanka Ringwald 752f399f7fbSMilanka Ringwald 753f399f7fbSMilanka Ringwald 754cd9ee144SMatthias Ringwald // MARK: service_record_item_t 755a265b909SMatthias Ringwald #if !defined(HAVE_MALLOC) && !defined(MAX_NR_SERVICE_RECORD_ITEMS) 756a265b909SMatthias Ringwald #if defined(MAX_NO_SERVICE_RECORD_ITEMS) 75727faf85aSMilanka 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." 758a265b909SMatthias Ringwald #else 759a265b909SMatthias Ringwald #define MAX_NR_SERVICE_RECORD_ITEMS 0 760a265b909SMatthias Ringwald #endif 761a265b909SMatthias Ringwald #endif 762a265b909SMatthias Ringwald 763a265b909SMatthias Ringwald #ifdef MAX_NR_SERVICE_RECORD_ITEMS 764a265b909SMatthias Ringwald #if MAX_NR_SERVICE_RECORD_ITEMS > 0 765a265b909SMatthias Ringwald static service_record_item_t service_record_item_storage[MAX_NR_SERVICE_RECORD_ITEMS]; 76629d0c4f7SMatthias Ringwald static btstack_memory_pool_t service_record_item_pool; 767cd9ee144SMatthias Ringwald service_record_item_t * btstack_memory_service_record_item_get(void){ 768a2673d88SMatthias Ringwald void * buffer = btstack_memory_pool_get(&service_record_item_pool); 769a2673d88SMatthias Ringwald if (buffer){ 770a2673d88SMatthias Ringwald memset(buffer, 0, sizeof(service_record_item_t)); 771a2673d88SMatthias Ringwald } 772a2673d88SMatthias Ringwald return (service_record_item_t *) buffer; 773cd9ee144SMatthias Ringwald } 774cd9ee144SMatthias Ringwald void btstack_memory_service_record_item_free(service_record_item_t *service_record_item){ 77529d0c4f7SMatthias Ringwald btstack_memory_pool_free(&service_record_item_pool, service_record_item); 776cd9ee144SMatthias Ringwald } 777cd9ee144SMatthias Ringwald #else 778cd9ee144SMatthias Ringwald service_record_item_t * btstack_memory_service_record_item_get(void){ 779cd9ee144SMatthias Ringwald return NULL; 780cd9ee144SMatthias Ringwald } 781cd9ee144SMatthias Ringwald void btstack_memory_service_record_item_free(service_record_item_t *service_record_item){ 782b6269742SMatthias Ringwald UNUSED(service_record_item); 783cd9ee144SMatthias Ringwald }; 784cd9ee144SMatthias Ringwald #endif 785cd9ee144SMatthias Ringwald #elif defined(HAVE_MALLOC) 7862a95308bSMatthias Ringwald 7872a95308bSMatthias Ringwald typedef struct { 7882a95308bSMatthias Ringwald btstack_memory_buffer_t tracking; 789798bd46fSMatthias Ringwald service_record_item_t data; 7902a95308bSMatthias Ringwald } btstack_memory_service_record_item_t; 7912a95308bSMatthias Ringwald 792cd9ee144SMatthias Ringwald service_record_item_t * btstack_memory_service_record_item_get(void){ 7932a95308bSMatthias Ringwald btstack_memory_service_record_item_t * buffer = (btstack_memory_service_record_item_t *) malloc(sizeof(btstack_memory_service_record_item_t)); 794a2673d88SMatthias Ringwald if (buffer){ 795798bd46fSMatthias Ringwald memset(buffer, 0, sizeof(btstack_memory_service_record_item_t)); 7962a95308bSMatthias Ringwald btstack_memory_tracking_add(&buffer->tracking); 7972a95308bSMatthias Ringwald return &buffer->data; 798b6269742SMatthias Ringwald } else { 799b6269742SMatthias Ringwald return NULL; 800a2673d88SMatthias Ringwald } 801cd9ee144SMatthias Ringwald } 802cd9ee144SMatthias Ringwald void btstack_memory_service_record_item_free(service_record_item_t *service_record_item){ 803798bd46fSMatthias Ringwald // reconstruct buffer start 804798bd46fSMatthias Ringwald btstack_memory_buffer_t * buffer = &((btstack_memory_buffer_t *) service_record_item)[-1]; 805798bd46fSMatthias Ringwald btstack_memory_tracking_remove(buffer); 806b6269742SMatthias Ringwald free(buffer); 807cd9ee144SMatthias Ringwald } 808cd9ee144SMatthias Ringwald #endif 809cd9ee144SMatthias Ringwald 810cd9ee144SMatthias Ringwald 81127faf85aSMilanka Ringwald 8120e826a17SMilanka Ringwald // MARK: avdtp_stream_endpoint_t 8130e826a17SMilanka Ringwald #if !defined(HAVE_MALLOC) && !defined(MAX_NR_AVDTP_STREAM_ENDPOINTS) 8140e826a17SMilanka Ringwald #if defined(MAX_NO_AVDTP_STREAM_ENDPOINTS) 8150e826a17SMilanka 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." 81627faf85aSMilanka Ringwald #else 8170e826a17SMilanka Ringwald #define MAX_NR_AVDTP_STREAM_ENDPOINTS 0 81827faf85aSMilanka Ringwald #endif 81927faf85aSMilanka Ringwald #endif 82027faf85aSMilanka Ringwald 8210e826a17SMilanka Ringwald #ifdef MAX_NR_AVDTP_STREAM_ENDPOINTS 8220e826a17SMilanka Ringwald #if MAX_NR_AVDTP_STREAM_ENDPOINTS > 0 8230e826a17SMilanka Ringwald static avdtp_stream_endpoint_t avdtp_stream_endpoint_storage[MAX_NR_AVDTP_STREAM_ENDPOINTS]; 8240e826a17SMilanka Ringwald static btstack_memory_pool_t avdtp_stream_endpoint_pool; 8250e826a17SMilanka Ringwald avdtp_stream_endpoint_t * btstack_memory_avdtp_stream_endpoint_get(void){ 826a2673d88SMatthias Ringwald void * buffer = btstack_memory_pool_get(&avdtp_stream_endpoint_pool); 827a2673d88SMatthias Ringwald if (buffer){ 828a2673d88SMatthias Ringwald memset(buffer, 0, sizeof(avdtp_stream_endpoint_t)); 829a2673d88SMatthias Ringwald } 830a2673d88SMatthias Ringwald return (avdtp_stream_endpoint_t *) buffer; 83127faf85aSMilanka Ringwald } 8320e826a17SMilanka Ringwald void btstack_memory_avdtp_stream_endpoint_free(avdtp_stream_endpoint_t *avdtp_stream_endpoint){ 8330e826a17SMilanka Ringwald btstack_memory_pool_free(&avdtp_stream_endpoint_pool, avdtp_stream_endpoint); 83427faf85aSMilanka Ringwald } 83527faf85aSMilanka Ringwald #else 8360e826a17SMilanka Ringwald avdtp_stream_endpoint_t * btstack_memory_avdtp_stream_endpoint_get(void){ 83727faf85aSMilanka Ringwald return NULL; 83827faf85aSMilanka Ringwald } 8390e826a17SMilanka Ringwald void btstack_memory_avdtp_stream_endpoint_free(avdtp_stream_endpoint_t *avdtp_stream_endpoint){ 840b6269742SMatthias Ringwald UNUSED(avdtp_stream_endpoint); 84127faf85aSMilanka Ringwald }; 84227faf85aSMilanka Ringwald #endif 84327faf85aSMilanka Ringwald #elif defined(HAVE_MALLOC) 8442a95308bSMatthias Ringwald 8452a95308bSMatthias Ringwald typedef struct { 8462a95308bSMatthias Ringwald btstack_memory_buffer_t tracking; 847798bd46fSMatthias Ringwald avdtp_stream_endpoint_t data; 8482a95308bSMatthias Ringwald } btstack_memory_avdtp_stream_endpoint_t; 8492a95308bSMatthias Ringwald 8500e826a17SMilanka Ringwald avdtp_stream_endpoint_t * btstack_memory_avdtp_stream_endpoint_get(void){ 8512a95308bSMatthias Ringwald btstack_memory_avdtp_stream_endpoint_t * buffer = (btstack_memory_avdtp_stream_endpoint_t *) malloc(sizeof(btstack_memory_avdtp_stream_endpoint_t)); 852a2673d88SMatthias Ringwald if (buffer){ 853798bd46fSMatthias Ringwald memset(buffer, 0, sizeof(btstack_memory_avdtp_stream_endpoint_t)); 8542a95308bSMatthias Ringwald btstack_memory_tracking_add(&buffer->tracking); 8552a95308bSMatthias Ringwald return &buffer->data; 856b6269742SMatthias Ringwald } else { 857b6269742SMatthias Ringwald return NULL; 858a2673d88SMatthias Ringwald } 85927faf85aSMilanka Ringwald } 8600e826a17SMilanka Ringwald void btstack_memory_avdtp_stream_endpoint_free(avdtp_stream_endpoint_t *avdtp_stream_endpoint){ 861798bd46fSMatthias Ringwald // reconstruct buffer start 862798bd46fSMatthias Ringwald btstack_memory_buffer_t * buffer = &((btstack_memory_buffer_t *) avdtp_stream_endpoint)[-1]; 863798bd46fSMatthias Ringwald btstack_memory_tracking_remove(buffer); 864b6269742SMatthias Ringwald free(buffer); 86527faf85aSMilanka Ringwald } 86627faf85aSMilanka Ringwald #endif 86727faf85aSMilanka Ringwald 86827faf85aSMilanka Ringwald 86912e7f38cSMilanka Ringwald 87012e7f38cSMilanka Ringwald // MARK: avdtp_connection_t 87112e7f38cSMilanka Ringwald #if !defined(HAVE_MALLOC) && !defined(MAX_NR_AVDTP_CONNECTIONS) 87212e7f38cSMilanka Ringwald #if defined(MAX_NO_AVDTP_CONNECTIONS) 87312e7f38cSMilanka 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." 87412e7f38cSMilanka Ringwald #else 87512e7f38cSMilanka Ringwald #define MAX_NR_AVDTP_CONNECTIONS 0 87612e7f38cSMilanka Ringwald #endif 87712e7f38cSMilanka Ringwald #endif 87812e7f38cSMilanka Ringwald 87912e7f38cSMilanka Ringwald #ifdef MAX_NR_AVDTP_CONNECTIONS 88012e7f38cSMilanka Ringwald #if MAX_NR_AVDTP_CONNECTIONS > 0 88112e7f38cSMilanka Ringwald static avdtp_connection_t avdtp_connection_storage[MAX_NR_AVDTP_CONNECTIONS]; 88212e7f38cSMilanka Ringwald static btstack_memory_pool_t avdtp_connection_pool; 88312e7f38cSMilanka Ringwald avdtp_connection_t * btstack_memory_avdtp_connection_get(void){ 884a2673d88SMatthias Ringwald void * buffer = btstack_memory_pool_get(&avdtp_connection_pool); 885a2673d88SMatthias Ringwald if (buffer){ 886a2673d88SMatthias Ringwald memset(buffer, 0, sizeof(avdtp_connection_t)); 887a2673d88SMatthias Ringwald } 888a2673d88SMatthias Ringwald return (avdtp_connection_t *) buffer; 88912e7f38cSMilanka Ringwald } 89012e7f38cSMilanka Ringwald void btstack_memory_avdtp_connection_free(avdtp_connection_t *avdtp_connection){ 89112e7f38cSMilanka Ringwald btstack_memory_pool_free(&avdtp_connection_pool, avdtp_connection); 89212e7f38cSMilanka Ringwald } 89312e7f38cSMilanka Ringwald #else 89412e7f38cSMilanka Ringwald avdtp_connection_t * btstack_memory_avdtp_connection_get(void){ 89512e7f38cSMilanka Ringwald return NULL; 89612e7f38cSMilanka Ringwald } 89712e7f38cSMilanka Ringwald void btstack_memory_avdtp_connection_free(avdtp_connection_t *avdtp_connection){ 898b6269742SMatthias Ringwald UNUSED(avdtp_connection); 89912e7f38cSMilanka Ringwald }; 90012e7f38cSMilanka Ringwald #endif 90112e7f38cSMilanka Ringwald #elif defined(HAVE_MALLOC) 9022a95308bSMatthias Ringwald 9032a95308bSMatthias Ringwald typedef struct { 9042a95308bSMatthias Ringwald btstack_memory_buffer_t tracking; 905798bd46fSMatthias Ringwald avdtp_connection_t data; 9062a95308bSMatthias Ringwald } btstack_memory_avdtp_connection_t; 9072a95308bSMatthias Ringwald 90812e7f38cSMilanka Ringwald avdtp_connection_t * btstack_memory_avdtp_connection_get(void){ 9092a95308bSMatthias Ringwald btstack_memory_avdtp_connection_t * buffer = (btstack_memory_avdtp_connection_t *) malloc(sizeof(btstack_memory_avdtp_connection_t)); 910a2673d88SMatthias Ringwald if (buffer){ 911798bd46fSMatthias Ringwald memset(buffer, 0, sizeof(btstack_memory_avdtp_connection_t)); 9122a95308bSMatthias Ringwald btstack_memory_tracking_add(&buffer->tracking); 9132a95308bSMatthias Ringwald return &buffer->data; 914b6269742SMatthias Ringwald } else { 915b6269742SMatthias Ringwald return NULL; 916a2673d88SMatthias Ringwald } 91712e7f38cSMilanka Ringwald } 91812e7f38cSMilanka Ringwald void btstack_memory_avdtp_connection_free(avdtp_connection_t *avdtp_connection){ 919798bd46fSMatthias Ringwald // reconstruct buffer start 920798bd46fSMatthias Ringwald btstack_memory_buffer_t * buffer = &((btstack_memory_buffer_t *) avdtp_connection)[-1]; 921798bd46fSMatthias Ringwald btstack_memory_tracking_remove(buffer); 922b6269742SMatthias Ringwald free(buffer); 92312e7f38cSMilanka Ringwald } 92412e7f38cSMilanka Ringwald #endif 92512e7f38cSMilanka Ringwald 92612e7f38cSMilanka Ringwald 92791451a2bSMilanka Ringwald 92891451a2bSMilanka Ringwald // MARK: avrcp_connection_t 92991451a2bSMilanka Ringwald #if !defined(HAVE_MALLOC) && !defined(MAX_NR_AVRCP_CONNECTIONS) 93091451a2bSMilanka Ringwald #if defined(MAX_NO_AVRCP_CONNECTIONS) 93191451a2bSMilanka 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." 93291451a2bSMilanka Ringwald #else 93391451a2bSMilanka Ringwald #define MAX_NR_AVRCP_CONNECTIONS 0 93491451a2bSMilanka Ringwald #endif 93591451a2bSMilanka Ringwald #endif 93691451a2bSMilanka Ringwald 93791451a2bSMilanka Ringwald #ifdef MAX_NR_AVRCP_CONNECTIONS 93891451a2bSMilanka Ringwald #if MAX_NR_AVRCP_CONNECTIONS > 0 93991451a2bSMilanka Ringwald static avrcp_connection_t avrcp_connection_storage[MAX_NR_AVRCP_CONNECTIONS]; 94091451a2bSMilanka Ringwald static btstack_memory_pool_t avrcp_connection_pool; 94191451a2bSMilanka Ringwald avrcp_connection_t * btstack_memory_avrcp_connection_get(void){ 942a2673d88SMatthias Ringwald void * buffer = btstack_memory_pool_get(&avrcp_connection_pool); 943a2673d88SMatthias Ringwald if (buffer){ 944a2673d88SMatthias Ringwald memset(buffer, 0, sizeof(avrcp_connection_t)); 945a2673d88SMatthias Ringwald } 946a2673d88SMatthias Ringwald return (avrcp_connection_t *) buffer; 94791451a2bSMilanka Ringwald } 94891451a2bSMilanka Ringwald void btstack_memory_avrcp_connection_free(avrcp_connection_t *avrcp_connection){ 94991451a2bSMilanka Ringwald btstack_memory_pool_free(&avrcp_connection_pool, avrcp_connection); 95091451a2bSMilanka Ringwald } 95191451a2bSMilanka Ringwald #else 95291451a2bSMilanka Ringwald avrcp_connection_t * btstack_memory_avrcp_connection_get(void){ 95391451a2bSMilanka Ringwald return NULL; 95491451a2bSMilanka Ringwald } 95591451a2bSMilanka Ringwald void btstack_memory_avrcp_connection_free(avrcp_connection_t *avrcp_connection){ 956b6269742SMatthias Ringwald UNUSED(avrcp_connection); 95791451a2bSMilanka Ringwald }; 95891451a2bSMilanka Ringwald #endif 95991451a2bSMilanka Ringwald #elif defined(HAVE_MALLOC) 9602a95308bSMatthias Ringwald 9612a95308bSMatthias Ringwald typedef struct { 9622a95308bSMatthias Ringwald btstack_memory_buffer_t tracking; 963798bd46fSMatthias Ringwald avrcp_connection_t data; 9642a95308bSMatthias Ringwald } btstack_memory_avrcp_connection_t; 9652a95308bSMatthias Ringwald 96691451a2bSMilanka Ringwald avrcp_connection_t * btstack_memory_avrcp_connection_get(void){ 9672a95308bSMatthias Ringwald btstack_memory_avrcp_connection_t * buffer = (btstack_memory_avrcp_connection_t *) malloc(sizeof(btstack_memory_avrcp_connection_t)); 968a2673d88SMatthias Ringwald if (buffer){ 969798bd46fSMatthias Ringwald memset(buffer, 0, sizeof(btstack_memory_avrcp_connection_t)); 9702a95308bSMatthias Ringwald btstack_memory_tracking_add(&buffer->tracking); 9712a95308bSMatthias Ringwald return &buffer->data; 972b6269742SMatthias Ringwald } else { 973b6269742SMatthias Ringwald return NULL; 974a2673d88SMatthias Ringwald } 97591451a2bSMilanka Ringwald } 97691451a2bSMilanka Ringwald void btstack_memory_avrcp_connection_free(avrcp_connection_t *avrcp_connection){ 977798bd46fSMatthias Ringwald // reconstruct buffer start 978798bd46fSMatthias Ringwald btstack_memory_buffer_t * buffer = &((btstack_memory_buffer_t *) avrcp_connection)[-1]; 979798bd46fSMatthias Ringwald btstack_memory_tracking_remove(buffer); 980b6269742SMatthias Ringwald free(buffer); 98191451a2bSMilanka Ringwald } 98291451a2bSMilanka Ringwald #endif 98391451a2bSMilanka Ringwald 98491451a2bSMilanka Ringwald 985f12a3722SMilanka Ringwald 986f12a3722SMilanka Ringwald // MARK: avrcp_browsing_connection_t 987f12a3722SMilanka Ringwald #if !defined(HAVE_MALLOC) && !defined(MAX_NR_AVRCP_BROWSING_CONNECTIONS) 988f12a3722SMilanka Ringwald #if defined(MAX_NO_AVRCP_BROWSING_CONNECTIONS) 989f12a3722SMilanka 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." 990f12a3722SMilanka Ringwald #else 991f12a3722SMilanka Ringwald #define MAX_NR_AVRCP_BROWSING_CONNECTIONS 0 992f12a3722SMilanka Ringwald #endif 993f12a3722SMilanka Ringwald #endif 994f12a3722SMilanka Ringwald 995f12a3722SMilanka Ringwald #ifdef MAX_NR_AVRCP_BROWSING_CONNECTIONS 996f12a3722SMilanka Ringwald #if MAX_NR_AVRCP_BROWSING_CONNECTIONS > 0 997f12a3722SMilanka Ringwald static avrcp_browsing_connection_t avrcp_browsing_connection_storage[MAX_NR_AVRCP_BROWSING_CONNECTIONS]; 998f12a3722SMilanka Ringwald static btstack_memory_pool_t avrcp_browsing_connection_pool; 999f12a3722SMilanka Ringwald avrcp_browsing_connection_t * btstack_memory_avrcp_browsing_connection_get(void){ 1000a2673d88SMatthias Ringwald void * buffer = btstack_memory_pool_get(&avrcp_browsing_connection_pool); 1001a2673d88SMatthias Ringwald if (buffer){ 1002a2673d88SMatthias Ringwald memset(buffer, 0, sizeof(avrcp_browsing_connection_t)); 1003a2673d88SMatthias Ringwald } 1004a2673d88SMatthias Ringwald return (avrcp_browsing_connection_t *) buffer; 1005f12a3722SMilanka Ringwald } 1006f12a3722SMilanka Ringwald void btstack_memory_avrcp_browsing_connection_free(avrcp_browsing_connection_t *avrcp_browsing_connection){ 1007f12a3722SMilanka Ringwald btstack_memory_pool_free(&avrcp_browsing_connection_pool, avrcp_browsing_connection); 1008f12a3722SMilanka Ringwald } 1009f12a3722SMilanka Ringwald #else 1010f12a3722SMilanka Ringwald avrcp_browsing_connection_t * btstack_memory_avrcp_browsing_connection_get(void){ 1011f12a3722SMilanka Ringwald return NULL; 1012f12a3722SMilanka Ringwald } 1013f12a3722SMilanka Ringwald void btstack_memory_avrcp_browsing_connection_free(avrcp_browsing_connection_t *avrcp_browsing_connection){ 1014b6269742SMatthias Ringwald UNUSED(avrcp_browsing_connection); 1015f12a3722SMilanka Ringwald }; 1016f12a3722SMilanka Ringwald #endif 1017f12a3722SMilanka Ringwald #elif defined(HAVE_MALLOC) 10182a95308bSMatthias Ringwald 10192a95308bSMatthias Ringwald typedef struct { 10202a95308bSMatthias Ringwald btstack_memory_buffer_t tracking; 1021798bd46fSMatthias Ringwald avrcp_browsing_connection_t data; 10222a95308bSMatthias Ringwald } btstack_memory_avrcp_browsing_connection_t; 10232a95308bSMatthias Ringwald 1024f12a3722SMilanka Ringwald avrcp_browsing_connection_t * btstack_memory_avrcp_browsing_connection_get(void){ 10252a95308bSMatthias Ringwald btstack_memory_avrcp_browsing_connection_t * buffer = (btstack_memory_avrcp_browsing_connection_t *) malloc(sizeof(btstack_memory_avrcp_browsing_connection_t)); 1026a2673d88SMatthias Ringwald if (buffer){ 1027798bd46fSMatthias Ringwald memset(buffer, 0, sizeof(btstack_memory_avrcp_browsing_connection_t)); 10282a95308bSMatthias Ringwald btstack_memory_tracking_add(&buffer->tracking); 10292a95308bSMatthias Ringwald return &buffer->data; 1030b6269742SMatthias Ringwald } else { 1031b6269742SMatthias Ringwald return NULL; 1032a2673d88SMatthias Ringwald } 1033f12a3722SMilanka Ringwald } 1034f12a3722SMilanka Ringwald void btstack_memory_avrcp_browsing_connection_free(avrcp_browsing_connection_t *avrcp_browsing_connection){ 1035798bd46fSMatthias Ringwald // reconstruct buffer start 1036798bd46fSMatthias Ringwald btstack_memory_buffer_t * buffer = &((btstack_memory_buffer_t *) avrcp_browsing_connection)[-1]; 1037798bd46fSMatthias Ringwald btstack_memory_tracking_remove(buffer); 1038b6269742SMatthias Ringwald free(buffer); 1039f12a3722SMilanka Ringwald } 1040f12a3722SMilanka Ringwald #endif 1041f12a3722SMilanka Ringwald 1042f12a3722SMilanka Ringwald 104344c5d856SMatthias Ringwald #endif 1044a9a4c409SMatthias Ringwald #ifdef ENABLE_BLE 10452e97c149S[email protected] 1046174a0c1cSMilanka Ringwald // MARK: battery_service_client_t 1047174a0c1cSMilanka Ringwald #if !defined(HAVE_MALLOC) && !defined(MAX_NR_BATTERY_SERVICE_CLIENTS) 1048174a0c1cSMilanka Ringwald #if defined(MAX_NO_BATTERY_SERVICE_CLIENTS) 1049174a0c1cSMilanka 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." 1050174a0c1cSMilanka Ringwald #else 1051174a0c1cSMilanka Ringwald #define MAX_NR_BATTERY_SERVICE_CLIENTS 0 1052174a0c1cSMilanka Ringwald #endif 1053174a0c1cSMilanka Ringwald #endif 1054174a0c1cSMilanka Ringwald 1055174a0c1cSMilanka Ringwald #ifdef MAX_NR_BATTERY_SERVICE_CLIENTS 1056174a0c1cSMilanka Ringwald #if MAX_NR_BATTERY_SERVICE_CLIENTS > 0 1057174a0c1cSMilanka Ringwald static battery_service_client_t battery_service_client_storage[MAX_NR_BATTERY_SERVICE_CLIENTS]; 1058174a0c1cSMilanka Ringwald static btstack_memory_pool_t battery_service_client_pool; 1059174a0c1cSMilanka Ringwald battery_service_client_t * btstack_memory_battery_service_client_get(void){ 1060174a0c1cSMilanka Ringwald void * buffer = btstack_memory_pool_get(&battery_service_client_pool); 1061174a0c1cSMilanka Ringwald if (buffer){ 1062174a0c1cSMilanka Ringwald memset(buffer, 0, sizeof(battery_service_client_t)); 1063174a0c1cSMilanka Ringwald } 1064174a0c1cSMilanka Ringwald return (battery_service_client_t *) buffer; 1065174a0c1cSMilanka Ringwald } 1066174a0c1cSMilanka Ringwald void btstack_memory_battery_service_client_free(battery_service_client_t *battery_service_client){ 1067174a0c1cSMilanka Ringwald btstack_memory_pool_free(&battery_service_client_pool, battery_service_client); 1068174a0c1cSMilanka Ringwald } 1069174a0c1cSMilanka Ringwald #else 1070174a0c1cSMilanka Ringwald battery_service_client_t * btstack_memory_battery_service_client_get(void){ 1071174a0c1cSMilanka Ringwald return NULL; 1072174a0c1cSMilanka Ringwald } 1073174a0c1cSMilanka Ringwald void btstack_memory_battery_service_client_free(battery_service_client_t *battery_service_client){ 1074174a0c1cSMilanka Ringwald UNUSED(battery_service_client); 1075174a0c1cSMilanka Ringwald }; 1076174a0c1cSMilanka Ringwald #endif 1077174a0c1cSMilanka Ringwald #elif defined(HAVE_MALLOC) 1078174a0c1cSMilanka Ringwald 1079174a0c1cSMilanka Ringwald typedef struct { 1080174a0c1cSMilanka Ringwald btstack_memory_buffer_t tracking; 1081174a0c1cSMilanka Ringwald battery_service_client_t data; 1082174a0c1cSMilanka Ringwald } btstack_memory_battery_service_client_t; 1083174a0c1cSMilanka Ringwald 1084174a0c1cSMilanka Ringwald battery_service_client_t * btstack_memory_battery_service_client_get(void){ 1085174a0c1cSMilanka Ringwald btstack_memory_battery_service_client_t * buffer = (btstack_memory_battery_service_client_t *) malloc(sizeof(btstack_memory_battery_service_client_t)); 1086174a0c1cSMilanka Ringwald if (buffer){ 1087174a0c1cSMilanka Ringwald memset(buffer, 0, sizeof(btstack_memory_battery_service_client_t)); 1088174a0c1cSMilanka Ringwald btstack_memory_tracking_add(&buffer->tracking); 1089174a0c1cSMilanka Ringwald return &buffer->data; 1090174a0c1cSMilanka Ringwald } else { 1091174a0c1cSMilanka Ringwald return NULL; 1092174a0c1cSMilanka Ringwald } 1093174a0c1cSMilanka Ringwald } 1094174a0c1cSMilanka Ringwald void btstack_memory_battery_service_client_free(battery_service_client_t *battery_service_client){ 1095174a0c1cSMilanka Ringwald // reconstruct buffer start 1096174a0c1cSMilanka Ringwald btstack_memory_buffer_t * buffer = &((btstack_memory_buffer_t *) battery_service_client)[-1]; 1097174a0c1cSMilanka Ringwald btstack_memory_tracking_remove(buffer); 1098174a0c1cSMilanka Ringwald free(buffer); 1099174a0c1cSMilanka Ringwald } 1100174a0c1cSMilanka Ringwald #endif 1101174a0c1cSMilanka Ringwald 1102174a0c1cSMilanka Ringwald 11032e97c149S[email protected] // MARK: gatt_client_t 1104a265b909SMatthias Ringwald #if !defined(HAVE_MALLOC) && !defined(MAX_NR_GATT_CLIENTS) 1105a265b909SMatthias Ringwald #if defined(MAX_NO_GATT_CLIENTS) 110627faf85aSMilanka 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." 1107a265b909SMatthias Ringwald #else 1108a265b909SMatthias Ringwald #define MAX_NR_GATT_CLIENTS 0 1109a265b909SMatthias Ringwald #endif 1110a265b909SMatthias Ringwald #endif 1111a265b909SMatthias Ringwald 1112a265b909SMatthias Ringwald #ifdef MAX_NR_GATT_CLIENTS 1113a265b909SMatthias Ringwald #if MAX_NR_GATT_CLIENTS > 0 1114a265b909SMatthias Ringwald static gatt_client_t gatt_client_storage[MAX_NR_GATT_CLIENTS]; 111529d0c4f7SMatthias Ringwald static btstack_memory_pool_t gatt_client_pool; 1116d0fdae3cS[email protected] gatt_client_t * btstack_memory_gatt_client_get(void){ 1117a2673d88SMatthias Ringwald void * buffer = btstack_memory_pool_get(&gatt_client_pool); 1118a2673d88SMatthias Ringwald if (buffer){ 1119a2673d88SMatthias Ringwald memset(buffer, 0, sizeof(gatt_client_t)); 1120a2673d88SMatthias Ringwald } 1121a2673d88SMatthias Ringwald return (gatt_client_t *) buffer; 1122d0fdae3cS[email protected] } 1123d0fdae3cS[email protected] void btstack_memory_gatt_client_free(gatt_client_t *gatt_client){ 112429d0c4f7SMatthias Ringwald btstack_memory_pool_free(&gatt_client_pool, gatt_client); 1125d0fdae3cS[email protected] } 1126d0fdae3cS[email protected] #else 1127d0fdae3cS[email protected] gatt_client_t * btstack_memory_gatt_client_get(void){ 1128d0fdae3cS[email protected] return NULL; 1129d0fdae3cS[email protected] } 1130d0fdae3cS[email protected] void btstack_memory_gatt_client_free(gatt_client_t *gatt_client){ 1131b6269742SMatthias Ringwald UNUSED(gatt_client); 1132d0fdae3cS[email protected] }; 1133d0fdae3cS[email protected] #endif 1134d0fdae3cS[email protected] #elif defined(HAVE_MALLOC) 11352a95308bSMatthias Ringwald 11362a95308bSMatthias Ringwald typedef struct { 11372a95308bSMatthias Ringwald btstack_memory_buffer_t tracking; 1138798bd46fSMatthias Ringwald gatt_client_t data; 11392a95308bSMatthias Ringwald } btstack_memory_gatt_client_t; 11402a95308bSMatthias Ringwald 1141d0fdae3cS[email protected] gatt_client_t * btstack_memory_gatt_client_get(void){ 11422a95308bSMatthias Ringwald btstack_memory_gatt_client_t * buffer = (btstack_memory_gatt_client_t *) malloc(sizeof(btstack_memory_gatt_client_t)); 1143a2673d88SMatthias Ringwald if (buffer){ 1144798bd46fSMatthias Ringwald memset(buffer, 0, sizeof(btstack_memory_gatt_client_t)); 11452a95308bSMatthias Ringwald btstack_memory_tracking_add(&buffer->tracking); 11462a95308bSMatthias Ringwald return &buffer->data; 1147b6269742SMatthias Ringwald } else { 1148b6269742SMatthias Ringwald return NULL; 1149a2673d88SMatthias Ringwald } 1150d0fdae3cS[email protected] } 1151d0fdae3cS[email protected] void btstack_memory_gatt_client_free(gatt_client_t *gatt_client){ 1152798bd46fSMatthias Ringwald // reconstruct buffer start 1153798bd46fSMatthias Ringwald btstack_memory_buffer_t * buffer = &((btstack_memory_buffer_t *) gatt_client)[-1]; 1154798bd46fSMatthias Ringwald btstack_memory_tracking_remove(buffer); 1155b6269742SMatthias Ringwald free(buffer); 1156d0fdae3cS[email protected] } 1157d0fdae3cS[email protected] #endif 11582e97c149S[email protected] 11592e97c149S[email protected] 1160cf26c8fbSMilanka Ringwald // MARK: hids_client_t 1161cf26c8fbSMilanka Ringwald #if !defined(HAVE_MALLOC) && !defined(MAX_NR_HIDS_CLIENTS) 1162cf26c8fbSMilanka Ringwald #if defined(MAX_NO_HIDS_CLIENTS) 1163cf26c8fbSMilanka 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." 1164cf26c8fbSMilanka Ringwald #else 1165cf26c8fbSMilanka Ringwald #define MAX_NR_HIDS_CLIENTS 0 1166cf26c8fbSMilanka Ringwald #endif 1167cf26c8fbSMilanka Ringwald #endif 1168cf26c8fbSMilanka Ringwald 1169cf26c8fbSMilanka Ringwald #ifdef MAX_NR_HIDS_CLIENTS 1170cf26c8fbSMilanka Ringwald #if MAX_NR_HIDS_CLIENTS > 0 1171cf26c8fbSMilanka Ringwald static hids_client_t hids_client_storage[MAX_NR_HIDS_CLIENTS]; 1172cf26c8fbSMilanka Ringwald static btstack_memory_pool_t hids_client_pool; 1173cf26c8fbSMilanka Ringwald hids_client_t * btstack_memory_hids_client_get(void){ 1174cf26c8fbSMilanka Ringwald void * buffer = btstack_memory_pool_get(&hids_client_pool); 1175cf26c8fbSMilanka Ringwald if (buffer){ 1176cf26c8fbSMilanka Ringwald memset(buffer, 0, sizeof(hids_client_t)); 1177cf26c8fbSMilanka Ringwald } 1178cf26c8fbSMilanka Ringwald return (hids_client_t *) buffer; 1179cf26c8fbSMilanka Ringwald } 1180cf26c8fbSMilanka Ringwald void btstack_memory_hids_client_free(hids_client_t *hids_client){ 1181cf26c8fbSMilanka Ringwald btstack_memory_pool_free(&hids_client_pool, hids_client); 1182cf26c8fbSMilanka Ringwald } 1183cf26c8fbSMilanka Ringwald #else 1184cf26c8fbSMilanka Ringwald hids_client_t * btstack_memory_hids_client_get(void){ 1185cf26c8fbSMilanka Ringwald return NULL; 1186cf26c8fbSMilanka Ringwald } 1187cf26c8fbSMilanka Ringwald void btstack_memory_hids_client_free(hids_client_t *hids_client){ 1188cf26c8fbSMilanka Ringwald UNUSED(hids_client); 1189cf26c8fbSMilanka Ringwald }; 1190cf26c8fbSMilanka Ringwald #endif 1191cf26c8fbSMilanka Ringwald #elif defined(HAVE_MALLOC) 1192cf26c8fbSMilanka Ringwald 1193cf26c8fbSMilanka Ringwald typedef struct { 1194cf26c8fbSMilanka Ringwald btstack_memory_buffer_t tracking; 1195cf26c8fbSMilanka Ringwald hids_client_t data; 1196cf26c8fbSMilanka Ringwald } btstack_memory_hids_client_t; 1197cf26c8fbSMilanka Ringwald 1198cf26c8fbSMilanka Ringwald hids_client_t * btstack_memory_hids_client_get(void){ 1199cf26c8fbSMilanka Ringwald btstack_memory_hids_client_t * buffer = (btstack_memory_hids_client_t *) malloc(sizeof(btstack_memory_hids_client_t)); 1200cf26c8fbSMilanka Ringwald if (buffer){ 1201cf26c8fbSMilanka Ringwald memset(buffer, 0, sizeof(btstack_memory_hids_client_t)); 1202cf26c8fbSMilanka Ringwald btstack_memory_tracking_add(&buffer->tracking); 1203cf26c8fbSMilanka Ringwald return &buffer->data; 1204cf26c8fbSMilanka Ringwald } else { 1205cf26c8fbSMilanka Ringwald return NULL; 1206cf26c8fbSMilanka Ringwald } 1207cf26c8fbSMilanka Ringwald } 1208cf26c8fbSMilanka Ringwald void btstack_memory_hids_client_free(hids_client_t *hids_client){ 1209cf26c8fbSMilanka Ringwald // reconstruct buffer start 1210cf26c8fbSMilanka Ringwald btstack_memory_buffer_t * buffer = &((btstack_memory_buffer_t *) hids_client)[-1]; 1211cf26c8fbSMilanka Ringwald btstack_memory_tracking_remove(buffer); 1212cf26c8fbSMilanka Ringwald free(buffer); 1213cf26c8fbSMilanka Ringwald } 1214cf26c8fbSMilanka Ringwald #endif 1215cf26c8fbSMilanka Ringwald 1216cf26c8fbSMilanka Ringwald 1217cf26c8fbSMilanka Ringwald // MARK: scan_parameters_service_client_t 1218cf26c8fbSMilanka Ringwald #if !defined(HAVE_MALLOC) && !defined(MAX_NR_SCAN_PARAMETERS_SERVICE_CLIENTS) 1219cf26c8fbSMilanka Ringwald #if defined(MAX_NO_SCAN_PARAMETERS_SERVICE_CLIENTS) 1220cf26c8fbSMilanka 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." 1221cf26c8fbSMilanka Ringwald #else 1222cf26c8fbSMilanka Ringwald #define MAX_NR_SCAN_PARAMETERS_SERVICE_CLIENTS 0 1223cf26c8fbSMilanka Ringwald #endif 1224cf26c8fbSMilanka Ringwald #endif 1225cf26c8fbSMilanka Ringwald 1226cf26c8fbSMilanka Ringwald #ifdef MAX_NR_SCAN_PARAMETERS_SERVICE_CLIENTS 1227cf26c8fbSMilanka Ringwald #if MAX_NR_SCAN_PARAMETERS_SERVICE_CLIENTS > 0 1228cf26c8fbSMilanka Ringwald static scan_parameters_service_client_t scan_parameters_service_client_storage[MAX_NR_SCAN_PARAMETERS_SERVICE_CLIENTS]; 1229cf26c8fbSMilanka Ringwald static btstack_memory_pool_t scan_parameters_service_client_pool; 1230cf26c8fbSMilanka Ringwald scan_parameters_service_client_t * btstack_memory_scan_parameters_service_client_get(void){ 1231cf26c8fbSMilanka Ringwald void * buffer = btstack_memory_pool_get(&scan_parameters_service_client_pool); 1232cf26c8fbSMilanka Ringwald if (buffer){ 1233cf26c8fbSMilanka Ringwald memset(buffer, 0, sizeof(scan_parameters_service_client_t)); 1234cf26c8fbSMilanka Ringwald } 1235cf26c8fbSMilanka Ringwald return (scan_parameters_service_client_t *) buffer; 1236cf26c8fbSMilanka Ringwald } 1237cf26c8fbSMilanka Ringwald void btstack_memory_scan_parameters_service_client_free(scan_parameters_service_client_t *scan_parameters_service_client){ 1238cf26c8fbSMilanka Ringwald btstack_memory_pool_free(&scan_parameters_service_client_pool, scan_parameters_service_client); 1239cf26c8fbSMilanka Ringwald } 1240cf26c8fbSMilanka Ringwald #else 1241cf26c8fbSMilanka Ringwald scan_parameters_service_client_t * btstack_memory_scan_parameters_service_client_get(void){ 1242cf26c8fbSMilanka Ringwald return NULL; 1243cf26c8fbSMilanka Ringwald } 1244cf26c8fbSMilanka Ringwald void btstack_memory_scan_parameters_service_client_free(scan_parameters_service_client_t *scan_parameters_service_client){ 1245cf26c8fbSMilanka Ringwald UNUSED(scan_parameters_service_client); 1246cf26c8fbSMilanka Ringwald }; 1247cf26c8fbSMilanka Ringwald #endif 1248cf26c8fbSMilanka Ringwald #elif defined(HAVE_MALLOC) 1249cf26c8fbSMilanka Ringwald 1250cf26c8fbSMilanka Ringwald typedef struct { 1251cf26c8fbSMilanka Ringwald btstack_memory_buffer_t tracking; 1252cf26c8fbSMilanka Ringwald scan_parameters_service_client_t data; 1253cf26c8fbSMilanka Ringwald } btstack_memory_scan_parameters_service_client_t; 1254cf26c8fbSMilanka Ringwald 1255cf26c8fbSMilanka Ringwald scan_parameters_service_client_t * btstack_memory_scan_parameters_service_client_get(void){ 1256cf26c8fbSMilanka 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)); 1257cf26c8fbSMilanka Ringwald if (buffer){ 1258cf26c8fbSMilanka Ringwald memset(buffer, 0, sizeof(btstack_memory_scan_parameters_service_client_t)); 1259cf26c8fbSMilanka Ringwald btstack_memory_tracking_add(&buffer->tracking); 1260cf26c8fbSMilanka Ringwald return &buffer->data; 1261cf26c8fbSMilanka Ringwald } else { 1262cf26c8fbSMilanka Ringwald return NULL; 1263cf26c8fbSMilanka Ringwald } 1264cf26c8fbSMilanka Ringwald } 1265cf26c8fbSMilanka Ringwald void btstack_memory_scan_parameters_service_client_free(scan_parameters_service_client_t *scan_parameters_service_client){ 1266cf26c8fbSMilanka Ringwald // reconstruct buffer start 1267cf26c8fbSMilanka Ringwald btstack_memory_buffer_t * buffer = &((btstack_memory_buffer_t *) scan_parameters_service_client)[-1]; 1268cf26c8fbSMilanka Ringwald btstack_memory_tracking_remove(buffer); 1269cf26c8fbSMilanka Ringwald free(buffer); 1270cf26c8fbSMilanka Ringwald } 1271cf26c8fbSMilanka Ringwald #endif 1272cf26c8fbSMilanka Ringwald 1273cf26c8fbSMilanka Ringwald 1274cf49570bSMatthias Ringwald // MARK: sm_lookup_entry_t 1275a265b909SMatthias Ringwald #if !defined(HAVE_MALLOC) && !defined(MAX_NR_SM_LOOKUP_ENTRIES) 1276a265b909SMatthias Ringwald #if defined(MAX_NO_SM_LOOKUP_ENTRIES) 127727faf85aSMilanka 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." 1278a265b909SMatthias Ringwald #else 1279a265b909SMatthias Ringwald #define MAX_NR_SM_LOOKUP_ENTRIES 0 1280a265b909SMatthias Ringwald #endif 1281a265b909SMatthias Ringwald #endif 1282a265b909SMatthias Ringwald 1283a265b909SMatthias Ringwald #ifdef MAX_NR_SM_LOOKUP_ENTRIES 1284a265b909SMatthias Ringwald #if MAX_NR_SM_LOOKUP_ENTRIES > 0 1285a265b909SMatthias Ringwald static sm_lookup_entry_t sm_lookup_entry_storage[MAX_NR_SM_LOOKUP_ENTRIES]; 128629d0c4f7SMatthias Ringwald static btstack_memory_pool_t sm_lookup_entry_pool; 1287cf49570bSMatthias Ringwald sm_lookup_entry_t * btstack_memory_sm_lookup_entry_get(void){ 1288a2673d88SMatthias Ringwald void * buffer = btstack_memory_pool_get(&sm_lookup_entry_pool); 1289a2673d88SMatthias Ringwald if (buffer){ 1290a2673d88SMatthias Ringwald memset(buffer, 0, sizeof(sm_lookup_entry_t)); 1291a2673d88SMatthias Ringwald } 1292a2673d88SMatthias Ringwald return (sm_lookup_entry_t *) buffer; 1293cf49570bSMatthias Ringwald } 1294cf49570bSMatthias Ringwald void btstack_memory_sm_lookup_entry_free(sm_lookup_entry_t *sm_lookup_entry){ 129529d0c4f7SMatthias Ringwald btstack_memory_pool_free(&sm_lookup_entry_pool, sm_lookup_entry); 1296cf49570bSMatthias Ringwald } 1297cf49570bSMatthias Ringwald #else 1298cf49570bSMatthias Ringwald sm_lookup_entry_t * btstack_memory_sm_lookup_entry_get(void){ 1299cf49570bSMatthias Ringwald return NULL; 1300cf49570bSMatthias Ringwald } 1301cf49570bSMatthias Ringwald void btstack_memory_sm_lookup_entry_free(sm_lookup_entry_t *sm_lookup_entry){ 1302b6269742SMatthias Ringwald UNUSED(sm_lookup_entry); 1303cf49570bSMatthias Ringwald }; 1304cf49570bSMatthias Ringwald #endif 1305cf49570bSMatthias Ringwald #elif defined(HAVE_MALLOC) 13062a95308bSMatthias Ringwald 13072a95308bSMatthias Ringwald typedef struct { 13082a95308bSMatthias Ringwald btstack_memory_buffer_t tracking; 1309798bd46fSMatthias Ringwald sm_lookup_entry_t data; 13102a95308bSMatthias Ringwald } btstack_memory_sm_lookup_entry_t; 13112a95308bSMatthias Ringwald 1312cf49570bSMatthias Ringwald sm_lookup_entry_t * btstack_memory_sm_lookup_entry_get(void){ 13132a95308bSMatthias Ringwald btstack_memory_sm_lookup_entry_t * buffer = (btstack_memory_sm_lookup_entry_t *) malloc(sizeof(btstack_memory_sm_lookup_entry_t)); 1314a2673d88SMatthias Ringwald if (buffer){ 1315798bd46fSMatthias Ringwald memset(buffer, 0, sizeof(btstack_memory_sm_lookup_entry_t)); 13162a95308bSMatthias Ringwald btstack_memory_tracking_add(&buffer->tracking); 13172a95308bSMatthias Ringwald return &buffer->data; 1318b6269742SMatthias Ringwald } else { 1319b6269742SMatthias Ringwald return NULL; 1320a2673d88SMatthias Ringwald } 1321cf49570bSMatthias Ringwald } 1322cf49570bSMatthias Ringwald void btstack_memory_sm_lookup_entry_free(sm_lookup_entry_t *sm_lookup_entry){ 1323798bd46fSMatthias Ringwald // reconstruct buffer start 1324798bd46fSMatthias Ringwald btstack_memory_buffer_t * buffer = &((btstack_memory_buffer_t *) sm_lookup_entry)[-1]; 1325798bd46fSMatthias Ringwald btstack_memory_tracking_remove(buffer); 1326b6269742SMatthias Ringwald free(buffer); 1327cf49570bSMatthias Ringwald } 1328cf49570bSMatthias Ringwald #endif 1329cf49570bSMatthias Ringwald 1330cf49570bSMatthias Ringwald 1331174a0c1cSMilanka Ringwald // MARK: whitelist_entry_t 1332174a0c1cSMilanka Ringwald #if !defined(HAVE_MALLOC) && !defined(MAX_NR_WHITELIST_ENTRIES) 1333174a0c1cSMilanka Ringwald #if defined(MAX_NO_WHITELIST_ENTRIES) 1334174a0c1cSMilanka 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." 1335174a0c1cSMilanka Ringwald #else 1336174a0c1cSMilanka Ringwald #define MAX_NR_WHITELIST_ENTRIES 0 1337174a0c1cSMilanka Ringwald #endif 1338174a0c1cSMilanka Ringwald #endif 1339174a0c1cSMilanka Ringwald 1340174a0c1cSMilanka Ringwald #ifdef MAX_NR_WHITELIST_ENTRIES 1341174a0c1cSMilanka Ringwald #if MAX_NR_WHITELIST_ENTRIES > 0 1342174a0c1cSMilanka Ringwald static whitelist_entry_t whitelist_entry_storage[MAX_NR_WHITELIST_ENTRIES]; 1343174a0c1cSMilanka Ringwald static btstack_memory_pool_t whitelist_entry_pool; 1344174a0c1cSMilanka Ringwald whitelist_entry_t * btstack_memory_whitelist_entry_get(void){ 1345174a0c1cSMilanka Ringwald void * buffer = btstack_memory_pool_get(&whitelist_entry_pool); 1346174a0c1cSMilanka Ringwald if (buffer){ 1347174a0c1cSMilanka Ringwald memset(buffer, 0, sizeof(whitelist_entry_t)); 1348174a0c1cSMilanka Ringwald } 1349174a0c1cSMilanka Ringwald return (whitelist_entry_t *) buffer; 1350174a0c1cSMilanka Ringwald } 1351174a0c1cSMilanka Ringwald void btstack_memory_whitelist_entry_free(whitelist_entry_t *whitelist_entry){ 1352174a0c1cSMilanka Ringwald btstack_memory_pool_free(&whitelist_entry_pool, whitelist_entry); 1353174a0c1cSMilanka Ringwald } 1354174a0c1cSMilanka Ringwald #else 1355174a0c1cSMilanka Ringwald whitelist_entry_t * btstack_memory_whitelist_entry_get(void){ 1356174a0c1cSMilanka Ringwald return NULL; 1357174a0c1cSMilanka Ringwald } 1358174a0c1cSMilanka Ringwald void btstack_memory_whitelist_entry_free(whitelist_entry_t *whitelist_entry){ 1359174a0c1cSMilanka Ringwald UNUSED(whitelist_entry); 1360174a0c1cSMilanka Ringwald }; 1361174a0c1cSMilanka Ringwald #endif 1362174a0c1cSMilanka Ringwald #elif defined(HAVE_MALLOC) 1363174a0c1cSMilanka Ringwald 1364174a0c1cSMilanka Ringwald typedef struct { 1365174a0c1cSMilanka Ringwald btstack_memory_buffer_t tracking; 1366174a0c1cSMilanka Ringwald whitelist_entry_t data; 1367174a0c1cSMilanka Ringwald } btstack_memory_whitelist_entry_t; 1368174a0c1cSMilanka Ringwald 1369174a0c1cSMilanka Ringwald whitelist_entry_t * btstack_memory_whitelist_entry_get(void){ 1370174a0c1cSMilanka Ringwald btstack_memory_whitelist_entry_t * buffer = (btstack_memory_whitelist_entry_t *) malloc(sizeof(btstack_memory_whitelist_entry_t)); 1371174a0c1cSMilanka Ringwald if (buffer){ 1372174a0c1cSMilanka Ringwald memset(buffer, 0, sizeof(btstack_memory_whitelist_entry_t)); 1373174a0c1cSMilanka Ringwald btstack_memory_tracking_add(&buffer->tracking); 1374174a0c1cSMilanka Ringwald return &buffer->data; 1375174a0c1cSMilanka Ringwald } else { 1376174a0c1cSMilanka Ringwald return NULL; 1377174a0c1cSMilanka Ringwald } 1378174a0c1cSMilanka Ringwald } 1379174a0c1cSMilanka Ringwald void btstack_memory_whitelist_entry_free(whitelist_entry_t *whitelist_entry){ 1380174a0c1cSMilanka Ringwald // reconstruct buffer start 1381174a0c1cSMilanka Ringwald btstack_memory_buffer_t * buffer = &((btstack_memory_buffer_t *) whitelist_entry)[-1]; 1382174a0c1cSMilanka Ringwald btstack_memory_tracking_remove(buffer); 1383174a0c1cSMilanka Ringwald free(buffer); 1384174a0c1cSMilanka Ringwald } 1385174a0c1cSMilanka Ringwald #endif 1386174a0c1cSMilanka Ringwald 1387174a0c1cSMilanka Ringwald 138844c5d856SMatthias Ringwald #endif 138944c5d856SMatthias Ringwald #ifdef ENABLE_MESH 1390ebb73e1fSMatthias Ringwald 1391ebb73e1fSMatthias Ringwald // MARK: mesh_network_pdu_t 1392ebb73e1fSMatthias Ringwald #if !defined(HAVE_MALLOC) && !defined(MAX_NR_MESH_NETWORK_PDUS) 1393ebb73e1fSMatthias Ringwald #if defined(MAX_NO_MESH_NETWORK_PDUS) 1394ebb73e1fSMatthias 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." 1395ebb73e1fSMatthias Ringwald #else 1396ebb73e1fSMatthias Ringwald #define MAX_NR_MESH_NETWORK_PDUS 0 1397ebb73e1fSMatthias Ringwald #endif 1398ebb73e1fSMatthias Ringwald #endif 1399ebb73e1fSMatthias Ringwald 1400ebb73e1fSMatthias Ringwald #ifdef MAX_NR_MESH_NETWORK_PDUS 1401ebb73e1fSMatthias Ringwald #if MAX_NR_MESH_NETWORK_PDUS > 0 1402ebb73e1fSMatthias Ringwald static mesh_network_pdu_t mesh_network_pdu_storage[MAX_NR_MESH_NETWORK_PDUS]; 1403ebb73e1fSMatthias Ringwald static btstack_memory_pool_t mesh_network_pdu_pool; 1404ebb73e1fSMatthias Ringwald mesh_network_pdu_t * btstack_memory_mesh_network_pdu_get(void){ 14051c4e8084SMatthias Ringwald void * buffer = btstack_memory_pool_get(&mesh_network_pdu_pool); 14061c4e8084SMatthias Ringwald if (buffer){ 14071c4e8084SMatthias Ringwald memset(buffer, 0, sizeof(mesh_network_pdu_t)); 14081c4e8084SMatthias Ringwald } 14091c4e8084SMatthias Ringwald return (mesh_network_pdu_t *) buffer; 1410ebb73e1fSMatthias Ringwald } 1411ebb73e1fSMatthias Ringwald void btstack_memory_mesh_network_pdu_free(mesh_network_pdu_t *mesh_network_pdu){ 1412ebb73e1fSMatthias Ringwald btstack_memory_pool_free(&mesh_network_pdu_pool, mesh_network_pdu); 1413ebb73e1fSMatthias Ringwald } 1414ebb73e1fSMatthias Ringwald #else 1415ebb73e1fSMatthias Ringwald mesh_network_pdu_t * btstack_memory_mesh_network_pdu_get(void){ 1416ebb73e1fSMatthias Ringwald return NULL; 1417ebb73e1fSMatthias Ringwald } 1418ebb73e1fSMatthias Ringwald void btstack_memory_mesh_network_pdu_free(mesh_network_pdu_t *mesh_network_pdu){ 1419b6269742SMatthias Ringwald UNUSED(mesh_network_pdu); 1420ebb73e1fSMatthias Ringwald }; 1421ebb73e1fSMatthias Ringwald #endif 1422ebb73e1fSMatthias Ringwald #elif defined(HAVE_MALLOC) 14232a95308bSMatthias Ringwald 14242a95308bSMatthias Ringwald typedef struct { 14252a95308bSMatthias Ringwald btstack_memory_buffer_t tracking; 1426798bd46fSMatthias Ringwald mesh_network_pdu_t data; 14272a95308bSMatthias Ringwald } btstack_memory_mesh_network_pdu_t; 14282a95308bSMatthias Ringwald 1429ebb73e1fSMatthias Ringwald mesh_network_pdu_t * btstack_memory_mesh_network_pdu_get(void){ 14302a95308bSMatthias Ringwald btstack_memory_mesh_network_pdu_t * buffer = (btstack_memory_mesh_network_pdu_t *) malloc(sizeof(btstack_memory_mesh_network_pdu_t)); 14311c4e8084SMatthias Ringwald if (buffer){ 1432798bd46fSMatthias Ringwald memset(buffer, 0, sizeof(btstack_memory_mesh_network_pdu_t)); 14332a95308bSMatthias Ringwald btstack_memory_tracking_add(&buffer->tracking); 14342a95308bSMatthias Ringwald return &buffer->data; 1435b6269742SMatthias Ringwald } else { 1436b6269742SMatthias Ringwald return NULL; 14371c4e8084SMatthias Ringwald } 1438ebb73e1fSMatthias Ringwald } 1439ebb73e1fSMatthias Ringwald void btstack_memory_mesh_network_pdu_free(mesh_network_pdu_t *mesh_network_pdu){ 1440798bd46fSMatthias Ringwald // reconstruct buffer start 1441798bd46fSMatthias Ringwald btstack_memory_buffer_t * buffer = &((btstack_memory_buffer_t *) mesh_network_pdu)[-1]; 1442798bd46fSMatthias Ringwald btstack_memory_tracking_remove(buffer); 1443b6269742SMatthias Ringwald free(buffer); 1444ebb73e1fSMatthias Ringwald } 1445ebb73e1fSMatthias Ringwald #endif 1446ebb73e1fSMatthias Ringwald 1447ebb73e1fSMatthias Ringwald 1448a4bbc09dSMatthias Ringwald // MARK: mesh_segmented_pdu_t 1449a4bbc09dSMatthias Ringwald #if !defined(HAVE_MALLOC) && !defined(MAX_NR_MESH_SEGMENTED_PDUS) 1450a4bbc09dSMatthias Ringwald #if defined(MAX_NO_MESH_SEGMENTED_PDUS) 1451a4bbc09dSMatthias 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." 1452f7434c1fSMatthias Ringwald #else 1453a4bbc09dSMatthias Ringwald #define MAX_NR_MESH_SEGMENTED_PDUS 0 1454f7434c1fSMatthias Ringwald #endif 1455f7434c1fSMatthias Ringwald #endif 1456f7434c1fSMatthias Ringwald 1457a4bbc09dSMatthias Ringwald #ifdef MAX_NR_MESH_SEGMENTED_PDUS 1458a4bbc09dSMatthias Ringwald #if MAX_NR_MESH_SEGMENTED_PDUS > 0 1459a4bbc09dSMatthias Ringwald static mesh_segmented_pdu_t mesh_segmented_pdu_storage[MAX_NR_MESH_SEGMENTED_PDUS]; 1460a4bbc09dSMatthias Ringwald static btstack_memory_pool_t mesh_segmented_pdu_pool; 1461a4bbc09dSMatthias Ringwald mesh_segmented_pdu_t * btstack_memory_mesh_segmented_pdu_get(void){ 1462a4bbc09dSMatthias Ringwald void * buffer = btstack_memory_pool_get(&mesh_segmented_pdu_pool); 1463f7434c1fSMatthias Ringwald if (buffer){ 1464a4bbc09dSMatthias Ringwald memset(buffer, 0, sizeof(mesh_segmented_pdu_t)); 1465f7434c1fSMatthias Ringwald } 1466a4bbc09dSMatthias Ringwald return (mesh_segmented_pdu_t *) buffer; 1467f7434c1fSMatthias Ringwald } 1468a4bbc09dSMatthias Ringwald void btstack_memory_mesh_segmented_pdu_free(mesh_segmented_pdu_t *mesh_segmented_pdu){ 1469a4bbc09dSMatthias Ringwald btstack_memory_pool_free(&mesh_segmented_pdu_pool, mesh_segmented_pdu); 1470f7434c1fSMatthias Ringwald } 1471f7434c1fSMatthias Ringwald #else 1472a4bbc09dSMatthias Ringwald mesh_segmented_pdu_t * btstack_memory_mesh_segmented_pdu_get(void){ 1473f7434c1fSMatthias Ringwald return NULL; 1474f7434c1fSMatthias Ringwald } 1475a4bbc09dSMatthias Ringwald void btstack_memory_mesh_segmented_pdu_free(mesh_segmented_pdu_t *mesh_segmented_pdu){ 1476b6269742SMatthias Ringwald UNUSED(mesh_segmented_pdu); 1477f7434c1fSMatthias Ringwald }; 1478f7434c1fSMatthias Ringwald #endif 1479f7434c1fSMatthias Ringwald #elif defined(HAVE_MALLOC) 14802a95308bSMatthias Ringwald 14812a95308bSMatthias Ringwald typedef struct { 14822a95308bSMatthias Ringwald btstack_memory_buffer_t tracking; 1483798bd46fSMatthias Ringwald mesh_segmented_pdu_t data; 14842a95308bSMatthias Ringwald } btstack_memory_mesh_segmented_pdu_t; 14852a95308bSMatthias Ringwald 1486a4bbc09dSMatthias Ringwald mesh_segmented_pdu_t * btstack_memory_mesh_segmented_pdu_get(void){ 14872a95308bSMatthias Ringwald btstack_memory_mesh_segmented_pdu_t * buffer = (btstack_memory_mesh_segmented_pdu_t *) malloc(sizeof(btstack_memory_mesh_segmented_pdu_t)); 1488f7434c1fSMatthias Ringwald if (buffer){ 1489798bd46fSMatthias Ringwald memset(buffer, 0, sizeof(btstack_memory_mesh_segmented_pdu_t)); 14902a95308bSMatthias Ringwald btstack_memory_tracking_add(&buffer->tracking); 14912a95308bSMatthias Ringwald return &buffer->data; 1492b6269742SMatthias Ringwald } else { 1493b6269742SMatthias Ringwald return NULL; 1494f7434c1fSMatthias Ringwald } 1495f7434c1fSMatthias Ringwald } 1496a4bbc09dSMatthias Ringwald void btstack_memory_mesh_segmented_pdu_free(mesh_segmented_pdu_t *mesh_segmented_pdu){ 1497798bd46fSMatthias Ringwald // reconstruct buffer start 1498798bd46fSMatthias Ringwald btstack_memory_buffer_t * buffer = &((btstack_memory_buffer_t *) mesh_segmented_pdu)[-1]; 1499798bd46fSMatthias Ringwald btstack_memory_tracking_remove(buffer); 1500b6269742SMatthias Ringwald free(buffer); 1501f7434c1fSMatthias Ringwald } 1502f7434c1fSMatthias Ringwald #endif 1503f7434c1fSMatthias Ringwald 1504f7434c1fSMatthias Ringwald 1505491f99b3SMatthias Ringwald // MARK: mesh_upper_transport_pdu_t 1506491f99b3SMatthias Ringwald #if !defined(HAVE_MALLOC) && !defined(MAX_NR_MESH_UPPER_TRANSPORT_PDUS) 1507491f99b3SMatthias Ringwald #if defined(MAX_NO_MESH_UPPER_TRANSPORT_PDUS) 1508491f99b3SMatthias 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." 1509491f99b3SMatthias Ringwald #else 1510491f99b3SMatthias Ringwald #define MAX_NR_MESH_UPPER_TRANSPORT_PDUS 0 1511491f99b3SMatthias Ringwald #endif 1512491f99b3SMatthias Ringwald #endif 1513491f99b3SMatthias Ringwald 1514491f99b3SMatthias Ringwald #ifdef MAX_NR_MESH_UPPER_TRANSPORT_PDUS 1515491f99b3SMatthias Ringwald #if MAX_NR_MESH_UPPER_TRANSPORT_PDUS > 0 1516491f99b3SMatthias Ringwald static mesh_upper_transport_pdu_t mesh_upper_transport_pdu_storage[MAX_NR_MESH_UPPER_TRANSPORT_PDUS]; 1517491f99b3SMatthias Ringwald static btstack_memory_pool_t mesh_upper_transport_pdu_pool; 1518491f99b3SMatthias Ringwald mesh_upper_transport_pdu_t * btstack_memory_mesh_upper_transport_pdu_get(void){ 1519491f99b3SMatthias Ringwald void * buffer = btstack_memory_pool_get(&mesh_upper_transport_pdu_pool); 1520491f99b3SMatthias Ringwald if (buffer){ 1521491f99b3SMatthias Ringwald memset(buffer, 0, sizeof(mesh_upper_transport_pdu_t)); 1522491f99b3SMatthias Ringwald } 1523491f99b3SMatthias Ringwald return (mesh_upper_transport_pdu_t *) buffer; 1524491f99b3SMatthias Ringwald } 1525491f99b3SMatthias Ringwald void btstack_memory_mesh_upper_transport_pdu_free(mesh_upper_transport_pdu_t *mesh_upper_transport_pdu){ 1526491f99b3SMatthias Ringwald btstack_memory_pool_free(&mesh_upper_transport_pdu_pool, mesh_upper_transport_pdu); 1527491f99b3SMatthias Ringwald } 1528491f99b3SMatthias Ringwald #else 1529491f99b3SMatthias Ringwald mesh_upper_transport_pdu_t * btstack_memory_mesh_upper_transport_pdu_get(void){ 1530491f99b3SMatthias Ringwald return NULL; 1531491f99b3SMatthias Ringwald } 1532491f99b3SMatthias Ringwald void btstack_memory_mesh_upper_transport_pdu_free(mesh_upper_transport_pdu_t *mesh_upper_transport_pdu){ 1533b6269742SMatthias Ringwald UNUSED(mesh_upper_transport_pdu); 1534491f99b3SMatthias Ringwald }; 1535491f99b3SMatthias Ringwald #endif 1536491f99b3SMatthias Ringwald #elif defined(HAVE_MALLOC) 15372a95308bSMatthias Ringwald 15382a95308bSMatthias Ringwald typedef struct { 15392a95308bSMatthias Ringwald btstack_memory_buffer_t tracking; 1540798bd46fSMatthias Ringwald mesh_upper_transport_pdu_t data; 15412a95308bSMatthias Ringwald } btstack_memory_mesh_upper_transport_pdu_t; 15422a95308bSMatthias Ringwald 1543491f99b3SMatthias Ringwald mesh_upper_transport_pdu_t * btstack_memory_mesh_upper_transport_pdu_get(void){ 15442a95308bSMatthias 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)); 1545491f99b3SMatthias Ringwald if (buffer){ 1546798bd46fSMatthias Ringwald memset(buffer, 0, sizeof(btstack_memory_mesh_upper_transport_pdu_t)); 15472a95308bSMatthias Ringwald btstack_memory_tracking_add(&buffer->tracking); 15482a95308bSMatthias Ringwald return &buffer->data; 1549b6269742SMatthias Ringwald } else { 1550b6269742SMatthias Ringwald return NULL; 1551491f99b3SMatthias Ringwald } 1552491f99b3SMatthias Ringwald } 1553491f99b3SMatthias Ringwald void btstack_memory_mesh_upper_transport_pdu_free(mesh_upper_transport_pdu_t *mesh_upper_transport_pdu){ 1554798bd46fSMatthias Ringwald // reconstruct buffer start 1555798bd46fSMatthias Ringwald btstack_memory_buffer_t * buffer = &((btstack_memory_buffer_t *) mesh_upper_transport_pdu)[-1]; 1556798bd46fSMatthias Ringwald btstack_memory_tracking_remove(buffer); 1557b6269742SMatthias Ringwald free(buffer); 1558491f99b3SMatthias Ringwald } 1559491f99b3SMatthias Ringwald #endif 1560491f99b3SMatthias Ringwald 1561491f99b3SMatthias Ringwald 1562c0a711d9SMatthias Ringwald // MARK: mesh_network_key_t 1563c0a711d9SMatthias Ringwald #if !defined(HAVE_MALLOC) && !defined(MAX_NR_MESH_NETWORK_KEYS) 1564c0a711d9SMatthias Ringwald #if defined(MAX_NO_MESH_NETWORK_KEYS) 1565c0a711d9SMatthias 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." 1566c0a711d9SMatthias Ringwald #else 1567c0a711d9SMatthias Ringwald #define MAX_NR_MESH_NETWORK_KEYS 0 1568c0a711d9SMatthias Ringwald #endif 1569c0a711d9SMatthias Ringwald #endif 1570c0a711d9SMatthias Ringwald 1571c0a711d9SMatthias Ringwald #ifdef MAX_NR_MESH_NETWORK_KEYS 1572c0a711d9SMatthias Ringwald #if MAX_NR_MESH_NETWORK_KEYS > 0 1573c0a711d9SMatthias Ringwald static mesh_network_key_t mesh_network_key_storage[MAX_NR_MESH_NETWORK_KEYS]; 1574c0a711d9SMatthias Ringwald static btstack_memory_pool_t mesh_network_key_pool; 1575c0a711d9SMatthias Ringwald mesh_network_key_t * btstack_memory_mesh_network_key_get(void){ 15761c4e8084SMatthias Ringwald void * buffer = btstack_memory_pool_get(&mesh_network_key_pool); 15771c4e8084SMatthias Ringwald if (buffer){ 15781c4e8084SMatthias Ringwald memset(buffer, 0, sizeof(mesh_network_key_t)); 15791c4e8084SMatthias Ringwald } 15801c4e8084SMatthias Ringwald return (mesh_network_key_t *) buffer; 1581c0a711d9SMatthias Ringwald } 1582c0a711d9SMatthias Ringwald void btstack_memory_mesh_network_key_free(mesh_network_key_t *mesh_network_key){ 1583c0a711d9SMatthias Ringwald btstack_memory_pool_free(&mesh_network_key_pool, mesh_network_key); 1584c0a711d9SMatthias Ringwald } 1585c0a711d9SMatthias Ringwald #else 1586c0a711d9SMatthias Ringwald mesh_network_key_t * btstack_memory_mesh_network_key_get(void){ 1587c0a711d9SMatthias Ringwald return NULL; 1588c0a711d9SMatthias Ringwald } 1589c0a711d9SMatthias Ringwald void btstack_memory_mesh_network_key_free(mesh_network_key_t *mesh_network_key){ 1590b6269742SMatthias Ringwald UNUSED(mesh_network_key); 1591c0a711d9SMatthias Ringwald }; 1592c0a711d9SMatthias Ringwald #endif 1593c0a711d9SMatthias Ringwald #elif defined(HAVE_MALLOC) 15942a95308bSMatthias Ringwald 15952a95308bSMatthias Ringwald typedef struct { 15962a95308bSMatthias Ringwald btstack_memory_buffer_t tracking; 1597798bd46fSMatthias Ringwald mesh_network_key_t data; 15982a95308bSMatthias Ringwald } btstack_memory_mesh_network_key_t; 15992a95308bSMatthias Ringwald 1600c0a711d9SMatthias Ringwald mesh_network_key_t * btstack_memory_mesh_network_key_get(void){ 16012a95308bSMatthias Ringwald btstack_memory_mesh_network_key_t * buffer = (btstack_memory_mesh_network_key_t *) malloc(sizeof(btstack_memory_mesh_network_key_t)); 16021c4e8084SMatthias Ringwald if (buffer){ 1603798bd46fSMatthias Ringwald memset(buffer, 0, sizeof(btstack_memory_mesh_network_key_t)); 16042a95308bSMatthias Ringwald btstack_memory_tracking_add(&buffer->tracking); 16052a95308bSMatthias Ringwald return &buffer->data; 1606b6269742SMatthias Ringwald } else { 1607b6269742SMatthias Ringwald return NULL; 16081c4e8084SMatthias Ringwald } 1609c0a711d9SMatthias Ringwald } 1610c0a711d9SMatthias Ringwald void btstack_memory_mesh_network_key_free(mesh_network_key_t *mesh_network_key){ 1611798bd46fSMatthias Ringwald // reconstruct buffer start 1612798bd46fSMatthias Ringwald btstack_memory_buffer_t * buffer = &((btstack_memory_buffer_t *) mesh_network_key)[-1]; 1613798bd46fSMatthias Ringwald btstack_memory_tracking_remove(buffer); 1614b6269742SMatthias Ringwald free(buffer); 1615c0a711d9SMatthias Ringwald } 1616c0a711d9SMatthias Ringwald #endif 1617c0a711d9SMatthias Ringwald 1618c0a711d9SMatthias Ringwald 161901e2bf94SMatthias Ringwald // MARK: mesh_transport_key_t 162001e2bf94SMatthias Ringwald #if !defined(HAVE_MALLOC) && !defined(MAX_NR_MESH_TRANSPORT_KEYS) 162101e2bf94SMatthias Ringwald #if defined(MAX_NO_MESH_TRANSPORT_KEYS) 162201e2bf94SMatthias 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." 162301e2bf94SMatthias Ringwald #else 162401e2bf94SMatthias Ringwald #define MAX_NR_MESH_TRANSPORT_KEYS 0 162501e2bf94SMatthias Ringwald #endif 162601e2bf94SMatthias Ringwald #endif 162701e2bf94SMatthias Ringwald 162801e2bf94SMatthias Ringwald #ifdef MAX_NR_MESH_TRANSPORT_KEYS 162901e2bf94SMatthias Ringwald #if MAX_NR_MESH_TRANSPORT_KEYS > 0 163001e2bf94SMatthias Ringwald static mesh_transport_key_t mesh_transport_key_storage[MAX_NR_MESH_TRANSPORT_KEYS]; 163101e2bf94SMatthias Ringwald static btstack_memory_pool_t mesh_transport_key_pool; 163201e2bf94SMatthias Ringwald mesh_transport_key_t * btstack_memory_mesh_transport_key_get(void){ 163301e2bf94SMatthias Ringwald void * buffer = btstack_memory_pool_get(&mesh_transport_key_pool); 163401e2bf94SMatthias Ringwald if (buffer){ 163501e2bf94SMatthias Ringwald memset(buffer, 0, sizeof(mesh_transport_key_t)); 163601e2bf94SMatthias Ringwald } 163701e2bf94SMatthias Ringwald return (mesh_transport_key_t *) buffer; 163801e2bf94SMatthias Ringwald } 163901e2bf94SMatthias Ringwald void btstack_memory_mesh_transport_key_free(mesh_transport_key_t *mesh_transport_key){ 164001e2bf94SMatthias Ringwald btstack_memory_pool_free(&mesh_transport_key_pool, mesh_transport_key); 164101e2bf94SMatthias Ringwald } 164201e2bf94SMatthias Ringwald #else 164301e2bf94SMatthias Ringwald mesh_transport_key_t * btstack_memory_mesh_transport_key_get(void){ 164401e2bf94SMatthias Ringwald return NULL; 164501e2bf94SMatthias Ringwald } 164601e2bf94SMatthias Ringwald void btstack_memory_mesh_transport_key_free(mesh_transport_key_t *mesh_transport_key){ 1647b6269742SMatthias Ringwald UNUSED(mesh_transport_key); 164801e2bf94SMatthias Ringwald }; 164901e2bf94SMatthias Ringwald #endif 165001e2bf94SMatthias Ringwald #elif defined(HAVE_MALLOC) 16512a95308bSMatthias Ringwald 16522a95308bSMatthias Ringwald typedef struct { 16532a95308bSMatthias Ringwald btstack_memory_buffer_t tracking; 1654798bd46fSMatthias Ringwald mesh_transport_key_t data; 16552a95308bSMatthias Ringwald } btstack_memory_mesh_transport_key_t; 16562a95308bSMatthias Ringwald 165701e2bf94SMatthias Ringwald mesh_transport_key_t * btstack_memory_mesh_transport_key_get(void){ 16582a95308bSMatthias Ringwald btstack_memory_mesh_transport_key_t * buffer = (btstack_memory_mesh_transport_key_t *) malloc(sizeof(btstack_memory_mesh_transport_key_t)); 165901e2bf94SMatthias Ringwald if (buffer){ 1660798bd46fSMatthias Ringwald memset(buffer, 0, sizeof(btstack_memory_mesh_transport_key_t)); 16612a95308bSMatthias Ringwald btstack_memory_tracking_add(&buffer->tracking); 16622a95308bSMatthias Ringwald return &buffer->data; 1663b6269742SMatthias Ringwald } else { 1664b6269742SMatthias Ringwald return NULL; 166501e2bf94SMatthias Ringwald } 166601e2bf94SMatthias Ringwald } 166701e2bf94SMatthias Ringwald void btstack_memory_mesh_transport_key_free(mesh_transport_key_t *mesh_transport_key){ 1668798bd46fSMatthias Ringwald // reconstruct buffer start 1669798bd46fSMatthias Ringwald btstack_memory_buffer_t * buffer = &((btstack_memory_buffer_t *) mesh_transport_key)[-1]; 1670798bd46fSMatthias Ringwald btstack_memory_tracking_remove(buffer); 1671b6269742SMatthias Ringwald free(buffer); 167201e2bf94SMatthias Ringwald } 167301e2bf94SMatthias Ringwald #endif 167401e2bf94SMatthias Ringwald 167501e2bf94SMatthias Ringwald 16761f45d603SMatthias Ringwald // MARK: mesh_virtual_address_t 16771f45d603SMatthias Ringwald #if !defined(HAVE_MALLOC) && !defined(MAX_NR_MESH_VIRTUAL_ADDRESSS) 16781f45d603SMatthias Ringwald #if defined(MAX_NO_MESH_VIRTUAL_ADDRESSS) 16791f45d603SMatthias 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." 16801f45d603SMatthias Ringwald #else 16811f45d603SMatthias Ringwald #define MAX_NR_MESH_VIRTUAL_ADDRESSS 0 16821f45d603SMatthias Ringwald #endif 16831f45d603SMatthias Ringwald #endif 16841f45d603SMatthias Ringwald 16851f45d603SMatthias Ringwald #ifdef MAX_NR_MESH_VIRTUAL_ADDRESSS 16861f45d603SMatthias Ringwald #if MAX_NR_MESH_VIRTUAL_ADDRESSS > 0 16871f45d603SMatthias Ringwald static mesh_virtual_address_t mesh_virtual_address_storage[MAX_NR_MESH_VIRTUAL_ADDRESSS]; 16881f45d603SMatthias Ringwald static btstack_memory_pool_t mesh_virtual_address_pool; 16891f45d603SMatthias Ringwald mesh_virtual_address_t * btstack_memory_mesh_virtual_address_get(void){ 16901f45d603SMatthias Ringwald void * buffer = btstack_memory_pool_get(&mesh_virtual_address_pool); 16911f45d603SMatthias Ringwald if (buffer){ 16921f45d603SMatthias Ringwald memset(buffer, 0, sizeof(mesh_virtual_address_t)); 16931f45d603SMatthias Ringwald } 16941f45d603SMatthias Ringwald return (mesh_virtual_address_t *) buffer; 16951f45d603SMatthias Ringwald } 16961f45d603SMatthias Ringwald void btstack_memory_mesh_virtual_address_free(mesh_virtual_address_t *mesh_virtual_address){ 16971f45d603SMatthias Ringwald btstack_memory_pool_free(&mesh_virtual_address_pool, mesh_virtual_address); 16981f45d603SMatthias Ringwald } 16991f45d603SMatthias Ringwald #else 17001f45d603SMatthias Ringwald mesh_virtual_address_t * btstack_memory_mesh_virtual_address_get(void){ 17011f45d603SMatthias Ringwald return NULL; 17021f45d603SMatthias Ringwald } 17031f45d603SMatthias Ringwald void btstack_memory_mesh_virtual_address_free(mesh_virtual_address_t *mesh_virtual_address){ 1704b6269742SMatthias Ringwald UNUSED(mesh_virtual_address); 17051f45d603SMatthias Ringwald }; 17061f45d603SMatthias Ringwald #endif 17071f45d603SMatthias Ringwald #elif defined(HAVE_MALLOC) 17082a95308bSMatthias Ringwald 17092a95308bSMatthias Ringwald typedef struct { 17102a95308bSMatthias Ringwald btstack_memory_buffer_t tracking; 1711798bd46fSMatthias Ringwald mesh_virtual_address_t data; 17122a95308bSMatthias Ringwald } btstack_memory_mesh_virtual_address_t; 17132a95308bSMatthias Ringwald 17141f45d603SMatthias Ringwald mesh_virtual_address_t * btstack_memory_mesh_virtual_address_get(void){ 17152a95308bSMatthias Ringwald btstack_memory_mesh_virtual_address_t * buffer = (btstack_memory_mesh_virtual_address_t *) malloc(sizeof(btstack_memory_mesh_virtual_address_t)); 17161f45d603SMatthias Ringwald if (buffer){ 1717798bd46fSMatthias Ringwald memset(buffer, 0, sizeof(btstack_memory_mesh_virtual_address_t)); 17182a95308bSMatthias Ringwald btstack_memory_tracking_add(&buffer->tracking); 17192a95308bSMatthias Ringwald return &buffer->data; 1720b6269742SMatthias Ringwald } else { 1721b6269742SMatthias Ringwald return NULL; 17221f45d603SMatthias Ringwald } 17231f45d603SMatthias Ringwald } 17241f45d603SMatthias Ringwald void btstack_memory_mesh_virtual_address_free(mesh_virtual_address_t *mesh_virtual_address){ 1725798bd46fSMatthias Ringwald // reconstruct buffer start 1726798bd46fSMatthias Ringwald btstack_memory_buffer_t * buffer = &((btstack_memory_buffer_t *) mesh_virtual_address)[-1]; 1727798bd46fSMatthias Ringwald btstack_memory_tracking_remove(buffer); 1728b6269742SMatthias Ringwald free(buffer); 17291f45d603SMatthias Ringwald } 17301f45d603SMatthias Ringwald #endif 17311f45d603SMatthias Ringwald 17321f45d603SMatthias Ringwald 173301122b73SMatthias Ringwald // MARK: mesh_subnet_t 173401122b73SMatthias Ringwald #if !defined(HAVE_MALLOC) && !defined(MAX_NR_MESH_SUBNETS) 173501122b73SMatthias Ringwald #if defined(MAX_NO_MESH_SUBNETS) 173601122b73SMatthias 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." 173701122b73SMatthias Ringwald #else 173801122b73SMatthias Ringwald #define MAX_NR_MESH_SUBNETS 0 173901122b73SMatthias Ringwald #endif 174001122b73SMatthias Ringwald #endif 174101122b73SMatthias Ringwald 174201122b73SMatthias Ringwald #ifdef MAX_NR_MESH_SUBNETS 174301122b73SMatthias Ringwald #if MAX_NR_MESH_SUBNETS > 0 174401122b73SMatthias Ringwald static mesh_subnet_t mesh_subnet_storage[MAX_NR_MESH_SUBNETS]; 174501122b73SMatthias Ringwald static btstack_memory_pool_t mesh_subnet_pool; 174601122b73SMatthias Ringwald mesh_subnet_t * btstack_memory_mesh_subnet_get(void){ 174701122b73SMatthias Ringwald void * buffer = btstack_memory_pool_get(&mesh_subnet_pool); 174801122b73SMatthias Ringwald if (buffer){ 174901122b73SMatthias Ringwald memset(buffer, 0, sizeof(mesh_subnet_t)); 175001122b73SMatthias Ringwald } 175101122b73SMatthias Ringwald return (mesh_subnet_t *) buffer; 175201122b73SMatthias Ringwald } 175301122b73SMatthias Ringwald void btstack_memory_mesh_subnet_free(mesh_subnet_t *mesh_subnet){ 175401122b73SMatthias Ringwald btstack_memory_pool_free(&mesh_subnet_pool, mesh_subnet); 175501122b73SMatthias Ringwald } 175601122b73SMatthias Ringwald #else 175701122b73SMatthias Ringwald mesh_subnet_t * btstack_memory_mesh_subnet_get(void){ 175801122b73SMatthias Ringwald return NULL; 175901122b73SMatthias Ringwald } 176001122b73SMatthias Ringwald void btstack_memory_mesh_subnet_free(mesh_subnet_t *mesh_subnet){ 1761b6269742SMatthias Ringwald UNUSED(mesh_subnet); 176201122b73SMatthias Ringwald }; 176301122b73SMatthias Ringwald #endif 176401122b73SMatthias Ringwald #elif defined(HAVE_MALLOC) 17652a95308bSMatthias Ringwald 17662a95308bSMatthias Ringwald typedef struct { 17672a95308bSMatthias Ringwald btstack_memory_buffer_t tracking; 1768798bd46fSMatthias Ringwald mesh_subnet_t data; 17692a95308bSMatthias Ringwald } btstack_memory_mesh_subnet_t; 17702a95308bSMatthias Ringwald 177101122b73SMatthias Ringwald mesh_subnet_t * btstack_memory_mesh_subnet_get(void){ 17722a95308bSMatthias Ringwald btstack_memory_mesh_subnet_t * buffer = (btstack_memory_mesh_subnet_t *) malloc(sizeof(btstack_memory_mesh_subnet_t)); 177301122b73SMatthias Ringwald if (buffer){ 1774798bd46fSMatthias Ringwald memset(buffer, 0, sizeof(btstack_memory_mesh_subnet_t)); 17752a95308bSMatthias Ringwald btstack_memory_tracking_add(&buffer->tracking); 17762a95308bSMatthias Ringwald return &buffer->data; 1777b6269742SMatthias Ringwald } else { 1778b6269742SMatthias Ringwald return NULL; 177901122b73SMatthias Ringwald } 178001122b73SMatthias Ringwald } 178101122b73SMatthias Ringwald void btstack_memory_mesh_subnet_free(mesh_subnet_t *mesh_subnet){ 1782798bd46fSMatthias Ringwald // reconstruct buffer start 1783798bd46fSMatthias Ringwald btstack_memory_buffer_t * buffer = &((btstack_memory_buffer_t *) mesh_subnet)[-1]; 1784798bd46fSMatthias Ringwald btstack_memory_tracking_remove(buffer); 1785b6269742SMatthias Ringwald free(buffer); 178601122b73SMatthias Ringwald } 178701122b73SMatthias Ringwald #endif 178801122b73SMatthias Ringwald 178901122b73SMatthias Ringwald 17902e97c149S[email protected] #endif 1791798bd46fSMatthias Ringwald 1792a3b02b71Smatthias.ringwald // init 1793a3b02b71Smatthias.ringwald void btstack_memory_init(void){ 1794798bd46fSMatthias Ringwald #ifdef HAVE_MALLOC 1795798bd46fSMatthias Ringwald // assert that there is no unexpected padding for combined buffer 1796798bd46fSMatthias Ringwald btstack_assert(sizeof(test_buffer_t) == sizeof(btstack_memory_buffer_t) + sizeof(void *)); 1797798bd46fSMatthias Ringwald #endif 1798798bd46fSMatthias Ringwald 1799a265b909SMatthias Ringwald #if MAX_NR_HCI_CONNECTIONS > 0 1800a265b909SMatthias Ringwald btstack_memory_pool_create(&hci_connection_pool, hci_connection_storage, MAX_NR_HCI_CONNECTIONS, sizeof(hci_connection_t)); 1801a3b02b71Smatthias.ringwald #endif 1802a265b909SMatthias Ringwald #if MAX_NR_L2CAP_SERVICES > 0 1803a265b909SMatthias Ringwald btstack_memory_pool_create(&l2cap_service_pool, l2cap_service_storage, MAX_NR_L2CAP_SERVICES, sizeof(l2cap_service_t)); 1804a3b02b71Smatthias.ringwald #endif 1805a265b909SMatthias Ringwald #if MAX_NR_L2CAP_CHANNELS > 0 1806a265b909SMatthias Ringwald btstack_memory_pool_create(&l2cap_channel_pool, l2cap_channel_storage, MAX_NR_L2CAP_CHANNELS, sizeof(l2cap_channel_t)); 1807a3b02b71Smatthias.ringwald #endif 180844c5d856SMatthias Ringwald #ifdef ENABLE_CLASSIC 180950dc57fcSMatthias Ringwald #if MAX_NR_RFCOMM_MULTIPLEXERS > 0 181050dc57fcSMatthias Ringwald btstack_memory_pool_create(&rfcomm_multiplexer_pool, rfcomm_multiplexer_storage, MAX_NR_RFCOMM_MULTIPLEXERS, sizeof(rfcomm_multiplexer_t)); 1811a3b02b71Smatthias.ringwald #endif 181250dc57fcSMatthias Ringwald #if MAX_NR_RFCOMM_SERVICES > 0 181350dc57fcSMatthias Ringwald btstack_memory_pool_create(&rfcomm_service_pool, rfcomm_service_storage, MAX_NR_RFCOMM_SERVICES, sizeof(rfcomm_service_t)); 1814a3b02b71Smatthias.ringwald #endif 181550dc57fcSMatthias Ringwald #if MAX_NR_RFCOMM_CHANNELS > 0 181650dc57fcSMatthias Ringwald btstack_memory_pool_create(&rfcomm_channel_pool, rfcomm_channel_storage, MAX_NR_RFCOMM_CHANNELS, sizeof(rfcomm_channel_t)); 181750dc57fcSMatthias Ringwald #endif 181850dc57fcSMatthias Ringwald #if MAX_NR_BTSTACK_LINK_KEY_DB_MEMORY_ENTRIES > 0 181950dc57fcSMatthias 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)); 182050dc57fcSMatthias Ringwald #endif 182150dc57fcSMatthias Ringwald #if MAX_NR_BNEP_SERVICES > 0 182250dc57fcSMatthias Ringwald btstack_memory_pool_create(&bnep_service_pool, bnep_service_storage, MAX_NR_BNEP_SERVICES, sizeof(bnep_service_t)); 182350dc57fcSMatthias Ringwald #endif 182450dc57fcSMatthias Ringwald #if MAX_NR_BNEP_CHANNELS > 0 182550dc57fcSMatthias Ringwald btstack_memory_pool_create(&bnep_channel_pool, bnep_channel_storage, MAX_NR_BNEP_CHANNELS, sizeof(bnep_channel_t)); 182650dc57fcSMatthias Ringwald #endif 182750dc57fcSMatthias Ringwald #if MAX_NR_HFP_CONNECTIONS > 0 182850dc57fcSMatthias Ringwald btstack_memory_pool_create(&hfp_connection_pool, hfp_connection_storage, MAX_NR_HFP_CONNECTIONS, sizeof(hfp_connection_t)); 182950dc57fcSMatthias Ringwald #endif 1830f399f7fbSMilanka Ringwald #if MAX_NR_HID_HOST_CONNECTIONS > 0 1831f399f7fbSMilanka Ringwald btstack_memory_pool_create(&hid_host_connection_pool, hid_host_connection_storage, MAX_NR_HID_HOST_CONNECTIONS, sizeof(hid_host_connection_t)); 1832f399f7fbSMilanka Ringwald #endif 183350dc57fcSMatthias Ringwald #if MAX_NR_SERVICE_RECORD_ITEMS > 0 183450dc57fcSMatthias Ringwald btstack_memory_pool_create(&service_record_item_pool, service_record_item_storage, MAX_NR_SERVICE_RECORD_ITEMS, sizeof(service_record_item_t)); 183550dc57fcSMatthias Ringwald #endif 183650dc57fcSMatthias Ringwald #if MAX_NR_AVDTP_STREAM_ENDPOINTS > 0 183750dc57fcSMatthias Ringwald btstack_memory_pool_create(&avdtp_stream_endpoint_pool, avdtp_stream_endpoint_storage, MAX_NR_AVDTP_STREAM_ENDPOINTS, sizeof(avdtp_stream_endpoint_t)); 183850dc57fcSMatthias Ringwald #endif 183950dc57fcSMatthias Ringwald #if MAX_NR_AVDTP_CONNECTIONS > 0 184050dc57fcSMatthias Ringwald btstack_memory_pool_create(&avdtp_connection_pool, avdtp_connection_storage, MAX_NR_AVDTP_CONNECTIONS, sizeof(avdtp_connection_t)); 184150dc57fcSMatthias Ringwald #endif 184250dc57fcSMatthias Ringwald #if MAX_NR_AVRCP_CONNECTIONS > 0 184350dc57fcSMatthias Ringwald btstack_memory_pool_create(&avrcp_connection_pool, avrcp_connection_storage, MAX_NR_AVRCP_CONNECTIONS, sizeof(avrcp_connection_t)); 184450dc57fcSMatthias Ringwald #endif 184550dc57fcSMatthias Ringwald #if MAX_NR_AVRCP_BROWSING_CONNECTIONS > 0 184650dc57fcSMatthias Ringwald btstack_memory_pool_create(&avrcp_browsing_connection_pool, avrcp_browsing_connection_storage, MAX_NR_AVRCP_BROWSING_CONNECTIONS, sizeof(avrcp_browsing_connection_t)); 1847a3b02b71Smatthias.ringwald #endif 1848f12a3722SMilanka Ringwald #endif 1849a9a4c409SMatthias Ringwald #ifdef ENABLE_BLE 1850174a0c1cSMilanka Ringwald #if MAX_NR_BATTERY_SERVICE_CLIENTS > 0 1851174a0c1cSMilanka Ringwald btstack_memory_pool_create(&battery_service_client_pool, battery_service_client_storage, MAX_NR_BATTERY_SERVICE_CLIENTS, sizeof(battery_service_client_t)); 1852174a0c1cSMilanka Ringwald #endif 1853a265b909SMatthias Ringwald #if MAX_NR_GATT_CLIENTS > 0 1854a265b909SMatthias Ringwald btstack_memory_pool_create(&gatt_client_pool, gatt_client_storage, MAX_NR_GATT_CLIENTS, sizeof(gatt_client_t)); 1855d0fdae3cS[email protected] #endif 1856cf26c8fbSMilanka Ringwald #if MAX_NR_HIDS_CLIENTS > 0 1857cf26c8fbSMilanka Ringwald btstack_memory_pool_create(&hids_client_pool, hids_client_storage, MAX_NR_HIDS_CLIENTS, sizeof(hids_client_t)); 1858cf26c8fbSMilanka Ringwald #endif 1859cf26c8fbSMilanka Ringwald #if MAX_NR_SCAN_PARAMETERS_SERVICE_CLIENTS > 0 1860cf26c8fbSMilanka 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)); 1861cf26c8fbSMilanka Ringwald #endif 1862a265b909SMatthias Ringwald #if MAX_NR_SM_LOOKUP_ENTRIES > 0 1863a265b909SMatthias Ringwald btstack_memory_pool_create(&sm_lookup_entry_pool, sm_lookup_entry_storage, MAX_NR_SM_LOOKUP_ENTRIES, sizeof(sm_lookup_entry_t)); 1864cf49570bSMatthias Ringwald #endif 1865174a0c1cSMilanka Ringwald #if MAX_NR_WHITELIST_ENTRIES > 0 1866174a0c1cSMilanka Ringwald btstack_memory_pool_create(&whitelist_entry_pool, whitelist_entry_storage, MAX_NR_WHITELIST_ENTRIES, sizeof(whitelist_entry_t)); 1867174a0c1cSMilanka Ringwald #endif 1868ebb73e1fSMatthias Ringwald #endif 186944c5d856SMatthias Ringwald #ifdef ENABLE_MESH 187050dc57fcSMatthias Ringwald #if MAX_NR_MESH_NETWORK_PDUS > 0 187150dc57fcSMatthias Ringwald btstack_memory_pool_create(&mesh_network_pdu_pool, mesh_network_pdu_storage, MAX_NR_MESH_NETWORK_PDUS, sizeof(mesh_network_pdu_t)); 187244c5d856SMatthias Ringwald #endif 1873a4bbc09dSMatthias Ringwald #if MAX_NR_MESH_SEGMENTED_PDUS > 0 1874a4bbc09dSMatthias Ringwald btstack_memory_pool_create(&mesh_segmented_pdu_pool, mesh_segmented_pdu_storage, MAX_NR_MESH_SEGMENTED_PDUS, sizeof(mesh_segmented_pdu_t)); 1875f7434c1fSMatthias Ringwald #endif 1876491f99b3SMatthias Ringwald #if MAX_NR_MESH_UPPER_TRANSPORT_PDUS > 0 1877491f99b3SMatthias 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)); 1878491f99b3SMatthias Ringwald #endif 187950dc57fcSMatthias Ringwald #if MAX_NR_MESH_NETWORK_KEYS > 0 188050dc57fcSMatthias Ringwald btstack_memory_pool_create(&mesh_network_key_pool, mesh_network_key_storage, MAX_NR_MESH_NETWORK_KEYS, sizeof(mesh_network_key_t)); 1881c0a711d9SMatthias Ringwald #endif 188201e2bf94SMatthias Ringwald #if MAX_NR_MESH_TRANSPORT_KEYS > 0 188301e2bf94SMatthias Ringwald btstack_memory_pool_create(&mesh_transport_key_pool, mesh_transport_key_storage, MAX_NR_MESH_TRANSPORT_KEYS, sizeof(mesh_transport_key_t)); 188401e2bf94SMatthias Ringwald #endif 18851f45d603SMatthias Ringwald #if MAX_NR_MESH_VIRTUAL_ADDRESSS > 0 18861f45d603SMatthias Ringwald btstack_memory_pool_create(&mesh_virtual_address_pool, mesh_virtual_address_storage, MAX_NR_MESH_VIRTUAL_ADDRESSS, sizeof(mesh_virtual_address_t)); 18871f45d603SMatthias Ringwald #endif 188801122b73SMatthias Ringwald #if MAX_NR_MESH_SUBNETS > 0 188901122b73SMatthias Ringwald btstack_memory_pool_create(&mesh_subnet_pool, mesh_subnet_storage, MAX_NR_MESH_SUBNETS, sizeof(mesh_subnet_t)); 189001122b73SMatthias Ringwald #endif 1891a7d12effS[email protected] #endif 1892a3b02b71Smatthias.ringwald } 1893