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 23a3b02b71Smatthias.ringwald * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL MATTHIAS 24a3b02b71Smatthias.ringwald * RINGWALD 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 58b6269742SMatthias Ringwald #ifdef HAVE_MALLOC 59b6269742SMatthias Ringwald typedef struct btstack_memory_buffer { 60b6269742SMatthias Ringwald struct btstack_memory_buffer * next; 61b6269742SMatthias Ringwald struct btstack_memory_buffer * prev; 62b6269742SMatthias Ringwald } btstack_memory_buffer_t; 63b6269742SMatthias Ringwald 64b6269742SMatthias Ringwald static btstack_memory_buffer_t * btstack_memory_malloc_buffers; 65*19ef97d2SMatthias Ringwald static uint32_t btstack_memory_malloc_counter; 66b6269742SMatthias Ringwald 672a95308bSMatthias Ringwald static void btstack_memory_tracking_add(btstack_memory_buffer_t * buffer){ 682a95308bSMatthias Ringwald btstack_assert(buffer != NULL); 69*19ef97d2SMatthias Ringwald if (btstack_memory_malloc_buffers != NULL) { 70*19ef97d2SMatthias Ringwald // let current first item prev point to new first item 71*19ef97d2SMatthias Ringwald btstack_memory_malloc_buffers->prev = buffer; 72*19ef97d2SMatthias Ringwald } 73b6269742SMatthias Ringwald buffer->prev = NULL; 74b6269742SMatthias Ringwald buffer->next = btstack_memory_malloc_buffers; 75b6269742SMatthias Ringwald btstack_memory_malloc_buffers = buffer; 76*19ef97d2SMatthias Ringwald 77*19ef97d2SMatthias Ringwald btstack_memory_malloc_counter++; 78b6269742SMatthias Ringwald } 79b6269742SMatthias Ringwald 802a95308bSMatthias Ringwald static void btstack_memory_tracking_remove(btstack_memory_buffer_t * buffer){ 812a95308bSMatthias Ringwald btstack_assert(buffer != NULL); 82b6269742SMatthias Ringwald if (buffer->prev == NULL){ 83b6269742SMatthias Ringwald // first item 84b6269742SMatthias Ringwald btstack_memory_malloc_buffers = buffer->next; 85b6269742SMatthias Ringwald } else { 86b6269742SMatthias Ringwald buffer->prev->next = buffer->next; 87b6269742SMatthias Ringwald } 88b6269742SMatthias Ringwald if (buffer->next != NULL){ 89b6269742SMatthias Ringwald buffer->next->prev = buffer->prev; 90b6269742SMatthias Ringwald } 91*19ef97d2SMatthias Ringwald 92*19ef97d2SMatthias Ringwald btstack_memory_malloc_counter--; 93b6269742SMatthias Ringwald } 94b6269742SMatthias Ringwald #endif 95b6269742SMatthias Ringwald 96b6269742SMatthias Ringwald void btstack_memory_deinit(void){ 97b6269742SMatthias Ringwald #ifdef HAVE_MALLOC 98b6269742SMatthias Ringwald while (btstack_memory_malloc_buffers != NULL){ 99b6269742SMatthias Ringwald btstack_memory_buffer_t * buffer = btstack_memory_malloc_buffers; 100b6269742SMatthias Ringwald btstack_memory_malloc_buffers = buffer->next; 101b6269742SMatthias Ringwald free(buffer); 102b6269742SMatthias Ringwald } 103*19ef97d2SMatthias Ringwald btstack_assert(btstack_memory_malloc_counter == 0); 104b6269742SMatthias Ringwald #endif 105b6269742SMatthias Ringwald } 106a3b02b71Smatthias.ringwald 1072e97c149S[email protected] 108a3b02b71Smatthias.ringwald // MARK: hci_connection_t 109a265b909SMatthias Ringwald #if !defined(HAVE_MALLOC) && !defined(MAX_NR_HCI_CONNECTIONS) 110a265b909SMatthias Ringwald #if defined(MAX_NO_HCI_CONNECTIONS) 11127faf85aSMilanka 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." 112a265b909SMatthias Ringwald #else 113a265b909SMatthias Ringwald #define MAX_NR_HCI_CONNECTIONS 0 114a265b909SMatthias Ringwald #endif 115a265b909SMatthias Ringwald #endif 116a265b909SMatthias Ringwald 117a265b909SMatthias Ringwald #ifdef MAX_NR_HCI_CONNECTIONS 118a265b909SMatthias Ringwald #if MAX_NR_HCI_CONNECTIONS > 0 119a265b909SMatthias Ringwald static hci_connection_t hci_connection_storage[MAX_NR_HCI_CONNECTIONS]; 12029d0c4f7SMatthias Ringwald static btstack_memory_pool_t hci_connection_pool; 1216527a633S[email protected] hci_connection_t * btstack_memory_hci_connection_get(void){ 122a2673d88SMatthias Ringwald void * buffer = btstack_memory_pool_get(&hci_connection_pool); 123a2673d88SMatthias Ringwald if (buffer){ 124a2673d88SMatthias Ringwald memset(buffer, 0, sizeof(hci_connection_t)); 125a2673d88SMatthias Ringwald } 126a2673d88SMatthias Ringwald return (hci_connection_t *) buffer; 127a3b02b71Smatthias.ringwald } 1286527a633S[email protected] void btstack_memory_hci_connection_free(hci_connection_t *hci_connection){ 12929d0c4f7SMatthias Ringwald btstack_memory_pool_free(&hci_connection_pool, hci_connection); 130a3b02b71Smatthias.ringwald } 131c4d3f927Smatthias.ringwald #else 1326527a633S[email protected] hci_connection_t * btstack_memory_hci_connection_get(void){ 133c4d3f927Smatthias.ringwald return NULL; 134c4d3f927Smatthias.ringwald } 1356527a633S[email protected] void btstack_memory_hci_connection_free(hci_connection_t *hci_connection){ 136b6269742SMatthias Ringwald UNUSED(hci_connection); 137c4d3f927Smatthias.ringwald }; 138c4d3f927Smatthias.ringwald #endif 139a3b02b71Smatthias.ringwald #elif defined(HAVE_MALLOC) 1402a95308bSMatthias Ringwald 1412a95308bSMatthias Ringwald typedef struct { 1422a95308bSMatthias Ringwald hci_connection_t data; 1432a95308bSMatthias Ringwald btstack_memory_buffer_t tracking; 1442a95308bSMatthias Ringwald } btstack_memory_hci_connection_t; 1452a95308bSMatthias Ringwald 1466527a633S[email protected] hci_connection_t * btstack_memory_hci_connection_get(void){ 1472a95308bSMatthias Ringwald btstack_memory_hci_connection_t * buffer = (btstack_memory_hci_connection_t *) malloc(sizeof(btstack_memory_hci_connection_t)); 148a2673d88SMatthias Ringwald if (buffer){ 1492a95308bSMatthias Ringwald memset(buffer, 0, sizeof(hci_connection_t)); 1502a95308bSMatthias Ringwald btstack_memory_tracking_add(&buffer->tracking); 1512a95308bSMatthias Ringwald return &buffer->data; 152b6269742SMatthias Ringwald } else { 153b6269742SMatthias Ringwald return NULL; 154a2673d88SMatthias Ringwald } 155a3b02b71Smatthias.ringwald } 1566527a633S[email protected] void btstack_memory_hci_connection_free(hci_connection_t *hci_connection){ 1572a95308bSMatthias Ringwald btstack_memory_hci_connection_t * buffer = (btstack_memory_hci_connection_t *) hci_connection; 1582a95308bSMatthias Ringwald btstack_memory_tracking_remove(&buffer->tracking); 159b6269742SMatthias Ringwald free(buffer); 160a3b02b71Smatthias.ringwald } 161a3b02b71Smatthias.ringwald #endif 162a3b02b71Smatthias.ringwald 163a3b02b71Smatthias.ringwald 1642e97c149S[email protected] 165a3b02b71Smatthias.ringwald // MARK: l2cap_service_t 166a265b909SMatthias Ringwald #if !defined(HAVE_MALLOC) && !defined(MAX_NR_L2CAP_SERVICES) 167a265b909SMatthias Ringwald #if defined(MAX_NO_L2CAP_SERVICES) 16827faf85aSMilanka 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." 169a265b909SMatthias Ringwald #else 170a265b909SMatthias Ringwald #define MAX_NR_L2CAP_SERVICES 0 171a265b909SMatthias Ringwald #endif 172a265b909SMatthias Ringwald #endif 173a265b909SMatthias Ringwald 174a265b909SMatthias Ringwald #ifdef MAX_NR_L2CAP_SERVICES 175a265b909SMatthias Ringwald #if MAX_NR_L2CAP_SERVICES > 0 176a265b909SMatthias Ringwald static l2cap_service_t l2cap_service_storage[MAX_NR_L2CAP_SERVICES]; 17729d0c4f7SMatthias Ringwald static btstack_memory_pool_t l2cap_service_pool; 1786527a633S[email protected] l2cap_service_t * btstack_memory_l2cap_service_get(void){ 179a2673d88SMatthias Ringwald void * buffer = btstack_memory_pool_get(&l2cap_service_pool); 180a2673d88SMatthias Ringwald if (buffer){ 181a2673d88SMatthias Ringwald memset(buffer, 0, sizeof(l2cap_service_t)); 182a2673d88SMatthias Ringwald } 183a2673d88SMatthias Ringwald return (l2cap_service_t *) buffer; 184a3b02b71Smatthias.ringwald } 1856527a633S[email protected] void btstack_memory_l2cap_service_free(l2cap_service_t *l2cap_service){ 18629d0c4f7SMatthias Ringwald btstack_memory_pool_free(&l2cap_service_pool, l2cap_service); 187a3b02b71Smatthias.ringwald } 188c4d3f927Smatthias.ringwald #else 1896527a633S[email protected] l2cap_service_t * btstack_memory_l2cap_service_get(void){ 190c4d3f927Smatthias.ringwald return NULL; 191c4d3f927Smatthias.ringwald } 1926527a633S[email protected] void btstack_memory_l2cap_service_free(l2cap_service_t *l2cap_service){ 193b6269742SMatthias Ringwald UNUSED(l2cap_service); 194c4d3f927Smatthias.ringwald }; 195c4d3f927Smatthias.ringwald #endif 196a3b02b71Smatthias.ringwald #elif defined(HAVE_MALLOC) 1972a95308bSMatthias Ringwald 1982a95308bSMatthias Ringwald typedef struct { 1992a95308bSMatthias Ringwald l2cap_service_t data; 2002a95308bSMatthias Ringwald btstack_memory_buffer_t tracking; 2012a95308bSMatthias Ringwald } btstack_memory_l2cap_service_t; 2022a95308bSMatthias Ringwald 2036527a633S[email protected] l2cap_service_t * btstack_memory_l2cap_service_get(void){ 2042a95308bSMatthias Ringwald btstack_memory_l2cap_service_t * buffer = (btstack_memory_l2cap_service_t *) malloc(sizeof(btstack_memory_l2cap_service_t)); 205a2673d88SMatthias Ringwald if (buffer){ 2062a95308bSMatthias Ringwald memset(buffer, 0, sizeof(l2cap_service_t)); 2072a95308bSMatthias Ringwald btstack_memory_tracking_add(&buffer->tracking); 2082a95308bSMatthias Ringwald return &buffer->data; 209b6269742SMatthias Ringwald } else { 210b6269742SMatthias Ringwald return NULL; 211a2673d88SMatthias Ringwald } 212a3b02b71Smatthias.ringwald } 2136527a633S[email protected] void btstack_memory_l2cap_service_free(l2cap_service_t *l2cap_service){ 2142a95308bSMatthias Ringwald btstack_memory_l2cap_service_t * buffer = (btstack_memory_l2cap_service_t *) l2cap_service; 2152a95308bSMatthias Ringwald btstack_memory_tracking_remove(&buffer->tracking); 216b6269742SMatthias Ringwald free(buffer); 217a3b02b71Smatthias.ringwald } 218a3b02b71Smatthias.ringwald #endif 219a3b02b71Smatthias.ringwald 220a3b02b71Smatthias.ringwald 221a3b02b71Smatthias.ringwald // MARK: l2cap_channel_t 222a265b909SMatthias Ringwald #if !defined(HAVE_MALLOC) && !defined(MAX_NR_L2CAP_CHANNELS) 223a265b909SMatthias Ringwald #if defined(MAX_NO_L2CAP_CHANNELS) 22427faf85aSMilanka 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." 225a265b909SMatthias Ringwald #else 226a265b909SMatthias Ringwald #define MAX_NR_L2CAP_CHANNELS 0 227a265b909SMatthias Ringwald #endif 228a265b909SMatthias Ringwald #endif 229a265b909SMatthias Ringwald 230a265b909SMatthias Ringwald #ifdef MAX_NR_L2CAP_CHANNELS 231a265b909SMatthias Ringwald #if MAX_NR_L2CAP_CHANNELS > 0 232a265b909SMatthias Ringwald static l2cap_channel_t l2cap_channel_storage[MAX_NR_L2CAP_CHANNELS]; 23329d0c4f7SMatthias Ringwald static btstack_memory_pool_t l2cap_channel_pool; 2346527a633S[email protected] l2cap_channel_t * btstack_memory_l2cap_channel_get(void){ 235a2673d88SMatthias Ringwald void * buffer = btstack_memory_pool_get(&l2cap_channel_pool); 236a2673d88SMatthias Ringwald if (buffer){ 237a2673d88SMatthias Ringwald memset(buffer, 0, sizeof(l2cap_channel_t)); 238a2673d88SMatthias Ringwald } 239a2673d88SMatthias Ringwald return (l2cap_channel_t *) buffer; 240a3b02b71Smatthias.ringwald } 2416527a633S[email protected] void btstack_memory_l2cap_channel_free(l2cap_channel_t *l2cap_channel){ 24229d0c4f7SMatthias Ringwald btstack_memory_pool_free(&l2cap_channel_pool, l2cap_channel); 243a3b02b71Smatthias.ringwald } 244c4d3f927Smatthias.ringwald #else 2456527a633S[email protected] l2cap_channel_t * btstack_memory_l2cap_channel_get(void){ 246c4d3f927Smatthias.ringwald return NULL; 247c4d3f927Smatthias.ringwald } 2486527a633S[email protected] void btstack_memory_l2cap_channel_free(l2cap_channel_t *l2cap_channel){ 249b6269742SMatthias Ringwald UNUSED(l2cap_channel); 250c4d3f927Smatthias.ringwald }; 251c4d3f927Smatthias.ringwald #endif 252a3b02b71Smatthias.ringwald #elif defined(HAVE_MALLOC) 2532a95308bSMatthias Ringwald 2542a95308bSMatthias Ringwald typedef struct { 2552a95308bSMatthias Ringwald l2cap_channel_t data; 2562a95308bSMatthias Ringwald btstack_memory_buffer_t tracking; 2572a95308bSMatthias Ringwald } btstack_memory_l2cap_channel_t; 2582a95308bSMatthias Ringwald 2596527a633S[email protected] l2cap_channel_t * btstack_memory_l2cap_channel_get(void){ 2602a95308bSMatthias Ringwald btstack_memory_l2cap_channel_t * buffer = (btstack_memory_l2cap_channel_t *) malloc(sizeof(btstack_memory_l2cap_channel_t)); 261a2673d88SMatthias Ringwald if (buffer){ 2622a95308bSMatthias Ringwald memset(buffer, 0, sizeof(l2cap_channel_t)); 2632a95308bSMatthias Ringwald btstack_memory_tracking_add(&buffer->tracking); 2642a95308bSMatthias Ringwald return &buffer->data; 265b6269742SMatthias Ringwald } else { 266b6269742SMatthias Ringwald return NULL; 267a2673d88SMatthias Ringwald } 268a3b02b71Smatthias.ringwald } 2696527a633S[email protected] void btstack_memory_l2cap_channel_free(l2cap_channel_t *l2cap_channel){ 2702a95308bSMatthias Ringwald btstack_memory_l2cap_channel_t * buffer = (btstack_memory_l2cap_channel_t *) l2cap_channel; 2712a95308bSMatthias Ringwald btstack_memory_tracking_remove(&buffer->tracking); 272b6269742SMatthias Ringwald free(buffer); 273a3b02b71Smatthias.ringwald } 274a3b02b71Smatthias.ringwald #endif 275a3b02b71Smatthias.ringwald 276a3b02b71Smatthias.ringwald 27744c5d856SMatthias Ringwald #ifdef ENABLE_CLASSIC 2782e97c149S[email protected] 279a3b02b71Smatthias.ringwald // MARK: rfcomm_multiplexer_t 280a265b909SMatthias Ringwald #if !defined(HAVE_MALLOC) && !defined(MAX_NR_RFCOMM_MULTIPLEXERS) 281a265b909SMatthias Ringwald #if defined(MAX_NO_RFCOMM_MULTIPLEXERS) 28227faf85aSMilanka 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." 283a265b909SMatthias Ringwald #else 284a265b909SMatthias Ringwald #define MAX_NR_RFCOMM_MULTIPLEXERS 0 285a265b909SMatthias Ringwald #endif 286a265b909SMatthias Ringwald #endif 287a265b909SMatthias Ringwald 288a265b909SMatthias Ringwald #ifdef MAX_NR_RFCOMM_MULTIPLEXERS 289a265b909SMatthias Ringwald #if MAX_NR_RFCOMM_MULTIPLEXERS > 0 290a265b909SMatthias Ringwald static rfcomm_multiplexer_t rfcomm_multiplexer_storage[MAX_NR_RFCOMM_MULTIPLEXERS]; 29129d0c4f7SMatthias Ringwald static btstack_memory_pool_t rfcomm_multiplexer_pool; 2926527a633S[email protected] rfcomm_multiplexer_t * btstack_memory_rfcomm_multiplexer_get(void){ 293a2673d88SMatthias Ringwald void * buffer = btstack_memory_pool_get(&rfcomm_multiplexer_pool); 294a2673d88SMatthias Ringwald if (buffer){ 295a2673d88SMatthias Ringwald memset(buffer, 0, sizeof(rfcomm_multiplexer_t)); 296a2673d88SMatthias Ringwald } 297a2673d88SMatthias Ringwald return (rfcomm_multiplexer_t *) buffer; 298a3b02b71Smatthias.ringwald } 2996527a633S[email protected] void btstack_memory_rfcomm_multiplexer_free(rfcomm_multiplexer_t *rfcomm_multiplexer){ 30029d0c4f7SMatthias Ringwald btstack_memory_pool_free(&rfcomm_multiplexer_pool, rfcomm_multiplexer); 301a3b02b71Smatthias.ringwald } 302c4d3f927Smatthias.ringwald #else 3036527a633S[email protected] rfcomm_multiplexer_t * btstack_memory_rfcomm_multiplexer_get(void){ 304c4d3f927Smatthias.ringwald return NULL; 305c4d3f927Smatthias.ringwald } 3066527a633S[email protected] void btstack_memory_rfcomm_multiplexer_free(rfcomm_multiplexer_t *rfcomm_multiplexer){ 307b6269742SMatthias Ringwald UNUSED(rfcomm_multiplexer); 308c4d3f927Smatthias.ringwald }; 309c4d3f927Smatthias.ringwald #endif 310a3b02b71Smatthias.ringwald #elif defined(HAVE_MALLOC) 3112a95308bSMatthias Ringwald 3122a95308bSMatthias Ringwald typedef struct { 3132a95308bSMatthias Ringwald rfcomm_multiplexer_t data; 3142a95308bSMatthias Ringwald btstack_memory_buffer_t tracking; 3152a95308bSMatthias Ringwald } btstack_memory_rfcomm_multiplexer_t; 3162a95308bSMatthias Ringwald 3176527a633S[email protected] rfcomm_multiplexer_t * btstack_memory_rfcomm_multiplexer_get(void){ 3182a95308bSMatthias Ringwald btstack_memory_rfcomm_multiplexer_t * buffer = (btstack_memory_rfcomm_multiplexer_t *) malloc(sizeof(btstack_memory_rfcomm_multiplexer_t)); 319a2673d88SMatthias Ringwald if (buffer){ 3202a95308bSMatthias Ringwald memset(buffer, 0, sizeof(rfcomm_multiplexer_t)); 3212a95308bSMatthias Ringwald btstack_memory_tracking_add(&buffer->tracking); 3222a95308bSMatthias Ringwald return &buffer->data; 323b6269742SMatthias Ringwald } else { 324b6269742SMatthias Ringwald return NULL; 325a2673d88SMatthias Ringwald } 326a3b02b71Smatthias.ringwald } 3276527a633S[email protected] void btstack_memory_rfcomm_multiplexer_free(rfcomm_multiplexer_t *rfcomm_multiplexer){ 3282a95308bSMatthias Ringwald btstack_memory_rfcomm_multiplexer_t * buffer = (btstack_memory_rfcomm_multiplexer_t *) rfcomm_multiplexer; 3292a95308bSMatthias Ringwald btstack_memory_tracking_remove(&buffer->tracking); 330b6269742SMatthias Ringwald free(buffer); 331a3b02b71Smatthias.ringwald } 332a3b02b71Smatthias.ringwald #endif 333a3b02b71Smatthias.ringwald 334a3b02b71Smatthias.ringwald 335a3b02b71Smatthias.ringwald // MARK: rfcomm_service_t 336a265b909SMatthias Ringwald #if !defined(HAVE_MALLOC) && !defined(MAX_NR_RFCOMM_SERVICES) 337a265b909SMatthias Ringwald #if defined(MAX_NO_RFCOMM_SERVICES) 33827faf85aSMilanka 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." 339a265b909SMatthias Ringwald #else 340a265b909SMatthias Ringwald #define MAX_NR_RFCOMM_SERVICES 0 341a265b909SMatthias Ringwald #endif 342a265b909SMatthias Ringwald #endif 343a265b909SMatthias Ringwald 344a265b909SMatthias Ringwald #ifdef MAX_NR_RFCOMM_SERVICES 345a265b909SMatthias Ringwald #if MAX_NR_RFCOMM_SERVICES > 0 346a265b909SMatthias Ringwald static rfcomm_service_t rfcomm_service_storage[MAX_NR_RFCOMM_SERVICES]; 34729d0c4f7SMatthias Ringwald static btstack_memory_pool_t rfcomm_service_pool; 3486527a633S[email protected] rfcomm_service_t * btstack_memory_rfcomm_service_get(void){ 349a2673d88SMatthias Ringwald void * buffer = btstack_memory_pool_get(&rfcomm_service_pool); 350a2673d88SMatthias Ringwald if (buffer){ 351a2673d88SMatthias Ringwald memset(buffer, 0, sizeof(rfcomm_service_t)); 352a2673d88SMatthias Ringwald } 353a2673d88SMatthias Ringwald return (rfcomm_service_t *) buffer; 354a3b02b71Smatthias.ringwald } 3556527a633S[email protected] void btstack_memory_rfcomm_service_free(rfcomm_service_t *rfcomm_service){ 35629d0c4f7SMatthias Ringwald btstack_memory_pool_free(&rfcomm_service_pool, rfcomm_service); 357a3b02b71Smatthias.ringwald } 358c4d3f927Smatthias.ringwald #else 3596527a633S[email protected] rfcomm_service_t * btstack_memory_rfcomm_service_get(void){ 360c4d3f927Smatthias.ringwald return NULL; 361c4d3f927Smatthias.ringwald } 3626527a633S[email protected] void btstack_memory_rfcomm_service_free(rfcomm_service_t *rfcomm_service){ 363b6269742SMatthias Ringwald UNUSED(rfcomm_service); 364c4d3f927Smatthias.ringwald }; 365c4d3f927Smatthias.ringwald #endif 366a3b02b71Smatthias.ringwald #elif defined(HAVE_MALLOC) 3672a95308bSMatthias Ringwald 3682a95308bSMatthias Ringwald typedef struct { 3692a95308bSMatthias Ringwald rfcomm_service_t data; 3702a95308bSMatthias Ringwald btstack_memory_buffer_t tracking; 3712a95308bSMatthias Ringwald } btstack_memory_rfcomm_service_t; 3722a95308bSMatthias Ringwald 3736527a633S[email protected] rfcomm_service_t * btstack_memory_rfcomm_service_get(void){ 3742a95308bSMatthias Ringwald btstack_memory_rfcomm_service_t * buffer = (btstack_memory_rfcomm_service_t *) malloc(sizeof(btstack_memory_rfcomm_service_t)); 375a2673d88SMatthias Ringwald if (buffer){ 3762a95308bSMatthias Ringwald memset(buffer, 0, sizeof(rfcomm_service_t)); 3772a95308bSMatthias Ringwald btstack_memory_tracking_add(&buffer->tracking); 3782a95308bSMatthias Ringwald return &buffer->data; 379b6269742SMatthias Ringwald } else { 380b6269742SMatthias Ringwald return NULL; 381a2673d88SMatthias Ringwald } 382a3b02b71Smatthias.ringwald } 3836527a633S[email protected] void btstack_memory_rfcomm_service_free(rfcomm_service_t *rfcomm_service){ 3842a95308bSMatthias Ringwald btstack_memory_rfcomm_service_t * buffer = (btstack_memory_rfcomm_service_t *) rfcomm_service; 3852a95308bSMatthias Ringwald btstack_memory_tracking_remove(&buffer->tracking); 386b6269742SMatthias Ringwald free(buffer); 387a3b02b71Smatthias.ringwald } 388a3b02b71Smatthias.ringwald #endif 389a3b02b71Smatthias.ringwald 390a3b02b71Smatthias.ringwald 391a3b02b71Smatthias.ringwald // MARK: rfcomm_channel_t 392a265b909SMatthias Ringwald #if !defined(HAVE_MALLOC) && !defined(MAX_NR_RFCOMM_CHANNELS) 393a265b909SMatthias Ringwald #if defined(MAX_NO_RFCOMM_CHANNELS) 39427faf85aSMilanka 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." 395a265b909SMatthias Ringwald #else 396a265b909SMatthias Ringwald #define MAX_NR_RFCOMM_CHANNELS 0 397a265b909SMatthias Ringwald #endif 398a265b909SMatthias Ringwald #endif 399a265b909SMatthias Ringwald 400a265b909SMatthias Ringwald #ifdef MAX_NR_RFCOMM_CHANNELS 401a265b909SMatthias Ringwald #if MAX_NR_RFCOMM_CHANNELS > 0 402a265b909SMatthias Ringwald static rfcomm_channel_t rfcomm_channel_storage[MAX_NR_RFCOMM_CHANNELS]; 40329d0c4f7SMatthias Ringwald static btstack_memory_pool_t rfcomm_channel_pool; 4046527a633S[email protected] rfcomm_channel_t * btstack_memory_rfcomm_channel_get(void){ 405a2673d88SMatthias Ringwald void * buffer = btstack_memory_pool_get(&rfcomm_channel_pool); 406a2673d88SMatthias Ringwald if (buffer){ 407a2673d88SMatthias Ringwald memset(buffer, 0, sizeof(rfcomm_channel_t)); 408a2673d88SMatthias Ringwald } 409a2673d88SMatthias Ringwald return (rfcomm_channel_t *) buffer; 410a3b02b71Smatthias.ringwald } 4116527a633S[email protected] void btstack_memory_rfcomm_channel_free(rfcomm_channel_t *rfcomm_channel){ 41229d0c4f7SMatthias Ringwald btstack_memory_pool_free(&rfcomm_channel_pool, rfcomm_channel); 413a3b02b71Smatthias.ringwald } 414c4d3f927Smatthias.ringwald #else 4156527a633S[email protected] rfcomm_channel_t * btstack_memory_rfcomm_channel_get(void){ 416c4d3f927Smatthias.ringwald return NULL; 417c4d3f927Smatthias.ringwald } 4186527a633S[email protected] void btstack_memory_rfcomm_channel_free(rfcomm_channel_t *rfcomm_channel){ 419b6269742SMatthias Ringwald UNUSED(rfcomm_channel); 420c4d3f927Smatthias.ringwald }; 421c4d3f927Smatthias.ringwald #endif 422a3b02b71Smatthias.ringwald #elif defined(HAVE_MALLOC) 4232a95308bSMatthias Ringwald 4242a95308bSMatthias Ringwald typedef struct { 4252a95308bSMatthias Ringwald rfcomm_channel_t data; 4262a95308bSMatthias Ringwald btstack_memory_buffer_t tracking; 4272a95308bSMatthias Ringwald } btstack_memory_rfcomm_channel_t; 4282a95308bSMatthias Ringwald 4296527a633S[email protected] rfcomm_channel_t * btstack_memory_rfcomm_channel_get(void){ 4302a95308bSMatthias Ringwald btstack_memory_rfcomm_channel_t * buffer = (btstack_memory_rfcomm_channel_t *) malloc(sizeof(btstack_memory_rfcomm_channel_t)); 431a2673d88SMatthias Ringwald if (buffer){ 4322a95308bSMatthias Ringwald memset(buffer, 0, sizeof(rfcomm_channel_t)); 4332a95308bSMatthias Ringwald btstack_memory_tracking_add(&buffer->tracking); 4342a95308bSMatthias Ringwald return &buffer->data; 435b6269742SMatthias Ringwald } else { 436b6269742SMatthias Ringwald return NULL; 437a2673d88SMatthias Ringwald } 438a3b02b71Smatthias.ringwald } 4396527a633S[email protected] void btstack_memory_rfcomm_channel_free(rfcomm_channel_t *rfcomm_channel){ 4402a95308bSMatthias Ringwald btstack_memory_rfcomm_channel_t * buffer = (btstack_memory_rfcomm_channel_t *) rfcomm_channel; 4412a95308bSMatthias Ringwald btstack_memory_tracking_remove(&buffer->tracking); 442b6269742SMatthias Ringwald free(buffer); 443a3b02b71Smatthias.ringwald } 444a3b02b71Smatthias.ringwald #endif 445a3b02b71Smatthias.ringwald 446fdb398c2S[email protected] 447e0e5e285Smatthias.ringwald 4482c455dadSMatthias Ringwald // MARK: btstack_link_key_db_memory_entry_t 449a265b909SMatthias Ringwald #if !defined(HAVE_MALLOC) && !defined(MAX_NR_BTSTACK_LINK_KEY_DB_MEMORY_ENTRIES) 450a265b909SMatthias Ringwald #if defined(MAX_NO_BTSTACK_LINK_KEY_DB_MEMORY_ENTRIES) 45127faf85aSMilanka 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." 452a265b909SMatthias Ringwald #else 453a265b909SMatthias Ringwald #define MAX_NR_BTSTACK_LINK_KEY_DB_MEMORY_ENTRIES 0 454a265b909SMatthias Ringwald #endif 455a265b909SMatthias Ringwald #endif 456a265b909SMatthias Ringwald 457a265b909SMatthias Ringwald #ifdef MAX_NR_BTSTACK_LINK_KEY_DB_MEMORY_ENTRIES 458a265b909SMatthias Ringwald #if MAX_NR_BTSTACK_LINK_KEY_DB_MEMORY_ENTRIES > 0 459a265b909SMatthias Ringwald static btstack_link_key_db_memory_entry_t btstack_link_key_db_memory_entry_storage[MAX_NR_BTSTACK_LINK_KEY_DB_MEMORY_ENTRIES]; 4602c455dadSMatthias Ringwald static btstack_memory_pool_t btstack_link_key_db_memory_entry_pool; 4612c455dadSMatthias Ringwald btstack_link_key_db_memory_entry_t * btstack_memory_btstack_link_key_db_memory_entry_get(void){ 462a2673d88SMatthias Ringwald void * buffer = btstack_memory_pool_get(&btstack_link_key_db_memory_entry_pool); 463a2673d88SMatthias Ringwald if (buffer){ 464a2673d88SMatthias Ringwald memset(buffer, 0, sizeof(btstack_link_key_db_memory_entry_t)); 465a2673d88SMatthias Ringwald } 466a2673d88SMatthias Ringwald return (btstack_link_key_db_memory_entry_t *) buffer; 4671801b596Smatthias.ringwald } 4682c455dadSMatthias Ringwald void btstack_memory_btstack_link_key_db_memory_entry_free(btstack_link_key_db_memory_entry_t *btstack_link_key_db_memory_entry){ 4692c455dadSMatthias Ringwald btstack_memory_pool_free(&btstack_link_key_db_memory_entry_pool, btstack_link_key_db_memory_entry); 4701801b596Smatthias.ringwald } 471c4d3f927Smatthias.ringwald #else 4722c455dadSMatthias Ringwald btstack_link_key_db_memory_entry_t * btstack_memory_btstack_link_key_db_memory_entry_get(void){ 473c4d3f927Smatthias.ringwald return NULL; 474c4d3f927Smatthias.ringwald } 4752c455dadSMatthias Ringwald void btstack_memory_btstack_link_key_db_memory_entry_free(btstack_link_key_db_memory_entry_t *btstack_link_key_db_memory_entry){ 476b6269742SMatthias Ringwald UNUSED(btstack_link_key_db_memory_entry); 477c4d3f927Smatthias.ringwald }; 478c4d3f927Smatthias.ringwald #endif 4791801b596Smatthias.ringwald #elif defined(HAVE_MALLOC) 4802a95308bSMatthias Ringwald 4812a95308bSMatthias Ringwald typedef struct { 4822a95308bSMatthias Ringwald btstack_link_key_db_memory_entry_t data; 4832a95308bSMatthias Ringwald btstack_memory_buffer_t tracking; 4842a95308bSMatthias Ringwald } btstack_memory_btstack_link_key_db_memory_entry_t; 4852a95308bSMatthias Ringwald 4862c455dadSMatthias Ringwald btstack_link_key_db_memory_entry_t * btstack_memory_btstack_link_key_db_memory_entry_get(void){ 4872a95308bSMatthias 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)); 488a2673d88SMatthias Ringwald if (buffer){ 4892a95308bSMatthias Ringwald memset(buffer, 0, sizeof(btstack_link_key_db_memory_entry_t)); 4902a95308bSMatthias Ringwald btstack_memory_tracking_add(&buffer->tracking); 4912a95308bSMatthias Ringwald return &buffer->data; 492b6269742SMatthias Ringwald } else { 493b6269742SMatthias Ringwald return NULL; 494a2673d88SMatthias Ringwald } 4951801b596Smatthias.ringwald } 4962c455dadSMatthias Ringwald void btstack_memory_btstack_link_key_db_memory_entry_free(btstack_link_key_db_memory_entry_t *btstack_link_key_db_memory_entry){ 4972a95308bSMatthias Ringwald btstack_memory_btstack_link_key_db_memory_entry_t * buffer = (btstack_memory_btstack_link_key_db_memory_entry_t *) btstack_link_key_db_memory_entry; 4982a95308bSMatthias Ringwald btstack_memory_tracking_remove(&buffer->tracking); 499b6269742SMatthias Ringwald free(buffer); 500e0e5e285Smatthias.ringwald } 5011801b596Smatthias.ringwald #endif 5021801b596Smatthias.ringwald 5032e97c149S[email protected] 5042e97c149S[email protected] 5052e97c149S[email protected] // MARK: bnep_service_t 506a265b909SMatthias Ringwald #if !defined(HAVE_MALLOC) && !defined(MAX_NR_BNEP_SERVICES) 507a265b909SMatthias Ringwald #if defined(MAX_NO_BNEP_SERVICES) 50827faf85aSMilanka 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." 509a265b909SMatthias Ringwald #else 510a265b909SMatthias Ringwald #define MAX_NR_BNEP_SERVICES 0 511a265b909SMatthias Ringwald #endif 512a265b909SMatthias Ringwald #endif 513a265b909SMatthias Ringwald 514a265b909SMatthias Ringwald #ifdef MAX_NR_BNEP_SERVICES 515a265b909SMatthias Ringwald #if MAX_NR_BNEP_SERVICES > 0 516a265b909SMatthias Ringwald static bnep_service_t bnep_service_storage[MAX_NR_BNEP_SERVICES]; 51729d0c4f7SMatthias Ringwald static btstack_memory_pool_t bnep_service_pool; 5182e97c149S[email protected] bnep_service_t * btstack_memory_bnep_service_get(void){ 519a2673d88SMatthias Ringwald void * buffer = btstack_memory_pool_get(&bnep_service_pool); 520a2673d88SMatthias Ringwald if (buffer){ 521a2673d88SMatthias Ringwald memset(buffer, 0, sizeof(bnep_service_t)); 522a2673d88SMatthias Ringwald } 523a2673d88SMatthias Ringwald return (bnep_service_t *) buffer; 5242e97c149S[email protected] } 5252e97c149S[email protected] void btstack_memory_bnep_service_free(bnep_service_t *bnep_service){ 52629d0c4f7SMatthias Ringwald btstack_memory_pool_free(&bnep_service_pool, bnep_service); 5272e97c149S[email protected] } 5282e97c149S[email protected] #else 5292e97c149S[email protected] bnep_service_t * btstack_memory_bnep_service_get(void){ 5302e97c149S[email protected] return NULL; 5312e97c149S[email protected] } 5322e97c149S[email protected] void btstack_memory_bnep_service_free(bnep_service_t *bnep_service){ 533b6269742SMatthias Ringwald UNUSED(bnep_service); 5342e97c149S[email protected] }; 5352e97c149S[email protected] #endif 5362e97c149S[email protected] #elif defined(HAVE_MALLOC) 5372a95308bSMatthias Ringwald 5382a95308bSMatthias Ringwald typedef struct { 5392a95308bSMatthias Ringwald bnep_service_t data; 5402a95308bSMatthias Ringwald btstack_memory_buffer_t tracking; 5412a95308bSMatthias Ringwald } btstack_memory_bnep_service_t; 5422a95308bSMatthias Ringwald 5432e97c149S[email protected] bnep_service_t * btstack_memory_bnep_service_get(void){ 5442a95308bSMatthias Ringwald btstack_memory_bnep_service_t * buffer = (btstack_memory_bnep_service_t *) malloc(sizeof(btstack_memory_bnep_service_t)); 545a2673d88SMatthias Ringwald if (buffer){ 5462a95308bSMatthias Ringwald memset(buffer, 0, sizeof(bnep_service_t)); 5472a95308bSMatthias Ringwald btstack_memory_tracking_add(&buffer->tracking); 5482a95308bSMatthias Ringwald return &buffer->data; 549b6269742SMatthias Ringwald } else { 550b6269742SMatthias Ringwald return NULL; 551a2673d88SMatthias Ringwald } 5522e97c149S[email protected] } 5532e97c149S[email protected] void btstack_memory_bnep_service_free(bnep_service_t *bnep_service){ 5542a95308bSMatthias Ringwald btstack_memory_bnep_service_t * buffer = (btstack_memory_bnep_service_t *) bnep_service; 5552a95308bSMatthias Ringwald btstack_memory_tracking_remove(&buffer->tracking); 556b6269742SMatthias Ringwald free(buffer); 5572e97c149S[email protected] } 5582e97c149S[email protected] #endif 5592e97c149S[email protected] 5602e97c149S[email protected] 5612e97c149S[email protected] // MARK: bnep_channel_t 562a265b909SMatthias Ringwald #if !defined(HAVE_MALLOC) && !defined(MAX_NR_BNEP_CHANNELS) 563a265b909SMatthias Ringwald #if defined(MAX_NO_BNEP_CHANNELS) 56427faf85aSMilanka 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." 565a265b909SMatthias Ringwald #else 566a265b909SMatthias Ringwald #define MAX_NR_BNEP_CHANNELS 0 567a265b909SMatthias Ringwald #endif 568a265b909SMatthias Ringwald #endif 569a265b909SMatthias Ringwald 570a265b909SMatthias Ringwald #ifdef MAX_NR_BNEP_CHANNELS 571a265b909SMatthias Ringwald #if MAX_NR_BNEP_CHANNELS > 0 572a265b909SMatthias Ringwald static bnep_channel_t bnep_channel_storage[MAX_NR_BNEP_CHANNELS]; 57329d0c4f7SMatthias Ringwald static btstack_memory_pool_t bnep_channel_pool; 5742e97c149S[email protected] bnep_channel_t * btstack_memory_bnep_channel_get(void){ 575a2673d88SMatthias Ringwald void * buffer = btstack_memory_pool_get(&bnep_channel_pool); 576a2673d88SMatthias Ringwald if (buffer){ 577a2673d88SMatthias Ringwald memset(buffer, 0, sizeof(bnep_channel_t)); 578a2673d88SMatthias Ringwald } 579a2673d88SMatthias Ringwald return (bnep_channel_t *) buffer; 5802e97c149S[email protected] } 5812e97c149S[email protected] void btstack_memory_bnep_channel_free(bnep_channel_t *bnep_channel){ 58229d0c4f7SMatthias Ringwald btstack_memory_pool_free(&bnep_channel_pool, bnep_channel); 5832e97c149S[email protected] } 5842e97c149S[email protected] #else 5852e97c149S[email protected] bnep_channel_t * btstack_memory_bnep_channel_get(void){ 5862e97c149S[email protected] return NULL; 5872e97c149S[email protected] } 5882e97c149S[email protected] void btstack_memory_bnep_channel_free(bnep_channel_t *bnep_channel){ 589b6269742SMatthias Ringwald UNUSED(bnep_channel); 5902e97c149S[email protected] }; 5912e97c149S[email protected] #endif 5922e97c149S[email protected] #elif defined(HAVE_MALLOC) 5932a95308bSMatthias Ringwald 5942a95308bSMatthias Ringwald typedef struct { 5952a95308bSMatthias Ringwald bnep_channel_t data; 5962a95308bSMatthias Ringwald btstack_memory_buffer_t tracking; 5972a95308bSMatthias Ringwald } btstack_memory_bnep_channel_t; 5982a95308bSMatthias Ringwald 5992e97c149S[email protected] bnep_channel_t * btstack_memory_bnep_channel_get(void){ 6002a95308bSMatthias Ringwald btstack_memory_bnep_channel_t * buffer = (btstack_memory_bnep_channel_t *) malloc(sizeof(btstack_memory_bnep_channel_t)); 601a2673d88SMatthias Ringwald if (buffer){ 6022a95308bSMatthias Ringwald memset(buffer, 0, sizeof(bnep_channel_t)); 6032a95308bSMatthias Ringwald btstack_memory_tracking_add(&buffer->tracking); 6042a95308bSMatthias Ringwald return &buffer->data; 605b6269742SMatthias Ringwald } else { 606b6269742SMatthias Ringwald return NULL; 607a2673d88SMatthias Ringwald } 6082e97c149S[email protected] } 6092e97c149S[email protected] void btstack_memory_bnep_channel_free(bnep_channel_t *bnep_channel){ 6102a95308bSMatthias Ringwald btstack_memory_bnep_channel_t * buffer = (btstack_memory_bnep_channel_t *) bnep_channel; 6112a95308bSMatthias Ringwald btstack_memory_tracking_remove(&buffer->tracking); 612b6269742SMatthias Ringwald free(buffer); 6132e97c149S[email protected] } 6142e97c149S[email protected] #endif 6152e97c149S[email protected] 6162e97c149S[email protected] 617ea5029c9SMilanka Ringwald 618ea5029c9SMilanka Ringwald // MARK: hfp_connection_t 619a265b909SMatthias Ringwald #if !defined(HAVE_MALLOC) && !defined(MAX_NR_HFP_CONNECTIONS) 620a265b909SMatthias Ringwald #if defined(MAX_NO_HFP_CONNECTIONS) 62127faf85aSMilanka 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." 622a265b909SMatthias Ringwald #else 623a265b909SMatthias Ringwald #define MAX_NR_HFP_CONNECTIONS 0 624a265b909SMatthias Ringwald #endif 625a265b909SMatthias Ringwald #endif 626a265b909SMatthias Ringwald 627a265b909SMatthias Ringwald #ifdef MAX_NR_HFP_CONNECTIONS 628a265b909SMatthias Ringwald #if MAX_NR_HFP_CONNECTIONS > 0 629a265b909SMatthias Ringwald static hfp_connection_t hfp_connection_storage[MAX_NR_HFP_CONNECTIONS]; 63029d0c4f7SMatthias Ringwald static btstack_memory_pool_t hfp_connection_pool; 631ea5029c9SMilanka Ringwald hfp_connection_t * btstack_memory_hfp_connection_get(void){ 632a2673d88SMatthias Ringwald void * buffer = btstack_memory_pool_get(&hfp_connection_pool); 633a2673d88SMatthias Ringwald if (buffer){ 634a2673d88SMatthias Ringwald memset(buffer, 0, sizeof(hfp_connection_t)); 635a2673d88SMatthias Ringwald } 636a2673d88SMatthias Ringwald return (hfp_connection_t *) buffer; 637ea5029c9SMilanka Ringwald } 638ea5029c9SMilanka Ringwald void btstack_memory_hfp_connection_free(hfp_connection_t *hfp_connection){ 63929d0c4f7SMatthias Ringwald btstack_memory_pool_free(&hfp_connection_pool, hfp_connection); 640ea5029c9SMilanka Ringwald } 641ea5029c9SMilanka Ringwald #else 642ea5029c9SMilanka Ringwald hfp_connection_t * btstack_memory_hfp_connection_get(void){ 643ea5029c9SMilanka Ringwald return NULL; 644ea5029c9SMilanka Ringwald } 645ea5029c9SMilanka Ringwald void btstack_memory_hfp_connection_free(hfp_connection_t *hfp_connection){ 646b6269742SMatthias Ringwald UNUSED(hfp_connection); 647ea5029c9SMilanka Ringwald }; 648ea5029c9SMilanka Ringwald #endif 649ea5029c9SMilanka Ringwald #elif defined(HAVE_MALLOC) 6502a95308bSMatthias Ringwald 6512a95308bSMatthias Ringwald typedef struct { 6522a95308bSMatthias Ringwald hfp_connection_t data; 6532a95308bSMatthias Ringwald btstack_memory_buffer_t tracking; 6542a95308bSMatthias Ringwald } btstack_memory_hfp_connection_t; 6552a95308bSMatthias Ringwald 656ea5029c9SMilanka Ringwald hfp_connection_t * btstack_memory_hfp_connection_get(void){ 6572a95308bSMatthias Ringwald btstack_memory_hfp_connection_t * buffer = (btstack_memory_hfp_connection_t *) malloc(sizeof(btstack_memory_hfp_connection_t)); 658a2673d88SMatthias Ringwald if (buffer){ 6592a95308bSMatthias Ringwald memset(buffer, 0, sizeof(hfp_connection_t)); 6602a95308bSMatthias Ringwald btstack_memory_tracking_add(&buffer->tracking); 6612a95308bSMatthias Ringwald return &buffer->data; 662b6269742SMatthias Ringwald } else { 663b6269742SMatthias Ringwald return NULL; 664a2673d88SMatthias Ringwald } 665ea5029c9SMilanka Ringwald } 666ea5029c9SMilanka Ringwald void btstack_memory_hfp_connection_free(hfp_connection_t *hfp_connection){ 6672a95308bSMatthias Ringwald btstack_memory_hfp_connection_t * buffer = (btstack_memory_hfp_connection_t *) hfp_connection; 6682a95308bSMatthias Ringwald btstack_memory_tracking_remove(&buffer->tracking); 669b6269742SMatthias Ringwald free(buffer); 670ea5029c9SMilanka Ringwald } 671ea5029c9SMilanka Ringwald #endif 672ea5029c9SMilanka Ringwald 673ea5029c9SMilanka Ringwald 674cd9ee144SMatthias Ringwald 675cd9ee144SMatthias Ringwald // MARK: service_record_item_t 676a265b909SMatthias Ringwald #if !defined(HAVE_MALLOC) && !defined(MAX_NR_SERVICE_RECORD_ITEMS) 677a265b909SMatthias Ringwald #if defined(MAX_NO_SERVICE_RECORD_ITEMS) 67827faf85aSMilanka 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." 679a265b909SMatthias Ringwald #else 680a265b909SMatthias Ringwald #define MAX_NR_SERVICE_RECORD_ITEMS 0 681a265b909SMatthias Ringwald #endif 682a265b909SMatthias Ringwald #endif 683a265b909SMatthias Ringwald 684a265b909SMatthias Ringwald #ifdef MAX_NR_SERVICE_RECORD_ITEMS 685a265b909SMatthias Ringwald #if MAX_NR_SERVICE_RECORD_ITEMS > 0 686a265b909SMatthias Ringwald static service_record_item_t service_record_item_storage[MAX_NR_SERVICE_RECORD_ITEMS]; 68729d0c4f7SMatthias Ringwald static btstack_memory_pool_t service_record_item_pool; 688cd9ee144SMatthias Ringwald service_record_item_t * btstack_memory_service_record_item_get(void){ 689a2673d88SMatthias Ringwald void * buffer = btstack_memory_pool_get(&service_record_item_pool); 690a2673d88SMatthias Ringwald if (buffer){ 691a2673d88SMatthias Ringwald memset(buffer, 0, sizeof(service_record_item_t)); 692a2673d88SMatthias Ringwald } 693a2673d88SMatthias Ringwald return (service_record_item_t *) buffer; 694cd9ee144SMatthias Ringwald } 695cd9ee144SMatthias Ringwald void btstack_memory_service_record_item_free(service_record_item_t *service_record_item){ 69629d0c4f7SMatthias Ringwald btstack_memory_pool_free(&service_record_item_pool, service_record_item); 697cd9ee144SMatthias Ringwald } 698cd9ee144SMatthias Ringwald #else 699cd9ee144SMatthias Ringwald service_record_item_t * btstack_memory_service_record_item_get(void){ 700cd9ee144SMatthias Ringwald return NULL; 701cd9ee144SMatthias Ringwald } 702cd9ee144SMatthias Ringwald void btstack_memory_service_record_item_free(service_record_item_t *service_record_item){ 703b6269742SMatthias Ringwald UNUSED(service_record_item); 704cd9ee144SMatthias Ringwald }; 705cd9ee144SMatthias Ringwald #endif 706cd9ee144SMatthias Ringwald #elif defined(HAVE_MALLOC) 7072a95308bSMatthias Ringwald 7082a95308bSMatthias Ringwald typedef struct { 7092a95308bSMatthias Ringwald service_record_item_t data; 7102a95308bSMatthias Ringwald btstack_memory_buffer_t tracking; 7112a95308bSMatthias Ringwald } btstack_memory_service_record_item_t; 7122a95308bSMatthias Ringwald 713cd9ee144SMatthias Ringwald service_record_item_t * btstack_memory_service_record_item_get(void){ 7142a95308bSMatthias Ringwald btstack_memory_service_record_item_t * buffer = (btstack_memory_service_record_item_t *) malloc(sizeof(btstack_memory_service_record_item_t)); 715a2673d88SMatthias Ringwald if (buffer){ 7162a95308bSMatthias Ringwald memset(buffer, 0, sizeof(service_record_item_t)); 7172a95308bSMatthias Ringwald btstack_memory_tracking_add(&buffer->tracking); 7182a95308bSMatthias Ringwald return &buffer->data; 719b6269742SMatthias Ringwald } else { 720b6269742SMatthias Ringwald return NULL; 721a2673d88SMatthias Ringwald } 722cd9ee144SMatthias Ringwald } 723cd9ee144SMatthias Ringwald void btstack_memory_service_record_item_free(service_record_item_t *service_record_item){ 7242a95308bSMatthias Ringwald btstack_memory_service_record_item_t * buffer = (btstack_memory_service_record_item_t *) service_record_item; 7252a95308bSMatthias Ringwald btstack_memory_tracking_remove(&buffer->tracking); 726b6269742SMatthias Ringwald free(buffer); 727cd9ee144SMatthias Ringwald } 728cd9ee144SMatthias Ringwald #endif 729cd9ee144SMatthias Ringwald 730cd9ee144SMatthias Ringwald 73127faf85aSMilanka Ringwald 7320e826a17SMilanka Ringwald // MARK: avdtp_stream_endpoint_t 7330e826a17SMilanka Ringwald #if !defined(HAVE_MALLOC) && !defined(MAX_NR_AVDTP_STREAM_ENDPOINTS) 7340e826a17SMilanka Ringwald #if defined(MAX_NO_AVDTP_STREAM_ENDPOINTS) 7350e826a17SMilanka 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." 73627faf85aSMilanka Ringwald #else 7370e826a17SMilanka Ringwald #define MAX_NR_AVDTP_STREAM_ENDPOINTS 0 73827faf85aSMilanka Ringwald #endif 73927faf85aSMilanka Ringwald #endif 74027faf85aSMilanka Ringwald 7410e826a17SMilanka Ringwald #ifdef MAX_NR_AVDTP_STREAM_ENDPOINTS 7420e826a17SMilanka Ringwald #if MAX_NR_AVDTP_STREAM_ENDPOINTS > 0 7430e826a17SMilanka Ringwald static avdtp_stream_endpoint_t avdtp_stream_endpoint_storage[MAX_NR_AVDTP_STREAM_ENDPOINTS]; 7440e826a17SMilanka Ringwald static btstack_memory_pool_t avdtp_stream_endpoint_pool; 7450e826a17SMilanka Ringwald avdtp_stream_endpoint_t * btstack_memory_avdtp_stream_endpoint_get(void){ 746a2673d88SMatthias Ringwald void * buffer = btstack_memory_pool_get(&avdtp_stream_endpoint_pool); 747a2673d88SMatthias Ringwald if (buffer){ 748a2673d88SMatthias Ringwald memset(buffer, 0, sizeof(avdtp_stream_endpoint_t)); 749a2673d88SMatthias Ringwald } 750a2673d88SMatthias Ringwald return (avdtp_stream_endpoint_t *) buffer; 75127faf85aSMilanka Ringwald } 7520e826a17SMilanka Ringwald void btstack_memory_avdtp_stream_endpoint_free(avdtp_stream_endpoint_t *avdtp_stream_endpoint){ 7530e826a17SMilanka Ringwald btstack_memory_pool_free(&avdtp_stream_endpoint_pool, avdtp_stream_endpoint); 75427faf85aSMilanka Ringwald } 75527faf85aSMilanka Ringwald #else 7560e826a17SMilanka Ringwald avdtp_stream_endpoint_t * btstack_memory_avdtp_stream_endpoint_get(void){ 75727faf85aSMilanka Ringwald return NULL; 75827faf85aSMilanka Ringwald } 7590e826a17SMilanka Ringwald void btstack_memory_avdtp_stream_endpoint_free(avdtp_stream_endpoint_t *avdtp_stream_endpoint){ 760b6269742SMatthias Ringwald UNUSED(avdtp_stream_endpoint); 76127faf85aSMilanka Ringwald }; 76227faf85aSMilanka Ringwald #endif 76327faf85aSMilanka Ringwald #elif defined(HAVE_MALLOC) 7642a95308bSMatthias Ringwald 7652a95308bSMatthias Ringwald typedef struct { 7662a95308bSMatthias Ringwald avdtp_stream_endpoint_t data; 7672a95308bSMatthias Ringwald btstack_memory_buffer_t tracking; 7682a95308bSMatthias Ringwald } btstack_memory_avdtp_stream_endpoint_t; 7692a95308bSMatthias Ringwald 7700e826a17SMilanka Ringwald avdtp_stream_endpoint_t * btstack_memory_avdtp_stream_endpoint_get(void){ 7712a95308bSMatthias Ringwald btstack_memory_avdtp_stream_endpoint_t * buffer = (btstack_memory_avdtp_stream_endpoint_t *) malloc(sizeof(btstack_memory_avdtp_stream_endpoint_t)); 772a2673d88SMatthias Ringwald if (buffer){ 7732a95308bSMatthias Ringwald memset(buffer, 0, sizeof(avdtp_stream_endpoint_t)); 7742a95308bSMatthias Ringwald btstack_memory_tracking_add(&buffer->tracking); 7752a95308bSMatthias Ringwald return &buffer->data; 776b6269742SMatthias Ringwald } else { 777b6269742SMatthias Ringwald return NULL; 778a2673d88SMatthias Ringwald } 77927faf85aSMilanka Ringwald } 7800e826a17SMilanka Ringwald void btstack_memory_avdtp_stream_endpoint_free(avdtp_stream_endpoint_t *avdtp_stream_endpoint){ 7812a95308bSMatthias Ringwald btstack_memory_avdtp_stream_endpoint_t * buffer = (btstack_memory_avdtp_stream_endpoint_t *) avdtp_stream_endpoint; 7822a95308bSMatthias Ringwald btstack_memory_tracking_remove(&buffer->tracking); 783b6269742SMatthias Ringwald free(buffer); 78427faf85aSMilanka Ringwald } 78527faf85aSMilanka Ringwald #endif 78627faf85aSMilanka Ringwald 78727faf85aSMilanka Ringwald 78812e7f38cSMilanka Ringwald 78912e7f38cSMilanka Ringwald // MARK: avdtp_connection_t 79012e7f38cSMilanka Ringwald #if !defined(HAVE_MALLOC) && !defined(MAX_NR_AVDTP_CONNECTIONS) 79112e7f38cSMilanka Ringwald #if defined(MAX_NO_AVDTP_CONNECTIONS) 79212e7f38cSMilanka 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." 79312e7f38cSMilanka Ringwald #else 79412e7f38cSMilanka Ringwald #define MAX_NR_AVDTP_CONNECTIONS 0 79512e7f38cSMilanka Ringwald #endif 79612e7f38cSMilanka Ringwald #endif 79712e7f38cSMilanka Ringwald 79812e7f38cSMilanka Ringwald #ifdef MAX_NR_AVDTP_CONNECTIONS 79912e7f38cSMilanka Ringwald #if MAX_NR_AVDTP_CONNECTIONS > 0 80012e7f38cSMilanka Ringwald static avdtp_connection_t avdtp_connection_storage[MAX_NR_AVDTP_CONNECTIONS]; 80112e7f38cSMilanka Ringwald static btstack_memory_pool_t avdtp_connection_pool; 80212e7f38cSMilanka Ringwald avdtp_connection_t * btstack_memory_avdtp_connection_get(void){ 803a2673d88SMatthias Ringwald void * buffer = btstack_memory_pool_get(&avdtp_connection_pool); 804a2673d88SMatthias Ringwald if (buffer){ 805a2673d88SMatthias Ringwald memset(buffer, 0, sizeof(avdtp_connection_t)); 806a2673d88SMatthias Ringwald } 807a2673d88SMatthias Ringwald return (avdtp_connection_t *) buffer; 80812e7f38cSMilanka Ringwald } 80912e7f38cSMilanka Ringwald void btstack_memory_avdtp_connection_free(avdtp_connection_t *avdtp_connection){ 81012e7f38cSMilanka Ringwald btstack_memory_pool_free(&avdtp_connection_pool, avdtp_connection); 81112e7f38cSMilanka Ringwald } 81212e7f38cSMilanka Ringwald #else 81312e7f38cSMilanka Ringwald avdtp_connection_t * btstack_memory_avdtp_connection_get(void){ 81412e7f38cSMilanka Ringwald return NULL; 81512e7f38cSMilanka Ringwald } 81612e7f38cSMilanka Ringwald void btstack_memory_avdtp_connection_free(avdtp_connection_t *avdtp_connection){ 817b6269742SMatthias Ringwald UNUSED(avdtp_connection); 81812e7f38cSMilanka Ringwald }; 81912e7f38cSMilanka Ringwald #endif 82012e7f38cSMilanka Ringwald #elif defined(HAVE_MALLOC) 8212a95308bSMatthias Ringwald 8222a95308bSMatthias Ringwald typedef struct { 8232a95308bSMatthias Ringwald avdtp_connection_t data; 8242a95308bSMatthias Ringwald btstack_memory_buffer_t tracking; 8252a95308bSMatthias Ringwald } btstack_memory_avdtp_connection_t; 8262a95308bSMatthias Ringwald 82712e7f38cSMilanka Ringwald avdtp_connection_t * btstack_memory_avdtp_connection_get(void){ 8282a95308bSMatthias Ringwald btstack_memory_avdtp_connection_t * buffer = (btstack_memory_avdtp_connection_t *) malloc(sizeof(btstack_memory_avdtp_connection_t)); 829a2673d88SMatthias Ringwald if (buffer){ 8302a95308bSMatthias Ringwald memset(buffer, 0, sizeof(avdtp_connection_t)); 8312a95308bSMatthias Ringwald btstack_memory_tracking_add(&buffer->tracking); 8322a95308bSMatthias Ringwald return &buffer->data; 833b6269742SMatthias Ringwald } else { 834b6269742SMatthias Ringwald return NULL; 835a2673d88SMatthias Ringwald } 83612e7f38cSMilanka Ringwald } 83712e7f38cSMilanka Ringwald void btstack_memory_avdtp_connection_free(avdtp_connection_t *avdtp_connection){ 8382a95308bSMatthias Ringwald btstack_memory_avdtp_connection_t * buffer = (btstack_memory_avdtp_connection_t *) avdtp_connection; 8392a95308bSMatthias Ringwald btstack_memory_tracking_remove(&buffer->tracking); 840b6269742SMatthias Ringwald free(buffer); 84112e7f38cSMilanka Ringwald } 84212e7f38cSMilanka Ringwald #endif 84312e7f38cSMilanka Ringwald 84412e7f38cSMilanka Ringwald 84591451a2bSMilanka Ringwald 84691451a2bSMilanka Ringwald // MARK: avrcp_connection_t 84791451a2bSMilanka Ringwald #if !defined(HAVE_MALLOC) && !defined(MAX_NR_AVRCP_CONNECTIONS) 84891451a2bSMilanka Ringwald #if defined(MAX_NO_AVRCP_CONNECTIONS) 84991451a2bSMilanka 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." 85091451a2bSMilanka Ringwald #else 85191451a2bSMilanka Ringwald #define MAX_NR_AVRCP_CONNECTIONS 0 85291451a2bSMilanka Ringwald #endif 85391451a2bSMilanka Ringwald #endif 85491451a2bSMilanka Ringwald 85591451a2bSMilanka Ringwald #ifdef MAX_NR_AVRCP_CONNECTIONS 85691451a2bSMilanka Ringwald #if MAX_NR_AVRCP_CONNECTIONS > 0 85791451a2bSMilanka Ringwald static avrcp_connection_t avrcp_connection_storage[MAX_NR_AVRCP_CONNECTIONS]; 85891451a2bSMilanka Ringwald static btstack_memory_pool_t avrcp_connection_pool; 85991451a2bSMilanka Ringwald avrcp_connection_t * btstack_memory_avrcp_connection_get(void){ 860a2673d88SMatthias Ringwald void * buffer = btstack_memory_pool_get(&avrcp_connection_pool); 861a2673d88SMatthias Ringwald if (buffer){ 862a2673d88SMatthias Ringwald memset(buffer, 0, sizeof(avrcp_connection_t)); 863a2673d88SMatthias Ringwald } 864a2673d88SMatthias Ringwald return (avrcp_connection_t *) buffer; 86591451a2bSMilanka Ringwald } 86691451a2bSMilanka Ringwald void btstack_memory_avrcp_connection_free(avrcp_connection_t *avrcp_connection){ 86791451a2bSMilanka Ringwald btstack_memory_pool_free(&avrcp_connection_pool, avrcp_connection); 86891451a2bSMilanka Ringwald } 86991451a2bSMilanka Ringwald #else 87091451a2bSMilanka Ringwald avrcp_connection_t * btstack_memory_avrcp_connection_get(void){ 87191451a2bSMilanka Ringwald return NULL; 87291451a2bSMilanka Ringwald } 87391451a2bSMilanka Ringwald void btstack_memory_avrcp_connection_free(avrcp_connection_t *avrcp_connection){ 874b6269742SMatthias Ringwald UNUSED(avrcp_connection); 87591451a2bSMilanka Ringwald }; 87691451a2bSMilanka Ringwald #endif 87791451a2bSMilanka Ringwald #elif defined(HAVE_MALLOC) 8782a95308bSMatthias Ringwald 8792a95308bSMatthias Ringwald typedef struct { 8802a95308bSMatthias Ringwald avrcp_connection_t data; 8812a95308bSMatthias Ringwald btstack_memory_buffer_t tracking; 8822a95308bSMatthias Ringwald } btstack_memory_avrcp_connection_t; 8832a95308bSMatthias Ringwald 88491451a2bSMilanka Ringwald avrcp_connection_t * btstack_memory_avrcp_connection_get(void){ 8852a95308bSMatthias Ringwald btstack_memory_avrcp_connection_t * buffer = (btstack_memory_avrcp_connection_t *) malloc(sizeof(btstack_memory_avrcp_connection_t)); 886a2673d88SMatthias Ringwald if (buffer){ 8872a95308bSMatthias Ringwald memset(buffer, 0, sizeof(avrcp_connection_t)); 8882a95308bSMatthias Ringwald btstack_memory_tracking_add(&buffer->tracking); 8892a95308bSMatthias Ringwald return &buffer->data; 890b6269742SMatthias Ringwald } else { 891b6269742SMatthias Ringwald return NULL; 892a2673d88SMatthias Ringwald } 89391451a2bSMilanka Ringwald } 89491451a2bSMilanka Ringwald void btstack_memory_avrcp_connection_free(avrcp_connection_t *avrcp_connection){ 8952a95308bSMatthias Ringwald btstack_memory_avrcp_connection_t * buffer = (btstack_memory_avrcp_connection_t *) avrcp_connection; 8962a95308bSMatthias Ringwald btstack_memory_tracking_remove(&buffer->tracking); 897b6269742SMatthias Ringwald free(buffer); 89891451a2bSMilanka Ringwald } 89991451a2bSMilanka Ringwald #endif 90091451a2bSMilanka Ringwald 90191451a2bSMilanka Ringwald 902f12a3722SMilanka Ringwald 903f12a3722SMilanka Ringwald // MARK: avrcp_browsing_connection_t 904f12a3722SMilanka Ringwald #if !defined(HAVE_MALLOC) && !defined(MAX_NR_AVRCP_BROWSING_CONNECTIONS) 905f12a3722SMilanka Ringwald #if defined(MAX_NO_AVRCP_BROWSING_CONNECTIONS) 906f12a3722SMilanka 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." 907f12a3722SMilanka Ringwald #else 908f12a3722SMilanka Ringwald #define MAX_NR_AVRCP_BROWSING_CONNECTIONS 0 909f12a3722SMilanka Ringwald #endif 910f12a3722SMilanka Ringwald #endif 911f12a3722SMilanka Ringwald 912f12a3722SMilanka Ringwald #ifdef MAX_NR_AVRCP_BROWSING_CONNECTIONS 913f12a3722SMilanka Ringwald #if MAX_NR_AVRCP_BROWSING_CONNECTIONS > 0 914f12a3722SMilanka Ringwald static avrcp_browsing_connection_t avrcp_browsing_connection_storage[MAX_NR_AVRCP_BROWSING_CONNECTIONS]; 915f12a3722SMilanka Ringwald static btstack_memory_pool_t avrcp_browsing_connection_pool; 916f12a3722SMilanka Ringwald avrcp_browsing_connection_t * btstack_memory_avrcp_browsing_connection_get(void){ 917a2673d88SMatthias Ringwald void * buffer = btstack_memory_pool_get(&avrcp_browsing_connection_pool); 918a2673d88SMatthias Ringwald if (buffer){ 919a2673d88SMatthias Ringwald memset(buffer, 0, sizeof(avrcp_browsing_connection_t)); 920a2673d88SMatthias Ringwald } 921a2673d88SMatthias Ringwald return (avrcp_browsing_connection_t *) buffer; 922f12a3722SMilanka Ringwald } 923f12a3722SMilanka Ringwald void btstack_memory_avrcp_browsing_connection_free(avrcp_browsing_connection_t *avrcp_browsing_connection){ 924f12a3722SMilanka Ringwald btstack_memory_pool_free(&avrcp_browsing_connection_pool, avrcp_browsing_connection); 925f12a3722SMilanka Ringwald } 926f12a3722SMilanka Ringwald #else 927f12a3722SMilanka Ringwald avrcp_browsing_connection_t * btstack_memory_avrcp_browsing_connection_get(void){ 928f12a3722SMilanka Ringwald return NULL; 929f12a3722SMilanka Ringwald } 930f12a3722SMilanka Ringwald void btstack_memory_avrcp_browsing_connection_free(avrcp_browsing_connection_t *avrcp_browsing_connection){ 931b6269742SMatthias Ringwald UNUSED(avrcp_browsing_connection); 932f12a3722SMilanka Ringwald }; 933f12a3722SMilanka Ringwald #endif 934f12a3722SMilanka Ringwald #elif defined(HAVE_MALLOC) 9352a95308bSMatthias Ringwald 9362a95308bSMatthias Ringwald typedef struct { 9372a95308bSMatthias Ringwald avrcp_browsing_connection_t data; 9382a95308bSMatthias Ringwald btstack_memory_buffer_t tracking; 9392a95308bSMatthias Ringwald } btstack_memory_avrcp_browsing_connection_t; 9402a95308bSMatthias Ringwald 941f12a3722SMilanka Ringwald avrcp_browsing_connection_t * btstack_memory_avrcp_browsing_connection_get(void){ 9422a95308bSMatthias Ringwald btstack_memory_avrcp_browsing_connection_t * buffer = (btstack_memory_avrcp_browsing_connection_t *) malloc(sizeof(btstack_memory_avrcp_browsing_connection_t)); 943a2673d88SMatthias Ringwald if (buffer){ 9442a95308bSMatthias Ringwald memset(buffer, 0, sizeof(avrcp_browsing_connection_t)); 9452a95308bSMatthias Ringwald btstack_memory_tracking_add(&buffer->tracking); 9462a95308bSMatthias Ringwald return &buffer->data; 947b6269742SMatthias Ringwald } else { 948b6269742SMatthias Ringwald return NULL; 949a2673d88SMatthias Ringwald } 950f12a3722SMilanka Ringwald } 951f12a3722SMilanka Ringwald void btstack_memory_avrcp_browsing_connection_free(avrcp_browsing_connection_t *avrcp_browsing_connection){ 9522a95308bSMatthias Ringwald btstack_memory_avrcp_browsing_connection_t * buffer = (btstack_memory_avrcp_browsing_connection_t *) avrcp_browsing_connection; 9532a95308bSMatthias Ringwald btstack_memory_tracking_remove(&buffer->tracking); 954b6269742SMatthias Ringwald free(buffer); 955f12a3722SMilanka Ringwald } 956f12a3722SMilanka Ringwald #endif 957f12a3722SMilanka Ringwald 958f12a3722SMilanka Ringwald 95944c5d856SMatthias Ringwald #endif 960a9a4c409SMatthias Ringwald #ifdef ENABLE_BLE 9612e97c149S[email protected] 9622e97c149S[email protected] // MARK: gatt_client_t 963a265b909SMatthias Ringwald #if !defined(HAVE_MALLOC) && !defined(MAX_NR_GATT_CLIENTS) 964a265b909SMatthias Ringwald #if defined(MAX_NO_GATT_CLIENTS) 96527faf85aSMilanka 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." 966a265b909SMatthias Ringwald #else 967a265b909SMatthias Ringwald #define MAX_NR_GATT_CLIENTS 0 968a265b909SMatthias Ringwald #endif 969a265b909SMatthias Ringwald #endif 970a265b909SMatthias Ringwald 971a265b909SMatthias Ringwald #ifdef MAX_NR_GATT_CLIENTS 972a265b909SMatthias Ringwald #if MAX_NR_GATT_CLIENTS > 0 973a265b909SMatthias Ringwald static gatt_client_t gatt_client_storage[MAX_NR_GATT_CLIENTS]; 97429d0c4f7SMatthias Ringwald static btstack_memory_pool_t gatt_client_pool; 975d0fdae3cS[email protected] gatt_client_t * btstack_memory_gatt_client_get(void){ 976a2673d88SMatthias Ringwald void * buffer = btstack_memory_pool_get(&gatt_client_pool); 977a2673d88SMatthias Ringwald if (buffer){ 978a2673d88SMatthias Ringwald memset(buffer, 0, sizeof(gatt_client_t)); 979a2673d88SMatthias Ringwald } 980a2673d88SMatthias Ringwald return (gatt_client_t *) buffer; 981d0fdae3cS[email protected] } 982d0fdae3cS[email protected] void btstack_memory_gatt_client_free(gatt_client_t *gatt_client){ 98329d0c4f7SMatthias Ringwald btstack_memory_pool_free(&gatt_client_pool, gatt_client); 984d0fdae3cS[email protected] } 985d0fdae3cS[email protected] #else 986d0fdae3cS[email protected] gatt_client_t * btstack_memory_gatt_client_get(void){ 987d0fdae3cS[email protected] return NULL; 988d0fdae3cS[email protected] } 989d0fdae3cS[email protected] void btstack_memory_gatt_client_free(gatt_client_t *gatt_client){ 990b6269742SMatthias Ringwald UNUSED(gatt_client); 991d0fdae3cS[email protected] }; 992d0fdae3cS[email protected] #endif 993d0fdae3cS[email protected] #elif defined(HAVE_MALLOC) 9942a95308bSMatthias Ringwald 9952a95308bSMatthias Ringwald typedef struct { 9962a95308bSMatthias Ringwald gatt_client_t data; 9972a95308bSMatthias Ringwald btstack_memory_buffer_t tracking; 9982a95308bSMatthias Ringwald } btstack_memory_gatt_client_t; 9992a95308bSMatthias Ringwald 1000d0fdae3cS[email protected] gatt_client_t * btstack_memory_gatt_client_get(void){ 10012a95308bSMatthias Ringwald btstack_memory_gatt_client_t * buffer = (btstack_memory_gatt_client_t *) malloc(sizeof(btstack_memory_gatt_client_t)); 1002a2673d88SMatthias Ringwald if (buffer){ 10032a95308bSMatthias Ringwald memset(buffer, 0, sizeof(gatt_client_t)); 10042a95308bSMatthias Ringwald btstack_memory_tracking_add(&buffer->tracking); 10052a95308bSMatthias Ringwald return &buffer->data; 1006b6269742SMatthias Ringwald } else { 1007b6269742SMatthias Ringwald return NULL; 1008a2673d88SMatthias Ringwald } 1009d0fdae3cS[email protected] } 1010d0fdae3cS[email protected] void btstack_memory_gatt_client_free(gatt_client_t *gatt_client){ 10112a95308bSMatthias Ringwald btstack_memory_gatt_client_t * buffer = (btstack_memory_gatt_client_t *) gatt_client; 10122a95308bSMatthias Ringwald btstack_memory_tracking_remove(&buffer->tracking); 1013b6269742SMatthias Ringwald free(buffer); 1014d0fdae3cS[email protected] } 1015d0fdae3cS[email protected] #endif 10162e97c149S[email protected] 10172e97c149S[email protected] 1018656bec4fSMatthias Ringwald // MARK: whitelist_entry_t 1019a265b909SMatthias Ringwald #if !defined(HAVE_MALLOC) && !defined(MAX_NR_WHITELIST_ENTRIES) 1020a265b909SMatthias Ringwald #if defined(MAX_NO_WHITELIST_ENTRIES) 102127faf85aSMilanka 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." 1022a265b909SMatthias Ringwald #else 1023a265b909SMatthias Ringwald #define MAX_NR_WHITELIST_ENTRIES 0 1024a265b909SMatthias Ringwald #endif 1025a265b909SMatthias Ringwald #endif 1026a265b909SMatthias Ringwald 1027a265b909SMatthias Ringwald #ifdef MAX_NR_WHITELIST_ENTRIES 1028a265b909SMatthias Ringwald #if MAX_NR_WHITELIST_ENTRIES > 0 1029a265b909SMatthias Ringwald static whitelist_entry_t whitelist_entry_storage[MAX_NR_WHITELIST_ENTRIES]; 103029d0c4f7SMatthias Ringwald static btstack_memory_pool_t whitelist_entry_pool; 1031656bec4fSMatthias Ringwald whitelist_entry_t * btstack_memory_whitelist_entry_get(void){ 1032a2673d88SMatthias Ringwald void * buffer = btstack_memory_pool_get(&whitelist_entry_pool); 1033a2673d88SMatthias Ringwald if (buffer){ 1034a2673d88SMatthias Ringwald memset(buffer, 0, sizeof(whitelist_entry_t)); 1035a2673d88SMatthias Ringwald } 1036a2673d88SMatthias Ringwald return (whitelist_entry_t *) buffer; 1037656bec4fSMatthias Ringwald } 1038656bec4fSMatthias Ringwald void btstack_memory_whitelist_entry_free(whitelist_entry_t *whitelist_entry){ 103929d0c4f7SMatthias Ringwald btstack_memory_pool_free(&whitelist_entry_pool, whitelist_entry); 1040656bec4fSMatthias Ringwald } 1041656bec4fSMatthias Ringwald #else 1042656bec4fSMatthias Ringwald whitelist_entry_t * btstack_memory_whitelist_entry_get(void){ 1043656bec4fSMatthias Ringwald return NULL; 1044656bec4fSMatthias Ringwald } 1045656bec4fSMatthias Ringwald void btstack_memory_whitelist_entry_free(whitelist_entry_t *whitelist_entry){ 1046b6269742SMatthias Ringwald UNUSED(whitelist_entry); 1047656bec4fSMatthias Ringwald }; 1048656bec4fSMatthias Ringwald #endif 1049656bec4fSMatthias Ringwald #elif defined(HAVE_MALLOC) 10502a95308bSMatthias Ringwald 10512a95308bSMatthias Ringwald typedef struct { 10522a95308bSMatthias Ringwald whitelist_entry_t data; 10532a95308bSMatthias Ringwald btstack_memory_buffer_t tracking; 10542a95308bSMatthias Ringwald } btstack_memory_whitelist_entry_t; 10552a95308bSMatthias Ringwald 1056656bec4fSMatthias Ringwald whitelist_entry_t * btstack_memory_whitelist_entry_get(void){ 10572a95308bSMatthias Ringwald btstack_memory_whitelist_entry_t * buffer = (btstack_memory_whitelist_entry_t *) malloc(sizeof(btstack_memory_whitelist_entry_t)); 1058a2673d88SMatthias Ringwald if (buffer){ 10592a95308bSMatthias Ringwald memset(buffer, 0, sizeof(whitelist_entry_t)); 10602a95308bSMatthias Ringwald btstack_memory_tracking_add(&buffer->tracking); 10612a95308bSMatthias Ringwald return &buffer->data; 1062b6269742SMatthias Ringwald } else { 1063b6269742SMatthias Ringwald return NULL; 1064a2673d88SMatthias Ringwald } 1065656bec4fSMatthias Ringwald } 1066656bec4fSMatthias Ringwald void btstack_memory_whitelist_entry_free(whitelist_entry_t *whitelist_entry){ 10672a95308bSMatthias Ringwald btstack_memory_whitelist_entry_t * buffer = (btstack_memory_whitelist_entry_t *) whitelist_entry; 10682a95308bSMatthias Ringwald btstack_memory_tracking_remove(&buffer->tracking); 1069b6269742SMatthias Ringwald free(buffer); 1070656bec4fSMatthias Ringwald } 1071656bec4fSMatthias Ringwald #endif 1072656bec4fSMatthias Ringwald 1073656bec4fSMatthias Ringwald 1074cf49570bSMatthias Ringwald // MARK: sm_lookup_entry_t 1075a265b909SMatthias Ringwald #if !defined(HAVE_MALLOC) && !defined(MAX_NR_SM_LOOKUP_ENTRIES) 1076a265b909SMatthias Ringwald #if defined(MAX_NO_SM_LOOKUP_ENTRIES) 107727faf85aSMilanka 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." 1078a265b909SMatthias Ringwald #else 1079a265b909SMatthias Ringwald #define MAX_NR_SM_LOOKUP_ENTRIES 0 1080a265b909SMatthias Ringwald #endif 1081a265b909SMatthias Ringwald #endif 1082a265b909SMatthias Ringwald 1083a265b909SMatthias Ringwald #ifdef MAX_NR_SM_LOOKUP_ENTRIES 1084a265b909SMatthias Ringwald #if MAX_NR_SM_LOOKUP_ENTRIES > 0 1085a265b909SMatthias Ringwald static sm_lookup_entry_t sm_lookup_entry_storage[MAX_NR_SM_LOOKUP_ENTRIES]; 108629d0c4f7SMatthias Ringwald static btstack_memory_pool_t sm_lookup_entry_pool; 1087cf49570bSMatthias Ringwald sm_lookup_entry_t * btstack_memory_sm_lookup_entry_get(void){ 1088a2673d88SMatthias Ringwald void * buffer = btstack_memory_pool_get(&sm_lookup_entry_pool); 1089a2673d88SMatthias Ringwald if (buffer){ 1090a2673d88SMatthias Ringwald memset(buffer, 0, sizeof(sm_lookup_entry_t)); 1091a2673d88SMatthias Ringwald } 1092a2673d88SMatthias Ringwald return (sm_lookup_entry_t *) buffer; 1093cf49570bSMatthias Ringwald } 1094cf49570bSMatthias Ringwald void btstack_memory_sm_lookup_entry_free(sm_lookup_entry_t *sm_lookup_entry){ 109529d0c4f7SMatthias Ringwald btstack_memory_pool_free(&sm_lookup_entry_pool, sm_lookup_entry); 1096cf49570bSMatthias Ringwald } 1097cf49570bSMatthias Ringwald #else 1098cf49570bSMatthias Ringwald sm_lookup_entry_t * btstack_memory_sm_lookup_entry_get(void){ 1099cf49570bSMatthias Ringwald return NULL; 1100cf49570bSMatthias Ringwald } 1101cf49570bSMatthias Ringwald void btstack_memory_sm_lookup_entry_free(sm_lookup_entry_t *sm_lookup_entry){ 1102b6269742SMatthias Ringwald UNUSED(sm_lookup_entry); 1103cf49570bSMatthias Ringwald }; 1104cf49570bSMatthias Ringwald #endif 1105cf49570bSMatthias Ringwald #elif defined(HAVE_MALLOC) 11062a95308bSMatthias Ringwald 11072a95308bSMatthias Ringwald typedef struct { 11082a95308bSMatthias Ringwald sm_lookup_entry_t data; 11092a95308bSMatthias Ringwald btstack_memory_buffer_t tracking; 11102a95308bSMatthias Ringwald } btstack_memory_sm_lookup_entry_t; 11112a95308bSMatthias Ringwald 1112cf49570bSMatthias Ringwald sm_lookup_entry_t * btstack_memory_sm_lookup_entry_get(void){ 11132a95308bSMatthias Ringwald btstack_memory_sm_lookup_entry_t * buffer = (btstack_memory_sm_lookup_entry_t *) malloc(sizeof(btstack_memory_sm_lookup_entry_t)); 1114a2673d88SMatthias Ringwald if (buffer){ 11152a95308bSMatthias Ringwald memset(buffer, 0, sizeof(sm_lookup_entry_t)); 11162a95308bSMatthias Ringwald btstack_memory_tracking_add(&buffer->tracking); 11172a95308bSMatthias Ringwald return &buffer->data; 1118b6269742SMatthias Ringwald } else { 1119b6269742SMatthias Ringwald return NULL; 1120a2673d88SMatthias Ringwald } 1121cf49570bSMatthias Ringwald } 1122cf49570bSMatthias Ringwald void btstack_memory_sm_lookup_entry_free(sm_lookup_entry_t *sm_lookup_entry){ 11232a95308bSMatthias Ringwald btstack_memory_sm_lookup_entry_t * buffer = (btstack_memory_sm_lookup_entry_t *) sm_lookup_entry; 11242a95308bSMatthias Ringwald btstack_memory_tracking_remove(&buffer->tracking); 1125b6269742SMatthias Ringwald free(buffer); 1126cf49570bSMatthias Ringwald } 1127cf49570bSMatthias Ringwald #endif 1128cf49570bSMatthias Ringwald 1129cf49570bSMatthias Ringwald 113044c5d856SMatthias Ringwald #endif 113144c5d856SMatthias Ringwald #ifdef ENABLE_MESH 1132ebb73e1fSMatthias Ringwald 1133ebb73e1fSMatthias Ringwald // MARK: mesh_network_pdu_t 1134ebb73e1fSMatthias Ringwald #if !defined(HAVE_MALLOC) && !defined(MAX_NR_MESH_NETWORK_PDUS) 1135ebb73e1fSMatthias Ringwald #if defined(MAX_NO_MESH_NETWORK_PDUS) 1136ebb73e1fSMatthias 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." 1137ebb73e1fSMatthias Ringwald #else 1138ebb73e1fSMatthias Ringwald #define MAX_NR_MESH_NETWORK_PDUS 0 1139ebb73e1fSMatthias Ringwald #endif 1140ebb73e1fSMatthias Ringwald #endif 1141ebb73e1fSMatthias Ringwald 1142ebb73e1fSMatthias Ringwald #ifdef MAX_NR_MESH_NETWORK_PDUS 1143ebb73e1fSMatthias Ringwald #if MAX_NR_MESH_NETWORK_PDUS > 0 1144ebb73e1fSMatthias Ringwald static mesh_network_pdu_t mesh_network_pdu_storage[MAX_NR_MESH_NETWORK_PDUS]; 1145ebb73e1fSMatthias Ringwald static btstack_memory_pool_t mesh_network_pdu_pool; 1146ebb73e1fSMatthias Ringwald mesh_network_pdu_t * btstack_memory_mesh_network_pdu_get(void){ 11471c4e8084SMatthias Ringwald void * buffer = btstack_memory_pool_get(&mesh_network_pdu_pool); 11481c4e8084SMatthias Ringwald if (buffer){ 11491c4e8084SMatthias Ringwald memset(buffer, 0, sizeof(mesh_network_pdu_t)); 11501c4e8084SMatthias Ringwald } 11511c4e8084SMatthias Ringwald return (mesh_network_pdu_t *) buffer; 1152ebb73e1fSMatthias Ringwald } 1153ebb73e1fSMatthias Ringwald void btstack_memory_mesh_network_pdu_free(mesh_network_pdu_t *mesh_network_pdu){ 1154ebb73e1fSMatthias Ringwald btstack_memory_pool_free(&mesh_network_pdu_pool, mesh_network_pdu); 1155ebb73e1fSMatthias Ringwald } 1156ebb73e1fSMatthias Ringwald #else 1157ebb73e1fSMatthias Ringwald mesh_network_pdu_t * btstack_memory_mesh_network_pdu_get(void){ 1158ebb73e1fSMatthias Ringwald return NULL; 1159ebb73e1fSMatthias Ringwald } 1160ebb73e1fSMatthias Ringwald void btstack_memory_mesh_network_pdu_free(mesh_network_pdu_t *mesh_network_pdu){ 1161b6269742SMatthias Ringwald UNUSED(mesh_network_pdu); 1162ebb73e1fSMatthias Ringwald }; 1163ebb73e1fSMatthias Ringwald #endif 1164ebb73e1fSMatthias Ringwald #elif defined(HAVE_MALLOC) 11652a95308bSMatthias Ringwald 11662a95308bSMatthias Ringwald typedef struct { 11672a95308bSMatthias Ringwald mesh_network_pdu_t data; 11682a95308bSMatthias Ringwald btstack_memory_buffer_t tracking; 11692a95308bSMatthias Ringwald } btstack_memory_mesh_network_pdu_t; 11702a95308bSMatthias Ringwald 1171ebb73e1fSMatthias Ringwald mesh_network_pdu_t * btstack_memory_mesh_network_pdu_get(void){ 11722a95308bSMatthias Ringwald btstack_memory_mesh_network_pdu_t * buffer = (btstack_memory_mesh_network_pdu_t *) malloc(sizeof(btstack_memory_mesh_network_pdu_t)); 11731c4e8084SMatthias Ringwald if (buffer){ 11742a95308bSMatthias Ringwald memset(buffer, 0, sizeof(mesh_network_pdu_t)); 11752a95308bSMatthias Ringwald btstack_memory_tracking_add(&buffer->tracking); 11762a95308bSMatthias Ringwald return &buffer->data; 1177b6269742SMatthias Ringwald } else { 1178b6269742SMatthias Ringwald return NULL; 11791c4e8084SMatthias Ringwald } 1180ebb73e1fSMatthias Ringwald } 1181ebb73e1fSMatthias Ringwald void btstack_memory_mesh_network_pdu_free(mesh_network_pdu_t *mesh_network_pdu){ 11822a95308bSMatthias Ringwald btstack_memory_mesh_network_pdu_t * buffer = (btstack_memory_mesh_network_pdu_t *) mesh_network_pdu; 11832a95308bSMatthias Ringwald btstack_memory_tracking_remove(&buffer->tracking); 1184b6269742SMatthias Ringwald free(buffer); 1185ebb73e1fSMatthias Ringwald } 1186ebb73e1fSMatthias Ringwald #endif 1187ebb73e1fSMatthias Ringwald 1188ebb73e1fSMatthias Ringwald 1189a4bbc09dSMatthias Ringwald // MARK: mesh_segmented_pdu_t 1190a4bbc09dSMatthias Ringwald #if !defined(HAVE_MALLOC) && !defined(MAX_NR_MESH_SEGMENTED_PDUS) 1191a4bbc09dSMatthias Ringwald #if defined(MAX_NO_MESH_SEGMENTED_PDUS) 1192a4bbc09dSMatthias 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." 1193f7434c1fSMatthias Ringwald #else 1194a4bbc09dSMatthias Ringwald #define MAX_NR_MESH_SEGMENTED_PDUS 0 1195f7434c1fSMatthias Ringwald #endif 1196f7434c1fSMatthias Ringwald #endif 1197f7434c1fSMatthias Ringwald 1198a4bbc09dSMatthias Ringwald #ifdef MAX_NR_MESH_SEGMENTED_PDUS 1199a4bbc09dSMatthias Ringwald #if MAX_NR_MESH_SEGMENTED_PDUS > 0 1200a4bbc09dSMatthias Ringwald static mesh_segmented_pdu_t mesh_segmented_pdu_storage[MAX_NR_MESH_SEGMENTED_PDUS]; 1201a4bbc09dSMatthias Ringwald static btstack_memory_pool_t mesh_segmented_pdu_pool; 1202a4bbc09dSMatthias Ringwald mesh_segmented_pdu_t * btstack_memory_mesh_segmented_pdu_get(void){ 1203a4bbc09dSMatthias Ringwald void * buffer = btstack_memory_pool_get(&mesh_segmented_pdu_pool); 1204f7434c1fSMatthias Ringwald if (buffer){ 1205a4bbc09dSMatthias Ringwald memset(buffer, 0, sizeof(mesh_segmented_pdu_t)); 1206f7434c1fSMatthias Ringwald } 1207a4bbc09dSMatthias Ringwald return (mesh_segmented_pdu_t *) buffer; 1208f7434c1fSMatthias Ringwald } 1209a4bbc09dSMatthias Ringwald void btstack_memory_mesh_segmented_pdu_free(mesh_segmented_pdu_t *mesh_segmented_pdu){ 1210a4bbc09dSMatthias Ringwald btstack_memory_pool_free(&mesh_segmented_pdu_pool, mesh_segmented_pdu); 1211f7434c1fSMatthias Ringwald } 1212f7434c1fSMatthias Ringwald #else 1213a4bbc09dSMatthias Ringwald mesh_segmented_pdu_t * btstack_memory_mesh_segmented_pdu_get(void){ 1214f7434c1fSMatthias Ringwald return NULL; 1215f7434c1fSMatthias Ringwald } 1216a4bbc09dSMatthias Ringwald void btstack_memory_mesh_segmented_pdu_free(mesh_segmented_pdu_t *mesh_segmented_pdu){ 1217b6269742SMatthias Ringwald UNUSED(mesh_segmented_pdu); 1218f7434c1fSMatthias Ringwald }; 1219f7434c1fSMatthias Ringwald #endif 1220f7434c1fSMatthias Ringwald #elif defined(HAVE_MALLOC) 12212a95308bSMatthias Ringwald 12222a95308bSMatthias Ringwald typedef struct { 12232a95308bSMatthias Ringwald mesh_segmented_pdu_t data; 12242a95308bSMatthias Ringwald btstack_memory_buffer_t tracking; 12252a95308bSMatthias Ringwald } btstack_memory_mesh_segmented_pdu_t; 12262a95308bSMatthias Ringwald 1227a4bbc09dSMatthias Ringwald mesh_segmented_pdu_t * btstack_memory_mesh_segmented_pdu_get(void){ 12282a95308bSMatthias Ringwald btstack_memory_mesh_segmented_pdu_t * buffer = (btstack_memory_mesh_segmented_pdu_t *) malloc(sizeof(btstack_memory_mesh_segmented_pdu_t)); 1229f7434c1fSMatthias Ringwald if (buffer){ 12302a95308bSMatthias Ringwald memset(buffer, 0, sizeof(mesh_segmented_pdu_t)); 12312a95308bSMatthias Ringwald btstack_memory_tracking_add(&buffer->tracking); 12322a95308bSMatthias Ringwald return &buffer->data; 1233b6269742SMatthias Ringwald } else { 1234b6269742SMatthias Ringwald return NULL; 1235f7434c1fSMatthias Ringwald } 1236f7434c1fSMatthias Ringwald } 1237a4bbc09dSMatthias Ringwald void btstack_memory_mesh_segmented_pdu_free(mesh_segmented_pdu_t *mesh_segmented_pdu){ 12382a95308bSMatthias Ringwald btstack_memory_mesh_segmented_pdu_t * buffer = (btstack_memory_mesh_segmented_pdu_t *) mesh_segmented_pdu; 12392a95308bSMatthias Ringwald btstack_memory_tracking_remove(&buffer->tracking); 1240b6269742SMatthias Ringwald free(buffer); 1241f7434c1fSMatthias Ringwald } 1242f7434c1fSMatthias Ringwald #endif 1243f7434c1fSMatthias Ringwald 1244f7434c1fSMatthias Ringwald 1245491f99b3SMatthias Ringwald // MARK: mesh_upper_transport_pdu_t 1246491f99b3SMatthias Ringwald #if !defined(HAVE_MALLOC) && !defined(MAX_NR_MESH_UPPER_TRANSPORT_PDUS) 1247491f99b3SMatthias Ringwald #if defined(MAX_NO_MESH_UPPER_TRANSPORT_PDUS) 1248491f99b3SMatthias 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." 1249491f99b3SMatthias Ringwald #else 1250491f99b3SMatthias Ringwald #define MAX_NR_MESH_UPPER_TRANSPORT_PDUS 0 1251491f99b3SMatthias Ringwald #endif 1252491f99b3SMatthias Ringwald #endif 1253491f99b3SMatthias Ringwald 1254491f99b3SMatthias Ringwald #ifdef MAX_NR_MESH_UPPER_TRANSPORT_PDUS 1255491f99b3SMatthias Ringwald #if MAX_NR_MESH_UPPER_TRANSPORT_PDUS > 0 1256491f99b3SMatthias Ringwald static mesh_upper_transport_pdu_t mesh_upper_transport_pdu_storage[MAX_NR_MESH_UPPER_TRANSPORT_PDUS]; 1257491f99b3SMatthias Ringwald static btstack_memory_pool_t mesh_upper_transport_pdu_pool; 1258491f99b3SMatthias Ringwald mesh_upper_transport_pdu_t * btstack_memory_mesh_upper_transport_pdu_get(void){ 1259491f99b3SMatthias Ringwald void * buffer = btstack_memory_pool_get(&mesh_upper_transport_pdu_pool); 1260491f99b3SMatthias Ringwald if (buffer){ 1261491f99b3SMatthias Ringwald memset(buffer, 0, sizeof(mesh_upper_transport_pdu_t)); 1262491f99b3SMatthias Ringwald } 1263491f99b3SMatthias Ringwald return (mesh_upper_transport_pdu_t *) buffer; 1264491f99b3SMatthias Ringwald } 1265491f99b3SMatthias Ringwald void btstack_memory_mesh_upper_transport_pdu_free(mesh_upper_transport_pdu_t *mesh_upper_transport_pdu){ 1266491f99b3SMatthias Ringwald btstack_memory_pool_free(&mesh_upper_transport_pdu_pool, mesh_upper_transport_pdu); 1267491f99b3SMatthias Ringwald } 1268491f99b3SMatthias Ringwald #else 1269491f99b3SMatthias Ringwald mesh_upper_transport_pdu_t * btstack_memory_mesh_upper_transport_pdu_get(void){ 1270491f99b3SMatthias Ringwald return NULL; 1271491f99b3SMatthias Ringwald } 1272491f99b3SMatthias Ringwald void btstack_memory_mesh_upper_transport_pdu_free(mesh_upper_transport_pdu_t *mesh_upper_transport_pdu){ 1273b6269742SMatthias Ringwald UNUSED(mesh_upper_transport_pdu); 1274491f99b3SMatthias Ringwald }; 1275491f99b3SMatthias Ringwald #endif 1276491f99b3SMatthias Ringwald #elif defined(HAVE_MALLOC) 12772a95308bSMatthias Ringwald 12782a95308bSMatthias Ringwald typedef struct { 12792a95308bSMatthias Ringwald mesh_upper_transport_pdu_t data; 12802a95308bSMatthias Ringwald btstack_memory_buffer_t tracking; 12812a95308bSMatthias Ringwald } btstack_memory_mesh_upper_transport_pdu_t; 12822a95308bSMatthias Ringwald 1283491f99b3SMatthias Ringwald mesh_upper_transport_pdu_t * btstack_memory_mesh_upper_transport_pdu_get(void){ 12842a95308bSMatthias 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)); 1285491f99b3SMatthias Ringwald if (buffer){ 12862a95308bSMatthias Ringwald memset(buffer, 0, sizeof(mesh_upper_transport_pdu_t)); 12872a95308bSMatthias Ringwald btstack_memory_tracking_add(&buffer->tracking); 12882a95308bSMatthias Ringwald return &buffer->data; 1289b6269742SMatthias Ringwald } else { 1290b6269742SMatthias Ringwald return NULL; 1291491f99b3SMatthias Ringwald } 1292491f99b3SMatthias Ringwald } 1293491f99b3SMatthias Ringwald void btstack_memory_mesh_upper_transport_pdu_free(mesh_upper_transport_pdu_t *mesh_upper_transport_pdu){ 12942a95308bSMatthias Ringwald btstack_memory_mesh_upper_transport_pdu_t * buffer = (btstack_memory_mesh_upper_transport_pdu_t *) mesh_upper_transport_pdu; 12952a95308bSMatthias Ringwald btstack_memory_tracking_remove(&buffer->tracking); 1296b6269742SMatthias Ringwald free(buffer); 1297491f99b3SMatthias Ringwald } 1298491f99b3SMatthias Ringwald #endif 1299491f99b3SMatthias Ringwald 1300491f99b3SMatthias Ringwald 1301c0a711d9SMatthias Ringwald // MARK: mesh_network_key_t 1302c0a711d9SMatthias Ringwald #if !defined(HAVE_MALLOC) && !defined(MAX_NR_MESH_NETWORK_KEYS) 1303c0a711d9SMatthias Ringwald #if defined(MAX_NO_MESH_NETWORK_KEYS) 1304c0a711d9SMatthias 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." 1305c0a711d9SMatthias Ringwald #else 1306c0a711d9SMatthias Ringwald #define MAX_NR_MESH_NETWORK_KEYS 0 1307c0a711d9SMatthias Ringwald #endif 1308c0a711d9SMatthias Ringwald #endif 1309c0a711d9SMatthias Ringwald 1310c0a711d9SMatthias Ringwald #ifdef MAX_NR_MESH_NETWORK_KEYS 1311c0a711d9SMatthias Ringwald #if MAX_NR_MESH_NETWORK_KEYS > 0 1312c0a711d9SMatthias Ringwald static mesh_network_key_t mesh_network_key_storage[MAX_NR_MESH_NETWORK_KEYS]; 1313c0a711d9SMatthias Ringwald static btstack_memory_pool_t mesh_network_key_pool; 1314c0a711d9SMatthias Ringwald mesh_network_key_t * btstack_memory_mesh_network_key_get(void){ 13151c4e8084SMatthias Ringwald void * buffer = btstack_memory_pool_get(&mesh_network_key_pool); 13161c4e8084SMatthias Ringwald if (buffer){ 13171c4e8084SMatthias Ringwald memset(buffer, 0, sizeof(mesh_network_key_t)); 13181c4e8084SMatthias Ringwald } 13191c4e8084SMatthias Ringwald return (mesh_network_key_t *) buffer; 1320c0a711d9SMatthias Ringwald } 1321c0a711d9SMatthias Ringwald void btstack_memory_mesh_network_key_free(mesh_network_key_t *mesh_network_key){ 1322c0a711d9SMatthias Ringwald btstack_memory_pool_free(&mesh_network_key_pool, mesh_network_key); 1323c0a711d9SMatthias Ringwald } 1324c0a711d9SMatthias Ringwald #else 1325c0a711d9SMatthias Ringwald mesh_network_key_t * btstack_memory_mesh_network_key_get(void){ 1326c0a711d9SMatthias Ringwald return NULL; 1327c0a711d9SMatthias Ringwald } 1328c0a711d9SMatthias Ringwald void btstack_memory_mesh_network_key_free(mesh_network_key_t *mesh_network_key){ 1329b6269742SMatthias Ringwald UNUSED(mesh_network_key); 1330c0a711d9SMatthias Ringwald }; 1331c0a711d9SMatthias Ringwald #endif 1332c0a711d9SMatthias Ringwald #elif defined(HAVE_MALLOC) 13332a95308bSMatthias Ringwald 13342a95308bSMatthias Ringwald typedef struct { 13352a95308bSMatthias Ringwald mesh_network_key_t data; 13362a95308bSMatthias Ringwald btstack_memory_buffer_t tracking; 13372a95308bSMatthias Ringwald } btstack_memory_mesh_network_key_t; 13382a95308bSMatthias Ringwald 1339c0a711d9SMatthias Ringwald mesh_network_key_t * btstack_memory_mesh_network_key_get(void){ 13402a95308bSMatthias Ringwald btstack_memory_mesh_network_key_t * buffer = (btstack_memory_mesh_network_key_t *) malloc(sizeof(btstack_memory_mesh_network_key_t)); 13411c4e8084SMatthias Ringwald if (buffer){ 13422a95308bSMatthias Ringwald memset(buffer, 0, sizeof(mesh_network_key_t)); 13432a95308bSMatthias Ringwald btstack_memory_tracking_add(&buffer->tracking); 13442a95308bSMatthias Ringwald return &buffer->data; 1345b6269742SMatthias Ringwald } else { 1346b6269742SMatthias Ringwald return NULL; 13471c4e8084SMatthias Ringwald } 1348c0a711d9SMatthias Ringwald } 1349c0a711d9SMatthias Ringwald void btstack_memory_mesh_network_key_free(mesh_network_key_t *mesh_network_key){ 13502a95308bSMatthias Ringwald btstack_memory_mesh_network_key_t * buffer = (btstack_memory_mesh_network_key_t *) mesh_network_key; 13512a95308bSMatthias Ringwald btstack_memory_tracking_remove(&buffer->tracking); 1352b6269742SMatthias Ringwald free(buffer); 1353c0a711d9SMatthias Ringwald } 1354c0a711d9SMatthias Ringwald #endif 1355c0a711d9SMatthias Ringwald 1356c0a711d9SMatthias Ringwald 135701e2bf94SMatthias Ringwald // MARK: mesh_transport_key_t 135801e2bf94SMatthias Ringwald #if !defined(HAVE_MALLOC) && !defined(MAX_NR_MESH_TRANSPORT_KEYS) 135901e2bf94SMatthias Ringwald #if defined(MAX_NO_MESH_TRANSPORT_KEYS) 136001e2bf94SMatthias 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." 136101e2bf94SMatthias Ringwald #else 136201e2bf94SMatthias Ringwald #define MAX_NR_MESH_TRANSPORT_KEYS 0 136301e2bf94SMatthias Ringwald #endif 136401e2bf94SMatthias Ringwald #endif 136501e2bf94SMatthias Ringwald 136601e2bf94SMatthias Ringwald #ifdef MAX_NR_MESH_TRANSPORT_KEYS 136701e2bf94SMatthias Ringwald #if MAX_NR_MESH_TRANSPORT_KEYS > 0 136801e2bf94SMatthias Ringwald static mesh_transport_key_t mesh_transport_key_storage[MAX_NR_MESH_TRANSPORT_KEYS]; 136901e2bf94SMatthias Ringwald static btstack_memory_pool_t mesh_transport_key_pool; 137001e2bf94SMatthias Ringwald mesh_transport_key_t * btstack_memory_mesh_transport_key_get(void){ 137101e2bf94SMatthias Ringwald void * buffer = btstack_memory_pool_get(&mesh_transport_key_pool); 137201e2bf94SMatthias Ringwald if (buffer){ 137301e2bf94SMatthias Ringwald memset(buffer, 0, sizeof(mesh_transport_key_t)); 137401e2bf94SMatthias Ringwald } 137501e2bf94SMatthias Ringwald return (mesh_transport_key_t *) buffer; 137601e2bf94SMatthias Ringwald } 137701e2bf94SMatthias Ringwald void btstack_memory_mesh_transport_key_free(mesh_transport_key_t *mesh_transport_key){ 137801e2bf94SMatthias Ringwald btstack_memory_pool_free(&mesh_transport_key_pool, mesh_transport_key); 137901e2bf94SMatthias Ringwald } 138001e2bf94SMatthias Ringwald #else 138101e2bf94SMatthias Ringwald mesh_transport_key_t * btstack_memory_mesh_transport_key_get(void){ 138201e2bf94SMatthias Ringwald return NULL; 138301e2bf94SMatthias Ringwald } 138401e2bf94SMatthias Ringwald void btstack_memory_mesh_transport_key_free(mesh_transport_key_t *mesh_transport_key){ 1385b6269742SMatthias Ringwald UNUSED(mesh_transport_key); 138601e2bf94SMatthias Ringwald }; 138701e2bf94SMatthias Ringwald #endif 138801e2bf94SMatthias Ringwald #elif defined(HAVE_MALLOC) 13892a95308bSMatthias Ringwald 13902a95308bSMatthias Ringwald typedef struct { 13912a95308bSMatthias Ringwald mesh_transport_key_t data; 13922a95308bSMatthias Ringwald btstack_memory_buffer_t tracking; 13932a95308bSMatthias Ringwald } btstack_memory_mesh_transport_key_t; 13942a95308bSMatthias Ringwald 139501e2bf94SMatthias Ringwald mesh_transport_key_t * btstack_memory_mesh_transport_key_get(void){ 13962a95308bSMatthias Ringwald btstack_memory_mesh_transport_key_t * buffer = (btstack_memory_mesh_transport_key_t *) malloc(sizeof(btstack_memory_mesh_transport_key_t)); 139701e2bf94SMatthias Ringwald if (buffer){ 13982a95308bSMatthias Ringwald memset(buffer, 0, sizeof(mesh_transport_key_t)); 13992a95308bSMatthias Ringwald btstack_memory_tracking_add(&buffer->tracking); 14002a95308bSMatthias Ringwald return &buffer->data; 1401b6269742SMatthias Ringwald } else { 1402b6269742SMatthias Ringwald return NULL; 140301e2bf94SMatthias Ringwald } 140401e2bf94SMatthias Ringwald } 140501e2bf94SMatthias Ringwald void btstack_memory_mesh_transport_key_free(mesh_transport_key_t *mesh_transport_key){ 14062a95308bSMatthias Ringwald btstack_memory_mesh_transport_key_t * buffer = (btstack_memory_mesh_transport_key_t *) mesh_transport_key; 14072a95308bSMatthias Ringwald btstack_memory_tracking_remove(&buffer->tracking); 1408b6269742SMatthias Ringwald free(buffer); 140901e2bf94SMatthias Ringwald } 141001e2bf94SMatthias Ringwald #endif 141101e2bf94SMatthias Ringwald 141201e2bf94SMatthias Ringwald 14131f45d603SMatthias Ringwald // MARK: mesh_virtual_address_t 14141f45d603SMatthias Ringwald #if !defined(HAVE_MALLOC) && !defined(MAX_NR_MESH_VIRTUAL_ADDRESSS) 14151f45d603SMatthias Ringwald #if defined(MAX_NO_MESH_VIRTUAL_ADDRESSS) 14161f45d603SMatthias 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." 14171f45d603SMatthias Ringwald #else 14181f45d603SMatthias Ringwald #define MAX_NR_MESH_VIRTUAL_ADDRESSS 0 14191f45d603SMatthias Ringwald #endif 14201f45d603SMatthias Ringwald #endif 14211f45d603SMatthias Ringwald 14221f45d603SMatthias Ringwald #ifdef MAX_NR_MESH_VIRTUAL_ADDRESSS 14231f45d603SMatthias Ringwald #if MAX_NR_MESH_VIRTUAL_ADDRESSS > 0 14241f45d603SMatthias Ringwald static mesh_virtual_address_t mesh_virtual_address_storage[MAX_NR_MESH_VIRTUAL_ADDRESSS]; 14251f45d603SMatthias Ringwald static btstack_memory_pool_t mesh_virtual_address_pool; 14261f45d603SMatthias Ringwald mesh_virtual_address_t * btstack_memory_mesh_virtual_address_get(void){ 14271f45d603SMatthias Ringwald void * buffer = btstack_memory_pool_get(&mesh_virtual_address_pool); 14281f45d603SMatthias Ringwald if (buffer){ 14291f45d603SMatthias Ringwald memset(buffer, 0, sizeof(mesh_virtual_address_t)); 14301f45d603SMatthias Ringwald } 14311f45d603SMatthias Ringwald return (mesh_virtual_address_t *) buffer; 14321f45d603SMatthias Ringwald } 14331f45d603SMatthias Ringwald void btstack_memory_mesh_virtual_address_free(mesh_virtual_address_t *mesh_virtual_address){ 14341f45d603SMatthias Ringwald btstack_memory_pool_free(&mesh_virtual_address_pool, mesh_virtual_address); 14351f45d603SMatthias Ringwald } 14361f45d603SMatthias Ringwald #else 14371f45d603SMatthias Ringwald mesh_virtual_address_t * btstack_memory_mesh_virtual_address_get(void){ 14381f45d603SMatthias Ringwald return NULL; 14391f45d603SMatthias Ringwald } 14401f45d603SMatthias Ringwald void btstack_memory_mesh_virtual_address_free(mesh_virtual_address_t *mesh_virtual_address){ 1441b6269742SMatthias Ringwald UNUSED(mesh_virtual_address); 14421f45d603SMatthias Ringwald }; 14431f45d603SMatthias Ringwald #endif 14441f45d603SMatthias Ringwald #elif defined(HAVE_MALLOC) 14452a95308bSMatthias Ringwald 14462a95308bSMatthias Ringwald typedef struct { 14472a95308bSMatthias Ringwald mesh_virtual_address_t data; 14482a95308bSMatthias Ringwald btstack_memory_buffer_t tracking; 14492a95308bSMatthias Ringwald } btstack_memory_mesh_virtual_address_t; 14502a95308bSMatthias Ringwald 14511f45d603SMatthias Ringwald mesh_virtual_address_t * btstack_memory_mesh_virtual_address_get(void){ 14522a95308bSMatthias Ringwald btstack_memory_mesh_virtual_address_t * buffer = (btstack_memory_mesh_virtual_address_t *) malloc(sizeof(btstack_memory_mesh_virtual_address_t)); 14531f45d603SMatthias Ringwald if (buffer){ 14542a95308bSMatthias Ringwald memset(buffer, 0, sizeof(mesh_virtual_address_t)); 14552a95308bSMatthias Ringwald btstack_memory_tracking_add(&buffer->tracking); 14562a95308bSMatthias Ringwald return &buffer->data; 1457b6269742SMatthias Ringwald } else { 1458b6269742SMatthias Ringwald return NULL; 14591f45d603SMatthias Ringwald } 14601f45d603SMatthias Ringwald } 14611f45d603SMatthias Ringwald void btstack_memory_mesh_virtual_address_free(mesh_virtual_address_t *mesh_virtual_address){ 14622a95308bSMatthias Ringwald btstack_memory_mesh_virtual_address_t * buffer = (btstack_memory_mesh_virtual_address_t *) mesh_virtual_address; 14632a95308bSMatthias Ringwald btstack_memory_tracking_remove(&buffer->tracking); 1464b6269742SMatthias Ringwald free(buffer); 14651f45d603SMatthias Ringwald } 14661f45d603SMatthias Ringwald #endif 14671f45d603SMatthias Ringwald 14681f45d603SMatthias Ringwald 146901122b73SMatthias Ringwald // MARK: mesh_subnet_t 147001122b73SMatthias Ringwald #if !defined(HAVE_MALLOC) && !defined(MAX_NR_MESH_SUBNETS) 147101122b73SMatthias Ringwald #if defined(MAX_NO_MESH_SUBNETS) 147201122b73SMatthias 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." 147301122b73SMatthias Ringwald #else 147401122b73SMatthias Ringwald #define MAX_NR_MESH_SUBNETS 0 147501122b73SMatthias Ringwald #endif 147601122b73SMatthias Ringwald #endif 147701122b73SMatthias Ringwald 147801122b73SMatthias Ringwald #ifdef MAX_NR_MESH_SUBNETS 147901122b73SMatthias Ringwald #if MAX_NR_MESH_SUBNETS > 0 148001122b73SMatthias Ringwald static mesh_subnet_t mesh_subnet_storage[MAX_NR_MESH_SUBNETS]; 148101122b73SMatthias Ringwald static btstack_memory_pool_t mesh_subnet_pool; 148201122b73SMatthias Ringwald mesh_subnet_t * btstack_memory_mesh_subnet_get(void){ 148301122b73SMatthias Ringwald void * buffer = btstack_memory_pool_get(&mesh_subnet_pool); 148401122b73SMatthias Ringwald if (buffer){ 148501122b73SMatthias Ringwald memset(buffer, 0, sizeof(mesh_subnet_t)); 148601122b73SMatthias Ringwald } 148701122b73SMatthias Ringwald return (mesh_subnet_t *) buffer; 148801122b73SMatthias Ringwald } 148901122b73SMatthias Ringwald void btstack_memory_mesh_subnet_free(mesh_subnet_t *mesh_subnet){ 149001122b73SMatthias Ringwald btstack_memory_pool_free(&mesh_subnet_pool, mesh_subnet); 149101122b73SMatthias Ringwald } 149201122b73SMatthias Ringwald #else 149301122b73SMatthias Ringwald mesh_subnet_t * btstack_memory_mesh_subnet_get(void){ 149401122b73SMatthias Ringwald return NULL; 149501122b73SMatthias Ringwald } 149601122b73SMatthias Ringwald void btstack_memory_mesh_subnet_free(mesh_subnet_t *mesh_subnet){ 1497b6269742SMatthias Ringwald UNUSED(mesh_subnet); 149801122b73SMatthias Ringwald }; 149901122b73SMatthias Ringwald #endif 150001122b73SMatthias Ringwald #elif defined(HAVE_MALLOC) 15012a95308bSMatthias Ringwald 15022a95308bSMatthias Ringwald typedef struct { 15032a95308bSMatthias Ringwald mesh_subnet_t data; 15042a95308bSMatthias Ringwald btstack_memory_buffer_t tracking; 15052a95308bSMatthias Ringwald } btstack_memory_mesh_subnet_t; 15062a95308bSMatthias Ringwald 150701122b73SMatthias Ringwald mesh_subnet_t * btstack_memory_mesh_subnet_get(void){ 15082a95308bSMatthias Ringwald btstack_memory_mesh_subnet_t * buffer = (btstack_memory_mesh_subnet_t *) malloc(sizeof(btstack_memory_mesh_subnet_t)); 150901122b73SMatthias Ringwald if (buffer){ 15102a95308bSMatthias Ringwald memset(buffer, 0, sizeof(mesh_subnet_t)); 15112a95308bSMatthias Ringwald btstack_memory_tracking_add(&buffer->tracking); 15122a95308bSMatthias Ringwald return &buffer->data; 1513b6269742SMatthias Ringwald } else { 1514b6269742SMatthias Ringwald return NULL; 151501122b73SMatthias Ringwald } 151601122b73SMatthias Ringwald } 151701122b73SMatthias Ringwald void btstack_memory_mesh_subnet_free(mesh_subnet_t *mesh_subnet){ 15182a95308bSMatthias Ringwald btstack_memory_mesh_subnet_t * buffer = (btstack_memory_mesh_subnet_t *) mesh_subnet; 15192a95308bSMatthias Ringwald btstack_memory_tracking_remove(&buffer->tracking); 1520b6269742SMatthias Ringwald free(buffer); 152101122b73SMatthias Ringwald } 152201122b73SMatthias Ringwald #endif 152301122b73SMatthias Ringwald 152401122b73SMatthias Ringwald 15252e97c149S[email protected] #endif 1526a3b02b71Smatthias.ringwald // init 1527a3b02b71Smatthias.ringwald void btstack_memory_init(void){ 1528a265b909SMatthias Ringwald #if MAX_NR_HCI_CONNECTIONS > 0 1529a265b909SMatthias Ringwald btstack_memory_pool_create(&hci_connection_pool, hci_connection_storage, MAX_NR_HCI_CONNECTIONS, sizeof(hci_connection_t)); 1530a3b02b71Smatthias.ringwald #endif 1531a265b909SMatthias Ringwald #if MAX_NR_L2CAP_SERVICES > 0 1532a265b909SMatthias Ringwald btstack_memory_pool_create(&l2cap_service_pool, l2cap_service_storage, MAX_NR_L2CAP_SERVICES, sizeof(l2cap_service_t)); 1533a3b02b71Smatthias.ringwald #endif 1534a265b909SMatthias Ringwald #if MAX_NR_L2CAP_CHANNELS > 0 1535a265b909SMatthias Ringwald btstack_memory_pool_create(&l2cap_channel_pool, l2cap_channel_storage, MAX_NR_L2CAP_CHANNELS, sizeof(l2cap_channel_t)); 1536a3b02b71Smatthias.ringwald #endif 153744c5d856SMatthias Ringwald #ifdef ENABLE_CLASSIC 153850dc57fcSMatthias Ringwald #if MAX_NR_RFCOMM_MULTIPLEXERS > 0 153950dc57fcSMatthias Ringwald btstack_memory_pool_create(&rfcomm_multiplexer_pool, rfcomm_multiplexer_storage, MAX_NR_RFCOMM_MULTIPLEXERS, sizeof(rfcomm_multiplexer_t)); 1540a3b02b71Smatthias.ringwald #endif 154150dc57fcSMatthias Ringwald #if MAX_NR_RFCOMM_SERVICES > 0 154250dc57fcSMatthias Ringwald btstack_memory_pool_create(&rfcomm_service_pool, rfcomm_service_storage, MAX_NR_RFCOMM_SERVICES, sizeof(rfcomm_service_t)); 1543a3b02b71Smatthias.ringwald #endif 154450dc57fcSMatthias Ringwald #if MAX_NR_RFCOMM_CHANNELS > 0 154550dc57fcSMatthias Ringwald btstack_memory_pool_create(&rfcomm_channel_pool, rfcomm_channel_storage, MAX_NR_RFCOMM_CHANNELS, sizeof(rfcomm_channel_t)); 154650dc57fcSMatthias Ringwald #endif 154750dc57fcSMatthias Ringwald #if MAX_NR_BTSTACK_LINK_KEY_DB_MEMORY_ENTRIES > 0 154850dc57fcSMatthias 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)); 154950dc57fcSMatthias Ringwald #endif 155050dc57fcSMatthias Ringwald #if MAX_NR_BNEP_SERVICES > 0 155150dc57fcSMatthias Ringwald btstack_memory_pool_create(&bnep_service_pool, bnep_service_storage, MAX_NR_BNEP_SERVICES, sizeof(bnep_service_t)); 155250dc57fcSMatthias Ringwald #endif 155350dc57fcSMatthias Ringwald #if MAX_NR_BNEP_CHANNELS > 0 155450dc57fcSMatthias Ringwald btstack_memory_pool_create(&bnep_channel_pool, bnep_channel_storage, MAX_NR_BNEP_CHANNELS, sizeof(bnep_channel_t)); 155550dc57fcSMatthias Ringwald #endif 155650dc57fcSMatthias Ringwald #if MAX_NR_HFP_CONNECTIONS > 0 155750dc57fcSMatthias Ringwald btstack_memory_pool_create(&hfp_connection_pool, hfp_connection_storage, MAX_NR_HFP_CONNECTIONS, sizeof(hfp_connection_t)); 155850dc57fcSMatthias Ringwald #endif 155950dc57fcSMatthias Ringwald #if MAX_NR_SERVICE_RECORD_ITEMS > 0 156050dc57fcSMatthias Ringwald btstack_memory_pool_create(&service_record_item_pool, service_record_item_storage, MAX_NR_SERVICE_RECORD_ITEMS, sizeof(service_record_item_t)); 156150dc57fcSMatthias Ringwald #endif 156250dc57fcSMatthias Ringwald #if MAX_NR_AVDTP_STREAM_ENDPOINTS > 0 156350dc57fcSMatthias Ringwald btstack_memory_pool_create(&avdtp_stream_endpoint_pool, avdtp_stream_endpoint_storage, MAX_NR_AVDTP_STREAM_ENDPOINTS, sizeof(avdtp_stream_endpoint_t)); 156450dc57fcSMatthias Ringwald #endif 156550dc57fcSMatthias Ringwald #if MAX_NR_AVDTP_CONNECTIONS > 0 156650dc57fcSMatthias Ringwald btstack_memory_pool_create(&avdtp_connection_pool, avdtp_connection_storage, MAX_NR_AVDTP_CONNECTIONS, sizeof(avdtp_connection_t)); 156750dc57fcSMatthias Ringwald #endif 156850dc57fcSMatthias Ringwald #if MAX_NR_AVRCP_CONNECTIONS > 0 156950dc57fcSMatthias Ringwald btstack_memory_pool_create(&avrcp_connection_pool, avrcp_connection_storage, MAX_NR_AVRCP_CONNECTIONS, sizeof(avrcp_connection_t)); 157050dc57fcSMatthias Ringwald #endif 157150dc57fcSMatthias Ringwald #if MAX_NR_AVRCP_BROWSING_CONNECTIONS > 0 157250dc57fcSMatthias Ringwald btstack_memory_pool_create(&avrcp_browsing_connection_pool, avrcp_browsing_connection_storage, MAX_NR_AVRCP_BROWSING_CONNECTIONS, sizeof(avrcp_browsing_connection_t)); 1573a3b02b71Smatthias.ringwald #endif 1574f12a3722SMilanka Ringwald #endif 1575a9a4c409SMatthias Ringwald #ifdef ENABLE_BLE 1576a265b909SMatthias Ringwald #if MAX_NR_GATT_CLIENTS > 0 1577a265b909SMatthias Ringwald btstack_memory_pool_create(&gatt_client_pool, gatt_client_storage, MAX_NR_GATT_CLIENTS, sizeof(gatt_client_t)); 1578d0fdae3cS[email protected] #endif 1579a265b909SMatthias Ringwald #if MAX_NR_WHITELIST_ENTRIES > 0 1580a265b909SMatthias Ringwald btstack_memory_pool_create(&whitelist_entry_pool, whitelist_entry_storage, MAX_NR_WHITELIST_ENTRIES, sizeof(whitelist_entry_t)); 1581656bec4fSMatthias Ringwald #endif 1582a265b909SMatthias Ringwald #if MAX_NR_SM_LOOKUP_ENTRIES > 0 1583a265b909SMatthias Ringwald btstack_memory_pool_create(&sm_lookup_entry_pool, sm_lookup_entry_storage, MAX_NR_SM_LOOKUP_ENTRIES, sizeof(sm_lookup_entry_t)); 1584cf49570bSMatthias Ringwald #endif 1585ebb73e1fSMatthias Ringwald #endif 158644c5d856SMatthias Ringwald #ifdef ENABLE_MESH 158750dc57fcSMatthias Ringwald #if MAX_NR_MESH_NETWORK_PDUS > 0 158850dc57fcSMatthias Ringwald btstack_memory_pool_create(&mesh_network_pdu_pool, mesh_network_pdu_storage, MAX_NR_MESH_NETWORK_PDUS, sizeof(mesh_network_pdu_t)); 158944c5d856SMatthias Ringwald #endif 1590a4bbc09dSMatthias Ringwald #if MAX_NR_MESH_SEGMENTED_PDUS > 0 1591a4bbc09dSMatthias Ringwald btstack_memory_pool_create(&mesh_segmented_pdu_pool, mesh_segmented_pdu_storage, MAX_NR_MESH_SEGMENTED_PDUS, sizeof(mesh_segmented_pdu_t)); 1592f7434c1fSMatthias Ringwald #endif 1593491f99b3SMatthias Ringwald #if MAX_NR_MESH_UPPER_TRANSPORT_PDUS > 0 1594491f99b3SMatthias 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)); 1595491f99b3SMatthias Ringwald #endif 159650dc57fcSMatthias Ringwald #if MAX_NR_MESH_NETWORK_KEYS > 0 159750dc57fcSMatthias Ringwald btstack_memory_pool_create(&mesh_network_key_pool, mesh_network_key_storage, MAX_NR_MESH_NETWORK_KEYS, sizeof(mesh_network_key_t)); 1598c0a711d9SMatthias Ringwald #endif 159901e2bf94SMatthias Ringwald #if MAX_NR_MESH_TRANSPORT_KEYS > 0 160001e2bf94SMatthias Ringwald btstack_memory_pool_create(&mesh_transport_key_pool, mesh_transport_key_storage, MAX_NR_MESH_TRANSPORT_KEYS, sizeof(mesh_transport_key_t)); 160101e2bf94SMatthias Ringwald #endif 16021f45d603SMatthias Ringwald #if MAX_NR_MESH_VIRTUAL_ADDRESSS > 0 16031f45d603SMatthias Ringwald btstack_memory_pool_create(&mesh_virtual_address_pool, mesh_virtual_address_storage, MAX_NR_MESH_VIRTUAL_ADDRESSS, sizeof(mesh_virtual_address_t)); 16041f45d603SMatthias Ringwald #endif 160501122b73SMatthias Ringwald #if MAX_NR_MESH_SUBNETS > 0 160601122b73SMatthias Ringwald btstack_memory_pool_create(&mesh_subnet_pool, mesh_subnet_storage, MAX_NR_MESH_SUBNETS, sizeof(mesh_subnet_t)); 160701122b73SMatthias Ringwald #endif 1608a7d12effS[email protected] #endif 1609a3b02b71Smatthias.ringwald } 1610