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; 65b6269742SMatthias Ringwald 66*2a95308bSMatthias Ringwald static void btstack_memory_tracking_add(btstack_memory_buffer_t * buffer){ 67*2a95308bSMatthias Ringwald btstack_assert(buffer != NULL); 68*2a95308bSMatthias Ringwald btstack_memory_malloc_buffers = buffer; 69b6269742SMatthias Ringwald buffer->prev = NULL; 70b6269742SMatthias Ringwald buffer->next = btstack_memory_malloc_buffers; 71b6269742SMatthias Ringwald btstack_memory_malloc_buffers = buffer; 72b6269742SMatthias Ringwald } 73b6269742SMatthias Ringwald 74*2a95308bSMatthias Ringwald static void btstack_memory_tracking_remove(btstack_memory_buffer_t * buffer){ 75*2a95308bSMatthias Ringwald btstack_assert(buffer != NULL); 76b6269742SMatthias Ringwald if (buffer->prev == NULL){ 77b6269742SMatthias Ringwald // first item 78b6269742SMatthias Ringwald btstack_memory_malloc_buffers = buffer->next; 79b6269742SMatthias Ringwald } else { 80b6269742SMatthias Ringwald buffer->prev->next = buffer->next; 81b6269742SMatthias Ringwald } 82b6269742SMatthias Ringwald if (buffer->next != NULL){ 83b6269742SMatthias Ringwald buffer->next->prev = buffer->prev; 84b6269742SMatthias Ringwald } 85b6269742SMatthias Ringwald } 86b6269742SMatthias Ringwald #endif 87b6269742SMatthias Ringwald 88b6269742SMatthias Ringwald void btstack_memory_deinit(void){ 89b6269742SMatthias Ringwald #ifdef HAVE_MALLOC 90b6269742SMatthias Ringwald while (btstack_memory_malloc_buffers != NULL){ 91b6269742SMatthias Ringwald btstack_memory_buffer_t * buffer = btstack_memory_malloc_buffers; 92b6269742SMatthias Ringwald btstack_memory_malloc_buffers = buffer->next; 93b6269742SMatthias Ringwald free(buffer); 94b6269742SMatthias Ringwald } 95b6269742SMatthias Ringwald #endif 96b6269742SMatthias Ringwald } 97a3b02b71Smatthias.ringwald 982e97c149S[email protected] 99a3b02b71Smatthias.ringwald // MARK: hci_connection_t 100a265b909SMatthias Ringwald #if !defined(HAVE_MALLOC) && !defined(MAX_NR_HCI_CONNECTIONS) 101a265b909SMatthias Ringwald #if defined(MAX_NO_HCI_CONNECTIONS) 10227faf85aSMilanka 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." 103a265b909SMatthias Ringwald #else 104a265b909SMatthias Ringwald #define MAX_NR_HCI_CONNECTIONS 0 105a265b909SMatthias Ringwald #endif 106a265b909SMatthias Ringwald #endif 107a265b909SMatthias Ringwald 108a265b909SMatthias Ringwald #ifdef MAX_NR_HCI_CONNECTIONS 109a265b909SMatthias Ringwald #if MAX_NR_HCI_CONNECTIONS > 0 110a265b909SMatthias Ringwald static hci_connection_t hci_connection_storage[MAX_NR_HCI_CONNECTIONS]; 11129d0c4f7SMatthias Ringwald static btstack_memory_pool_t hci_connection_pool; 1126527a633S[email protected] hci_connection_t * btstack_memory_hci_connection_get(void){ 113a2673d88SMatthias Ringwald void * buffer = btstack_memory_pool_get(&hci_connection_pool); 114a2673d88SMatthias Ringwald if (buffer){ 115a2673d88SMatthias Ringwald memset(buffer, 0, sizeof(hci_connection_t)); 116a2673d88SMatthias Ringwald } 117a2673d88SMatthias Ringwald return (hci_connection_t *) buffer; 118a3b02b71Smatthias.ringwald } 1196527a633S[email protected] void btstack_memory_hci_connection_free(hci_connection_t *hci_connection){ 12029d0c4f7SMatthias Ringwald btstack_memory_pool_free(&hci_connection_pool, hci_connection); 121a3b02b71Smatthias.ringwald } 122c4d3f927Smatthias.ringwald #else 1236527a633S[email protected] hci_connection_t * btstack_memory_hci_connection_get(void){ 124c4d3f927Smatthias.ringwald return NULL; 125c4d3f927Smatthias.ringwald } 1266527a633S[email protected] void btstack_memory_hci_connection_free(hci_connection_t *hci_connection){ 127b6269742SMatthias Ringwald UNUSED(hci_connection); 128c4d3f927Smatthias.ringwald }; 129c4d3f927Smatthias.ringwald #endif 130a3b02b71Smatthias.ringwald #elif defined(HAVE_MALLOC) 131*2a95308bSMatthias Ringwald 132*2a95308bSMatthias Ringwald typedef struct { 133*2a95308bSMatthias Ringwald hci_connection_t data; 134*2a95308bSMatthias Ringwald btstack_memory_buffer_t tracking; 135*2a95308bSMatthias Ringwald } btstack_memory_hci_connection_t; 136*2a95308bSMatthias Ringwald 1376527a633S[email protected] hci_connection_t * btstack_memory_hci_connection_get(void){ 138*2a95308bSMatthias Ringwald btstack_memory_hci_connection_t * buffer = (btstack_memory_hci_connection_t *) malloc(sizeof(btstack_memory_hci_connection_t)); 139a2673d88SMatthias Ringwald if (buffer){ 140*2a95308bSMatthias Ringwald memset(buffer, 0, sizeof(hci_connection_t)); 141*2a95308bSMatthias Ringwald btstack_memory_tracking_add(&buffer->tracking); 142*2a95308bSMatthias Ringwald return &buffer->data; 143b6269742SMatthias Ringwald } else { 144b6269742SMatthias Ringwald return NULL; 145a2673d88SMatthias Ringwald } 146a3b02b71Smatthias.ringwald } 1476527a633S[email protected] void btstack_memory_hci_connection_free(hci_connection_t *hci_connection){ 148*2a95308bSMatthias Ringwald btstack_memory_hci_connection_t * buffer = (btstack_memory_hci_connection_t *) hci_connection; 149*2a95308bSMatthias Ringwald btstack_memory_tracking_remove(&buffer->tracking); 150b6269742SMatthias Ringwald free(buffer); 151a3b02b71Smatthias.ringwald } 152a3b02b71Smatthias.ringwald #endif 153a3b02b71Smatthias.ringwald 154a3b02b71Smatthias.ringwald 1552e97c149S[email protected] 156a3b02b71Smatthias.ringwald // MARK: l2cap_service_t 157a265b909SMatthias Ringwald #if !defined(HAVE_MALLOC) && !defined(MAX_NR_L2CAP_SERVICES) 158a265b909SMatthias Ringwald #if defined(MAX_NO_L2CAP_SERVICES) 15927faf85aSMilanka 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." 160a265b909SMatthias Ringwald #else 161a265b909SMatthias Ringwald #define MAX_NR_L2CAP_SERVICES 0 162a265b909SMatthias Ringwald #endif 163a265b909SMatthias Ringwald #endif 164a265b909SMatthias Ringwald 165a265b909SMatthias Ringwald #ifdef MAX_NR_L2CAP_SERVICES 166a265b909SMatthias Ringwald #if MAX_NR_L2CAP_SERVICES > 0 167a265b909SMatthias Ringwald static l2cap_service_t l2cap_service_storage[MAX_NR_L2CAP_SERVICES]; 16829d0c4f7SMatthias Ringwald static btstack_memory_pool_t l2cap_service_pool; 1696527a633S[email protected] l2cap_service_t * btstack_memory_l2cap_service_get(void){ 170a2673d88SMatthias Ringwald void * buffer = btstack_memory_pool_get(&l2cap_service_pool); 171a2673d88SMatthias Ringwald if (buffer){ 172a2673d88SMatthias Ringwald memset(buffer, 0, sizeof(l2cap_service_t)); 173a2673d88SMatthias Ringwald } 174a2673d88SMatthias Ringwald return (l2cap_service_t *) buffer; 175a3b02b71Smatthias.ringwald } 1766527a633S[email protected] void btstack_memory_l2cap_service_free(l2cap_service_t *l2cap_service){ 17729d0c4f7SMatthias Ringwald btstack_memory_pool_free(&l2cap_service_pool, l2cap_service); 178a3b02b71Smatthias.ringwald } 179c4d3f927Smatthias.ringwald #else 1806527a633S[email protected] l2cap_service_t * btstack_memory_l2cap_service_get(void){ 181c4d3f927Smatthias.ringwald return NULL; 182c4d3f927Smatthias.ringwald } 1836527a633S[email protected] void btstack_memory_l2cap_service_free(l2cap_service_t *l2cap_service){ 184b6269742SMatthias Ringwald UNUSED(l2cap_service); 185c4d3f927Smatthias.ringwald }; 186c4d3f927Smatthias.ringwald #endif 187a3b02b71Smatthias.ringwald #elif defined(HAVE_MALLOC) 188*2a95308bSMatthias Ringwald 189*2a95308bSMatthias Ringwald typedef struct { 190*2a95308bSMatthias Ringwald l2cap_service_t data; 191*2a95308bSMatthias Ringwald btstack_memory_buffer_t tracking; 192*2a95308bSMatthias Ringwald } btstack_memory_l2cap_service_t; 193*2a95308bSMatthias Ringwald 1946527a633S[email protected] l2cap_service_t * btstack_memory_l2cap_service_get(void){ 195*2a95308bSMatthias Ringwald btstack_memory_l2cap_service_t * buffer = (btstack_memory_l2cap_service_t *) malloc(sizeof(btstack_memory_l2cap_service_t)); 196a2673d88SMatthias Ringwald if (buffer){ 197*2a95308bSMatthias Ringwald memset(buffer, 0, sizeof(l2cap_service_t)); 198*2a95308bSMatthias Ringwald btstack_memory_tracking_add(&buffer->tracking); 199*2a95308bSMatthias Ringwald return &buffer->data; 200b6269742SMatthias Ringwald } else { 201b6269742SMatthias Ringwald return NULL; 202a2673d88SMatthias Ringwald } 203a3b02b71Smatthias.ringwald } 2046527a633S[email protected] void btstack_memory_l2cap_service_free(l2cap_service_t *l2cap_service){ 205*2a95308bSMatthias Ringwald btstack_memory_l2cap_service_t * buffer = (btstack_memory_l2cap_service_t *) l2cap_service; 206*2a95308bSMatthias Ringwald btstack_memory_tracking_remove(&buffer->tracking); 207b6269742SMatthias Ringwald free(buffer); 208a3b02b71Smatthias.ringwald } 209a3b02b71Smatthias.ringwald #endif 210a3b02b71Smatthias.ringwald 211a3b02b71Smatthias.ringwald 212a3b02b71Smatthias.ringwald // MARK: l2cap_channel_t 213a265b909SMatthias Ringwald #if !defined(HAVE_MALLOC) && !defined(MAX_NR_L2CAP_CHANNELS) 214a265b909SMatthias Ringwald #if defined(MAX_NO_L2CAP_CHANNELS) 21527faf85aSMilanka 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." 216a265b909SMatthias Ringwald #else 217a265b909SMatthias Ringwald #define MAX_NR_L2CAP_CHANNELS 0 218a265b909SMatthias Ringwald #endif 219a265b909SMatthias Ringwald #endif 220a265b909SMatthias Ringwald 221a265b909SMatthias Ringwald #ifdef MAX_NR_L2CAP_CHANNELS 222a265b909SMatthias Ringwald #if MAX_NR_L2CAP_CHANNELS > 0 223a265b909SMatthias Ringwald static l2cap_channel_t l2cap_channel_storage[MAX_NR_L2CAP_CHANNELS]; 22429d0c4f7SMatthias Ringwald static btstack_memory_pool_t l2cap_channel_pool; 2256527a633S[email protected] l2cap_channel_t * btstack_memory_l2cap_channel_get(void){ 226a2673d88SMatthias Ringwald void * buffer = btstack_memory_pool_get(&l2cap_channel_pool); 227a2673d88SMatthias Ringwald if (buffer){ 228a2673d88SMatthias Ringwald memset(buffer, 0, sizeof(l2cap_channel_t)); 229a2673d88SMatthias Ringwald } 230a2673d88SMatthias Ringwald return (l2cap_channel_t *) buffer; 231a3b02b71Smatthias.ringwald } 2326527a633S[email protected] void btstack_memory_l2cap_channel_free(l2cap_channel_t *l2cap_channel){ 23329d0c4f7SMatthias Ringwald btstack_memory_pool_free(&l2cap_channel_pool, l2cap_channel); 234a3b02b71Smatthias.ringwald } 235c4d3f927Smatthias.ringwald #else 2366527a633S[email protected] l2cap_channel_t * btstack_memory_l2cap_channel_get(void){ 237c4d3f927Smatthias.ringwald return NULL; 238c4d3f927Smatthias.ringwald } 2396527a633S[email protected] void btstack_memory_l2cap_channel_free(l2cap_channel_t *l2cap_channel){ 240b6269742SMatthias Ringwald UNUSED(l2cap_channel); 241c4d3f927Smatthias.ringwald }; 242c4d3f927Smatthias.ringwald #endif 243a3b02b71Smatthias.ringwald #elif defined(HAVE_MALLOC) 244*2a95308bSMatthias Ringwald 245*2a95308bSMatthias Ringwald typedef struct { 246*2a95308bSMatthias Ringwald l2cap_channel_t data; 247*2a95308bSMatthias Ringwald btstack_memory_buffer_t tracking; 248*2a95308bSMatthias Ringwald } btstack_memory_l2cap_channel_t; 249*2a95308bSMatthias Ringwald 2506527a633S[email protected] l2cap_channel_t * btstack_memory_l2cap_channel_get(void){ 251*2a95308bSMatthias Ringwald btstack_memory_l2cap_channel_t * buffer = (btstack_memory_l2cap_channel_t *) malloc(sizeof(btstack_memory_l2cap_channel_t)); 252a2673d88SMatthias Ringwald if (buffer){ 253*2a95308bSMatthias Ringwald memset(buffer, 0, sizeof(l2cap_channel_t)); 254*2a95308bSMatthias Ringwald btstack_memory_tracking_add(&buffer->tracking); 255*2a95308bSMatthias Ringwald return &buffer->data; 256b6269742SMatthias Ringwald } else { 257b6269742SMatthias Ringwald return NULL; 258a2673d88SMatthias Ringwald } 259a3b02b71Smatthias.ringwald } 2606527a633S[email protected] void btstack_memory_l2cap_channel_free(l2cap_channel_t *l2cap_channel){ 261*2a95308bSMatthias Ringwald btstack_memory_l2cap_channel_t * buffer = (btstack_memory_l2cap_channel_t *) l2cap_channel; 262*2a95308bSMatthias Ringwald btstack_memory_tracking_remove(&buffer->tracking); 263b6269742SMatthias Ringwald free(buffer); 264a3b02b71Smatthias.ringwald } 265a3b02b71Smatthias.ringwald #endif 266a3b02b71Smatthias.ringwald 267a3b02b71Smatthias.ringwald 26844c5d856SMatthias Ringwald #ifdef ENABLE_CLASSIC 2692e97c149S[email protected] 270a3b02b71Smatthias.ringwald // MARK: rfcomm_multiplexer_t 271a265b909SMatthias Ringwald #if !defined(HAVE_MALLOC) && !defined(MAX_NR_RFCOMM_MULTIPLEXERS) 272a265b909SMatthias Ringwald #if defined(MAX_NO_RFCOMM_MULTIPLEXERS) 27327faf85aSMilanka 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." 274a265b909SMatthias Ringwald #else 275a265b909SMatthias Ringwald #define MAX_NR_RFCOMM_MULTIPLEXERS 0 276a265b909SMatthias Ringwald #endif 277a265b909SMatthias Ringwald #endif 278a265b909SMatthias Ringwald 279a265b909SMatthias Ringwald #ifdef MAX_NR_RFCOMM_MULTIPLEXERS 280a265b909SMatthias Ringwald #if MAX_NR_RFCOMM_MULTIPLEXERS > 0 281a265b909SMatthias Ringwald static rfcomm_multiplexer_t rfcomm_multiplexer_storage[MAX_NR_RFCOMM_MULTIPLEXERS]; 28229d0c4f7SMatthias Ringwald static btstack_memory_pool_t rfcomm_multiplexer_pool; 2836527a633S[email protected] rfcomm_multiplexer_t * btstack_memory_rfcomm_multiplexer_get(void){ 284a2673d88SMatthias Ringwald void * buffer = btstack_memory_pool_get(&rfcomm_multiplexer_pool); 285a2673d88SMatthias Ringwald if (buffer){ 286a2673d88SMatthias Ringwald memset(buffer, 0, sizeof(rfcomm_multiplexer_t)); 287a2673d88SMatthias Ringwald } 288a2673d88SMatthias Ringwald return (rfcomm_multiplexer_t *) buffer; 289a3b02b71Smatthias.ringwald } 2906527a633S[email protected] void btstack_memory_rfcomm_multiplexer_free(rfcomm_multiplexer_t *rfcomm_multiplexer){ 29129d0c4f7SMatthias Ringwald btstack_memory_pool_free(&rfcomm_multiplexer_pool, rfcomm_multiplexer); 292a3b02b71Smatthias.ringwald } 293c4d3f927Smatthias.ringwald #else 2946527a633S[email protected] rfcomm_multiplexer_t * btstack_memory_rfcomm_multiplexer_get(void){ 295c4d3f927Smatthias.ringwald return NULL; 296c4d3f927Smatthias.ringwald } 2976527a633S[email protected] void btstack_memory_rfcomm_multiplexer_free(rfcomm_multiplexer_t *rfcomm_multiplexer){ 298b6269742SMatthias Ringwald UNUSED(rfcomm_multiplexer); 299c4d3f927Smatthias.ringwald }; 300c4d3f927Smatthias.ringwald #endif 301a3b02b71Smatthias.ringwald #elif defined(HAVE_MALLOC) 302*2a95308bSMatthias Ringwald 303*2a95308bSMatthias Ringwald typedef struct { 304*2a95308bSMatthias Ringwald rfcomm_multiplexer_t data; 305*2a95308bSMatthias Ringwald btstack_memory_buffer_t tracking; 306*2a95308bSMatthias Ringwald } btstack_memory_rfcomm_multiplexer_t; 307*2a95308bSMatthias Ringwald 3086527a633S[email protected] rfcomm_multiplexer_t * btstack_memory_rfcomm_multiplexer_get(void){ 309*2a95308bSMatthias Ringwald btstack_memory_rfcomm_multiplexer_t * buffer = (btstack_memory_rfcomm_multiplexer_t *) malloc(sizeof(btstack_memory_rfcomm_multiplexer_t)); 310a2673d88SMatthias Ringwald if (buffer){ 311*2a95308bSMatthias Ringwald memset(buffer, 0, sizeof(rfcomm_multiplexer_t)); 312*2a95308bSMatthias Ringwald btstack_memory_tracking_add(&buffer->tracking); 313*2a95308bSMatthias Ringwald return &buffer->data; 314b6269742SMatthias Ringwald } else { 315b6269742SMatthias Ringwald return NULL; 316a2673d88SMatthias Ringwald } 317a3b02b71Smatthias.ringwald } 3186527a633S[email protected] void btstack_memory_rfcomm_multiplexer_free(rfcomm_multiplexer_t *rfcomm_multiplexer){ 319*2a95308bSMatthias Ringwald btstack_memory_rfcomm_multiplexer_t * buffer = (btstack_memory_rfcomm_multiplexer_t *) rfcomm_multiplexer; 320*2a95308bSMatthias Ringwald btstack_memory_tracking_remove(&buffer->tracking); 321b6269742SMatthias Ringwald free(buffer); 322a3b02b71Smatthias.ringwald } 323a3b02b71Smatthias.ringwald #endif 324a3b02b71Smatthias.ringwald 325a3b02b71Smatthias.ringwald 326a3b02b71Smatthias.ringwald // MARK: rfcomm_service_t 327a265b909SMatthias Ringwald #if !defined(HAVE_MALLOC) && !defined(MAX_NR_RFCOMM_SERVICES) 328a265b909SMatthias Ringwald #if defined(MAX_NO_RFCOMM_SERVICES) 32927faf85aSMilanka 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." 330a265b909SMatthias Ringwald #else 331a265b909SMatthias Ringwald #define MAX_NR_RFCOMM_SERVICES 0 332a265b909SMatthias Ringwald #endif 333a265b909SMatthias Ringwald #endif 334a265b909SMatthias Ringwald 335a265b909SMatthias Ringwald #ifdef MAX_NR_RFCOMM_SERVICES 336a265b909SMatthias Ringwald #if MAX_NR_RFCOMM_SERVICES > 0 337a265b909SMatthias Ringwald static rfcomm_service_t rfcomm_service_storage[MAX_NR_RFCOMM_SERVICES]; 33829d0c4f7SMatthias Ringwald static btstack_memory_pool_t rfcomm_service_pool; 3396527a633S[email protected] rfcomm_service_t * btstack_memory_rfcomm_service_get(void){ 340a2673d88SMatthias Ringwald void * buffer = btstack_memory_pool_get(&rfcomm_service_pool); 341a2673d88SMatthias Ringwald if (buffer){ 342a2673d88SMatthias Ringwald memset(buffer, 0, sizeof(rfcomm_service_t)); 343a2673d88SMatthias Ringwald } 344a2673d88SMatthias Ringwald return (rfcomm_service_t *) buffer; 345a3b02b71Smatthias.ringwald } 3466527a633S[email protected] void btstack_memory_rfcomm_service_free(rfcomm_service_t *rfcomm_service){ 34729d0c4f7SMatthias Ringwald btstack_memory_pool_free(&rfcomm_service_pool, rfcomm_service); 348a3b02b71Smatthias.ringwald } 349c4d3f927Smatthias.ringwald #else 3506527a633S[email protected] rfcomm_service_t * btstack_memory_rfcomm_service_get(void){ 351c4d3f927Smatthias.ringwald return NULL; 352c4d3f927Smatthias.ringwald } 3536527a633S[email protected] void btstack_memory_rfcomm_service_free(rfcomm_service_t *rfcomm_service){ 354b6269742SMatthias Ringwald UNUSED(rfcomm_service); 355c4d3f927Smatthias.ringwald }; 356c4d3f927Smatthias.ringwald #endif 357a3b02b71Smatthias.ringwald #elif defined(HAVE_MALLOC) 358*2a95308bSMatthias Ringwald 359*2a95308bSMatthias Ringwald typedef struct { 360*2a95308bSMatthias Ringwald rfcomm_service_t data; 361*2a95308bSMatthias Ringwald btstack_memory_buffer_t tracking; 362*2a95308bSMatthias Ringwald } btstack_memory_rfcomm_service_t; 363*2a95308bSMatthias Ringwald 3646527a633S[email protected] rfcomm_service_t * btstack_memory_rfcomm_service_get(void){ 365*2a95308bSMatthias Ringwald btstack_memory_rfcomm_service_t * buffer = (btstack_memory_rfcomm_service_t *) malloc(sizeof(btstack_memory_rfcomm_service_t)); 366a2673d88SMatthias Ringwald if (buffer){ 367*2a95308bSMatthias Ringwald memset(buffer, 0, sizeof(rfcomm_service_t)); 368*2a95308bSMatthias Ringwald btstack_memory_tracking_add(&buffer->tracking); 369*2a95308bSMatthias Ringwald return &buffer->data; 370b6269742SMatthias Ringwald } else { 371b6269742SMatthias Ringwald return NULL; 372a2673d88SMatthias Ringwald } 373a3b02b71Smatthias.ringwald } 3746527a633S[email protected] void btstack_memory_rfcomm_service_free(rfcomm_service_t *rfcomm_service){ 375*2a95308bSMatthias Ringwald btstack_memory_rfcomm_service_t * buffer = (btstack_memory_rfcomm_service_t *) rfcomm_service; 376*2a95308bSMatthias Ringwald btstack_memory_tracking_remove(&buffer->tracking); 377b6269742SMatthias Ringwald free(buffer); 378a3b02b71Smatthias.ringwald } 379a3b02b71Smatthias.ringwald #endif 380a3b02b71Smatthias.ringwald 381a3b02b71Smatthias.ringwald 382a3b02b71Smatthias.ringwald // MARK: rfcomm_channel_t 383a265b909SMatthias Ringwald #if !defined(HAVE_MALLOC) && !defined(MAX_NR_RFCOMM_CHANNELS) 384a265b909SMatthias Ringwald #if defined(MAX_NO_RFCOMM_CHANNELS) 38527faf85aSMilanka 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." 386a265b909SMatthias Ringwald #else 387a265b909SMatthias Ringwald #define MAX_NR_RFCOMM_CHANNELS 0 388a265b909SMatthias Ringwald #endif 389a265b909SMatthias Ringwald #endif 390a265b909SMatthias Ringwald 391a265b909SMatthias Ringwald #ifdef MAX_NR_RFCOMM_CHANNELS 392a265b909SMatthias Ringwald #if MAX_NR_RFCOMM_CHANNELS > 0 393a265b909SMatthias Ringwald static rfcomm_channel_t rfcomm_channel_storage[MAX_NR_RFCOMM_CHANNELS]; 39429d0c4f7SMatthias Ringwald static btstack_memory_pool_t rfcomm_channel_pool; 3956527a633S[email protected] rfcomm_channel_t * btstack_memory_rfcomm_channel_get(void){ 396a2673d88SMatthias Ringwald void * buffer = btstack_memory_pool_get(&rfcomm_channel_pool); 397a2673d88SMatthias Ringwald if (buffer){ 398a2673d88SMatthias Ringwald memset(buffer, 0, sizeof(rfcomm_channel_t)); 399a2673d88SMatthias Ringwald } 400a2673d88SMatthias Ringwald return (rfcomm_channel_t *) buffer; 401a3b02b71Smatthias.ringwald } 4026527a633S[email protected] void btstack_memory_rfcomm_channel_free(rfcomm_channel_t *rfcomm_channel){ 40329d0c4f7SMatthias Ringwald btstack_memory_pool_free(&rfcomm_channel_pool, rfcomm_channel); 404a3b02b71Smatthias.ringwald } 405c4d3f927Smatthias.ringwald #else 4066527a633S[email protected] rfcomm_channel_t * btstack_memory_rfcomm_channel_get(void){ 407c4d3f927Smatthias.ringwald return NULL; 408c4d3f927Smatthias.ringwald } 4096527a633S[email protected] void btstack_memory_rfcomm_channel_free(rfcomm_channel_t *rfcomm_channel){ 410b6269742SMatthias Ringwald UNUSED(rfcomm_channel); 411c4d3f927Smatthias.ringwald }; 412c4d3f927Smatthias.ringwald #endif 413a3b02b71Smatthias.ringwald #elif defined(HAVE_MALLOC) 414*2a95308bSMatthias Ringwald 415*2a95308bSMatthias Ringwald typedef struct { 416*2a95308bSMatthias Ringwald rfcomm_channel_t data; 417*2a95308bSMatthias Ringwald btstack_memory_buffer_t tracking; 418*2a95308bSMatthias Ringwald } btstack_memory_rfcomm_channel_t; 419*2a95308bSMatthias Ringwald 4206527a633S[email protected] rfcomm_channel_t * btstack_memory_rfcomm_channel_get(void){ 421*2a95308bSMatthias Ringwald btstack_memory_rfcomm_channel_t * buffer = (btstack_memory_rfcomm_channel_t *) malloc(sizeof(btstack_memory_rfcomm_channel_t)); 422a2673d88SMatthias Ringwald if (buffer){ 423*2a95308bSMatthias Ringwald memset(buffer, 0, sizeof(rfcomm_channel_t)); 424*2a95308bSMatthias Ringwald btstack_memory_tracking_add(&buffer->tracking); 425*2a95308bSMatthias Ringwald return &buffer->data; 426b6269742SMatthias Ringwald } else { 427b6269742SMatthias Ringwald return NULL; 428a2673d88SMatthias Ringwald } 429a3b02b71Smatthias.ringwald } 4306527a633S[email protected] void btstack_memory_rfcomm_channel_free(rfcomm_channel_t *rfcomm_channel){ 431*2a95308bSMatthias Ringwald btstack_memory_rfcomm_channel_t * buffer = (btstack_memory_rfcomm_channel_t *) rfcomm_channel; 432*2a95308bSMatthias Ringwald btstack_memory_tracking_remove(&buffer->tracking); 433b6269742SMatthias Ringwald free(buffer); 434a3b02b71Smatthias.ringwald } 435a3b02b71Smatthias.ringwald #endif 436a3b02b71Smatthias.ringwald 437fdb398c2S[email protected] 438e0e5e285Smatthias.ringwald 4392c455dadSMatthias Ringwald // MARK: btstack_link_key_db_memory_entry_t 440a265b909SMatthias Ringwald #if !defined(HAVE_MALLOC) && !defined(MAX_NR_BTSTACK_LINK_KEY_DB_MEMORY_ENTRIES) 441a265b909SMatthias Ringwald #if defined(MAX_NO_BTSTACK_LINK_KEY_DB_MEMORY_ENTRIES) 44227faf85aSMilanka 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." 443a265b909SMatthias Ringwald #else 444a265b909SMatthias Ringwald #define MAX_NR_BTSTACK_LINK_KEY_DB_MEMORY_ENTRIES 0 445a265b909SMatthias Ringwald #endif 446a265b909SMatthias Ringwald #endif 447a265b909SMatthias Ringwald 448a265b909SMatthias Ringwald #ifdef MAX_NR_BTSTACK_LINK_KEY_DB_MEMORY_ENTRIES 449a265b909SMatthias Ringwald #if MAX_NR_BTSTACK_LINK_KEY_DB_MEMORY_ENTRIES > 0 450a265b909SMatthias Ringwald static btstack_link_key_db_memory_entry_t btstack_link_key_db_memory_entry_storage[MAX_NR_BTSTACK_LINK_KEY_DB_MEMORY_ENTRIES]; 4512c455dadSMatthias Ringwald static btstack_memory_pool_t btstack_link_key_db_memory_entry_pool; 4522c455dadSMatthias Ringwald btstack_link_key_db_memory_entry_t * btstack_memory_btstack_link_key_db_memory_entry_get(void){ 453a2673d88SMatthias Ringwald void * buffer = btstack_memory_pool_get(&btstack_link_key_db_memory_entry_pool); 454a2673d88SMatthias Ringwald if (buffer){ 455a2673d88SMatthias Ringwald memset(buffer, 0, sizeof(btstack_link_key_db_memory_entry_t)); 456a2673d88SMatthias Ringwald } 457a2673d88SMatthias Ringwald return (btstack_link_key_db_memory_entry_t *) buffer; 4581801b596Smatthias.ringwald } 4592c455dadSMatthias Ringwald void btstack_memory_btstack_link_key_db_memory_entry_free(btstack_link_key_db_memory_entry_t *btstack_link_key_db_memory_entry){ 4602c455dadSMatthias Ringwald btstack_memory_pool_free(&btstack_link_key_db_memory_entry_pool, btstack_link_key_db_memory_entry); 4611801b596Smatthias.ringwald } 462c4d3f927Smatthias.ringwald #else 4632c455dadSMatthias Ringwald btstack_link_key_db_memory_entry_t * btstack_memory_btstack_link_key_db_memory_entry_get(void){ 464c4d3f927Smatthias.ringwald return NULL; 465c4d3f927Smatthias.ringwald } 4662c455dadSMatthias Ringwald void btstack_memory_btstack_link_key_db_memory_entry_free(btstack_link_key_db_memory_entry_t *btstack_link_key_db_memory_entry){ 467b6269742SMatthias Ringwald UNUSED(btstack_link_key_db_memory_entry); 468c4d3f927Smatthias.ringwald }; 469c4d3f927Smatthias.ringwald #endif 4701801b596Smatthias.ringwald #elif defined(HAVE_MALLOC) 471*2a95308bSMatthias Ringwald 472*2a95308bSMatthias Ringwald typedef struct { 473*2a95308bSMatthias Ringwald btstack_link_key_db_memory_entry_t data; 474*2a95308bSMatthias Ringwald btstack_memory_buffer_t tracking; 475*2a95308bSMatthias Ringwald } btstack_memory_btstack_link_key_db_memory_entry_t; 476*2a95308bSMatthias Ringwald 4772c455dadSMatthias Ringwald btstack_link_key_db_memory_entry_t * btstack_memory_btstack_link_key_db_memory_entry_get(void){ 478*2a95308bSMatthias 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)); 479a2673d88SMatthias Ringwald if (buffer){ 480*2a95308bSMatthias Ringwald memset(buffer, 0, sizeof(btstack_link_key_db_memory_entry_t)); 481*2a95308bSMatthias Ringwald btstack_memory_tracking_add(&buffer->tracking); 482*2a95308bSMatthias Ringwald return &buffer->data; 483b6269742SMatthias Ringwald } else { 484b6269742SMatthias Ringwald return NULL; 485a2673d88SMatthias Ringwald } 4861801b596Smatthias.ringwald } 4872c455dadSMatthias Ringwald void btstack_memory_btstack_link_key_db_memory_entry_free(btstack_link_key_db_memory_entry_t *btstack_link_key_db_memory_entry){ 488*2a95308bSMatthias 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; 489*2a95308bSMatthias Ringwald btstack_memory_tracking_remove(&buffer->tracking); 490b6269742SMatthias Ringwald free(buffer); 491e0e5e285Smatthias.ringwald } 4921801b596Smatthias.ringwald #endif 4931801b596Smatthias.ringwald 4942e97c149S[email protected] 4952e97c149S[email protected] 4962e97c149S[email protected] // MARK: bnep_service_t 497a265b909SMatthias Ringwald #if !defined(HAVE_MALLOC) && !defined(MAX_NR_BNEP_SERVICES) 498a265b909SMatthias Ringwald #if defined(MAX_NO_BNEP_SERVICES) 49927faf85aSMilanka 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." 500a265b909SMatthias Ringwald #else 501a265b909SMatthias Ringwald #define MAX_NR_BNEP_SERVICES 0 502a265b909SMatthias Ringwald #endif 503a265b909SMatthias Ringwald #endif 504a265b909SMatthias Ringwald 505a265b909SMatthias Ringwald #ifdef MAX_NR_BNEP_SERVICES 506a265b909SMatthias Ringwald #if MAX_NR_BNEP_SERVICES > 0 507a265b909SMatthias Ringwald static bnep_service_t bnep_service_storage[MAX_NR_BNEP_SERVICES]; 50829d0c4f7SMatthias Ringwald static btstack_memory_pool_t bnep_service_pool; 5092e97c149S[email protected] bnep_service_t * btstack_memory_bnep_service_get(void){ 510a2673d88SMatthias Ringwald void * buffer = btstack_memory_pool_get(&bnep_service_pool); 511a2673d88SMatthias Ringwald if (buffer){ 512a2673d88SMatthias Ringwald memset(buffer, 0, sizeof(bnep_service_t)); 513a2673d88SMatthias Ringwald } 514a2673d88SMatthias Ringwald return (bnep_service_t *) buffer; 5152e97c149S[email protected] } 5162e97c149S[email protected] void btstack_memory_bnep_service_free(bnep_service_t *bnep_service){ 51729d0c4f7SMatthias Ringwald btstack_memory_pool_free(&bnep_service_pool, bnep_service); 5182e97c149S[email protected] } 5192e97c149S[email protected] #else 5202e97c149S[email protected] bnep_service_t * btstack_memory_bnep_service_get(void){ 5212e97c149S[email protected] return NULL; 5222e97c149S[email protected] } 5232e97c149S[email protected] void btstack_memory_bnep_service_free(bnep_service_t *bnep_service){ 524b6269742SMatthias Ringwald UNUSED(bnep_service); 5252e97c149S[email protected] }; 5262e97c149S[email protected] #endif 5272e97c149S[email protected] #elif defined(HAVE_MALLOC) 528*2a95308bSMatthias Ringwald 529*2a95308bSMatthias Ringwald typedef struct { 530*2a95308bSMatthias Ringwald bnep_service_t data; 531*2a95308bSMatthias Ringwald btstack_memory_buffer_t tracking; 532*2a95308bSMatthias Ringwald } btstack_memory_bnep_service_t; 533*2a95308bSMatthias Ringwald 5342e97c149S[email protected] bnep_service_t * btstack_memory_bnep_service_get(void){ 535*2a95308bSMatthias Ringwald btstack_memory_bnep_service_t * buffer = (btstack_memory_bnep_service_t *) malloc(sizeof(btstack_memory_bnep_service_t)); 536a2673d88SMatthias Ringwald if (buffer){ 537*2a95308bSMatthias Ringwald memset(buffer, 0, sizeof(bnep_service_t)); 538*2a95308bSMatthias Ringwald btstack_memory_tracking_add(&buffer->tracking); 539*2a95308bSMatthias Ringwald return &buffer->data; 540b6269742SMatthias Ringwald } else { 541b6269742SMatthias Ringwald return NULL; 542a2673d88SMatthias Ringwald } 5432e97c149S[email protected] } 5442e97c149S[email protected] void btstack_memory_bnep_service_free(bnep_service_t *bnep_service){ 545*2a95308bSMatthias Ringwald btstack_memory_bnep_service_t * buffer = (btstack_memory_bnep_service_t *) bnep_service; 546*2a95308bSMatthias Ringwald btstack_memory_tracking_remove(&buffer->tracking); 547b6269742SMatthias Ringwald free(buffer); 5482e97c149S[email protected] } 5492e97c149S[email protected] #endif 5502e97c149S[email protected] 5512e97c149S[email protected] 5522e97c149S[email protected] // MARK: bnep_channel_t 553a265b909SMatthias Ringwald #if !defined(HAVE_MALLOC) && !defined(MAX_NR_BNEP_CHANNELS) 554a265b909SMatthias Ringwald #if defined(MAX_NO_BNEP_CHANNELS) 55527faf85aSMilanka 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." 556a265b909SMatthias Ringwald #else 557a265b909SMatthias Ringwald #define MAX_NR_BNEP_CHANNELS 0 558a265b909SMatthias Ringwald #endif 559a265b909SMatthias Ringwald #endif 560a265b909SMatthias Ringwald 561a265b909SMatthias Ringwald #ifdef MAX_NR_BNEP_CHANNELS 562a265b909SMatthias Ringwald #if MAX_NR_BNEP_CHANNELS > 0 563a265b909SMatthias Ringwald static bnep_channel_t bnep_channel_storage[MAX_NR_BNEP_CHANNELS]; 56429d0c4f7SMatthias Ringwald static btstack_memory_pool_t bnep_channel_pool; 5652e97c149S[email protected] bnep_channel_t * btstack_memory_bnep_channel_get(void){ 566a2673d88SMatthias Ringwald void * buffer = btstack_memory_pool_get(&bnep_channel_pool); 567a2673d88SMatthias Ringwald if (buffer){ 568a2673d88SMatthias Ringwald memset(buffer, 0, sizeof(bnep_channel_t)); 569a2673d88SMatthias Ringwald } 570a2673d88SMatthias Ringwald return (bnep_channel_t *) buffer; 5712e97c149S[email protected] } 5722e97c149S[email protected] void btstack_memory_bnep_channel_free(bnep_channel_t *bnep_channel){ 57329d0c4f7SMatthias Ringwald btstack_memory_pool_free(&bnep_channel_pool, bnep_channel); 5742e97c149S[email protected] } 5752e97c149S[email protected] #else 5762e97c149S[email protected] bnep_channel_t * btstack_memory_bnep_channel_get(void){ 5772e97c149S[email protected] return NULL; 5782e97c149S[email protected] } 5792e97c149S[email protected] void btstack_memory_bnep_channel_free(bnep_channel_t *bnep_channel){ 580b6269742SMatthias Ringwald UNUSED(bnep_channel); 5812e97c149S[email protected] }; 5822e97c149S[email protected] #endif 5832e97c149S[email protected] #elif defined(HAVE_MALLOC) 584*2a95308bSMatthias Ringwald 585*2a95308bSMatthias Ringwald typedef struct { 586*2a95308bSMatthias Ringwald bnep_channel_t data; 587*2a95308bSMatthias Ringwald btstack_memory_buffer_t tracking; 588*2a95308bSMatthias Ringwald } btstack_memory_bnep_channel_t; 589*2a95308bSMatthias Ringwald 5902e97c149S[email protected] bnep_channel_t * btstack_memory_bnep_channel_get(void){ 591*2a95308bSMatthias Ringwald btstack_memory_bnep_channel_t * buffer = (btstack_memory_bnep_channel_t *) malloc(sizeof(btstack_memory_bnep_channel_t)); 592a2673d88SMatthias Ringwald if (buffer){ 593*2a95308bSMatthias Ringwald memset(buffer, 0, sizeof(bnep_channel_t)); 594*2a95308bSMatthias Ringwald btstack_memory_tracking_add(&buffer->tracking); 595*2a95308bSMatthias Ringwald return &buffer->data; 596b6269742SMatthias Ringwald } else { 597b6269742SMatthias Ringwald return NULL; 598a2673d88SMatthias Ringwald } 5992e97c149S[email protected] } 6002e97c149S[email protected] void btstack_memory_bnep_channel_free(bnep_channel_t *bnep_channel){ 601*2a95308bSMatthias Ringwald btstack_memory_bnep_channel_t * buffer = (btstack_memory_bnep_channel_t *) bnep_channel; 602*2a95308bSMatthias Ringwald btstack_memory_tracking_remove(&buffer->tracking); 603b6269742SMatthias Ringwald free(buffer); 6042e97c149S[email protected] } 6052e97c149S[email protected] #endif 6062e97c149S[email protected] 6072e97c149S[email protected] 608ea5029c9SMilanka Ringwald 609ea5029c9SMilanka Ringwald // MARK: hfp_connection_t 610a265b909SMatthias Ringwald #if !defined(HAVE_MALLOC) && !defined(MAX_NR_HFP_CONNECTIONS) 611a265b909SMatthias Ringwald #if defined(MAX_NO_HFP_CONNECTIONS) 61227faf85aSMilanka 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." 613a265b909SMatthias Ringwald #else 614a265b909SMatthias Ringwald #define MAX_NR_HFP_CONNECTIONS 0 615a265b909SMatthias Ringwald #endif 616a265b909SMatthias Ringwald #endif 617a265b909SMatthias Ringwald 618a265b909SMatthias Ringwald #ifdef MAX_NR_HFP_CONNECTIONS 619a265b909SMatthias Ringwald #if MAX_NR_HFP_CONNECTIONS > 0 620a265b909SMatthias Ringwald static hfp_connection_t hfp_connection_storage[MAX_NR_HFP_CONNECTIONS]; 62129d0c4f7SMatthias Ringwald static btstack_memory_pool_t hfp_connection_pool; 622ea5029c9SMilanka Ringwald hfp_connection_t * btstack_memory_hfp_connection_get(void){ 623a2673d88SMatthias Ringwald void * buffer = btstack_memory_pool_get(&hfp_connection_pool); 624a2673d88SMatthias Ringwald if (buffer){ 625a2673d88SMatthias Ringwald memset(buffer, 0, sizeof(hfp_connection_t)); 626a2673d88SMatthias Ringwald } 627a2673d88SMatthias Ringwald return (hfp_connection_t *) buffer; 628ea5029c9SMilanka Ringwald } 629ea5029c9SMilanka Ringwald void btstack_memory_hfp_connection_free(hfp_connection_t *hfp_connection){ 63029d0c4f7SMatthias Ringwald btstack_memory_pool_free(&hfp_connection_pool, hfp_connection); 631ea5029c9SMilanka Ringwald } 632ea5029c9SMilanka Ringwald #else 633ea5029c9SMilanka Ringwald hfp_connection_t * btstack_memory_hfp_connection_get(void){ 634ea5029c9SMilanka Ringwald return NULL; 635ea5029c9SMilanka Ringwald } 636ea5029c9SMilanka Ringwald void btstack_memory_hfp_connection_free(hfp_connection_t *hfp_connection){ 637b6269742SMatthias Ringwald UNUSED(hfp_connection); 638ea5029c9SMilanka Ringwald }; 639ea5029c9SMilanka Ringwald #endif 640ea5029c9SMilanka Ringwald #elif defined(HAVE_MALLOC) 641*2a95308bSMatthias Ringwald 642*2a95308bSMatthias Ringwald typedef struct { 643*2a95308bSMatthias Ringwald hfp_connection_t data; 644*2a95308bSMatthias Ringwald btstack_memory_buffer_t tracking; 645*2a95308bSMatthias Ringwald } btstack_memory_hfp_connection_t; 646*2a95308bSMatthias Ringwald 647ea5029c9SMilanka Ringwald hfp_connection_t * btstack_memory_hfp_connection_get(void){ 648*2a95308bSMatthias Ringwald btstack_memory_hfp_connection_t * buffer = (btstack_memory_hfp_connection_t *) malloc(sizeof(btstack_memory_hfp_connection_t)); 649a2673d88SMatthias Ringwald if (buffer){ 650*2a95308bSMatthias Ringwald memset(buffer, 0, sizeof(hfp_connection_t)); 651*2a95308bSMatthias Ringwald btstack_memory_tracking_add(&buffer->tracking); 652*2a95308bSMatthias Ringwald return &buffer->data; 653b6269742SMatthias Ringwald } else { 654b6269742SMatthias Ringwald return NULL; 655a2673d88SMatthias Ringwald } 656ea5029c9SMilanka Ringwald } 657ea5029c9SMilanka Ringwald void btstack_memory_hfp_connection_free(hfp_connection_t *hfp_connection){ 658*2a95308bSMatthias Ringwald btstack_memory_hfp_connection_t * buffer = (btstack_memory_hfp_connection_t *) hfp_connection; 659*2a95308bSMatthias Ringwald btstack_memory_tracking_remove(&buffer->tracking); 660b6269742SMatthias Ringwald free(buffer); 661ea5029c9SMilanka Ringwald } 662ea5029c9SMilanka Ringwald #endif 663ea5029c9SMilanka Ringwald 664ea5029c9SMilanka Ringwald 665cd9ee144SMatthias Ringwald 666cd9ee144SMatthias Ringwald // MARK: service_record_item_t 667a265b909SMatthias Ringwald #if !defined(HAVE_MALLOC) && !defined(MAX_NR_SERVICE_RECORD_ITEMS) 668a265b909SMatthias Ringwald #if defined(MAX_NO_SERVICE_RECORD_ITEMS) 66927faf85aSMilanka 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." 670a265b909SMatthias Ringwald #else 671a265b909SMatthias Ringwald #define MAX_NR_SERVICE_RECORD_ITEMS 0 672a265b909SMatthias Ringwald #endif 673a265b909SMatthias Ringwald #endif 674a265b909SMatthias Ringwald 675a265b909SMatthias Ringwald #ifdef MAX_NR_SERVICE_RECORD_ITEMS 676a265b909SMatthias Ringwald #if MAX_NR_SERVICE_RECORD_ITEMS > 0 677a265b909SMatthias Ringwald static service_record_item_t service_record_item_storage[MAX_NR_SERVICE_RECORD_ITEMS]; 67829d0c4f7SMatthias Ringwald static btstack_memory_pool_t service_record_item_pool; 679cd9ee144SMatthias Ringwald service_record_item_t * btstack_memory_service_record_item_get(void){ 680a2673d88SMatthias Ringwald void * buffer = btstack_memory_pool_get(&service_record_item_pool); 681a2673d88SMatthias Ringwald if (buffer){ 682a2673d88SMatthias Ringwald memset(buffer, 0, sizeof(service_record_item_t)); 683a2673d88SMatthias Ringwald } 684a2673d88SMatthias Ringwald return (service_record_item_t *) buffer; 685cd9ee144SMatthias Ringwald } 686cd9ee144SMatthias Ringwald void btstack_memory_service_record_item_free(service_record_item_t *service_record_item){ 68729d0c4f7SMatthias Ringwald btstack_memory_pool_free(&service_record_item_pool, service_record_item); 688cd9ee144SMatthias Ringwald } 689cd9ee144SMatthias Ringwald #else 690cd9ee144SMatthias Ringwald service_record_item_t * btstack_memory_service_record_item_get(void){ 691cd9ee144SMatthias Ringwald return NULL; 692cd9ee144SMatthias Ringwald } 693cd9ee144SMatthias Ringwald void btstack_memory_service_record_item_free(service_record_item_t *service_record_item){ 694b6269742SMatthias Ringwald UNUSED(service_record_item); 695cd9ee144SMatthias Ringwald }; 696cd9ee144SMatthias Ringwald #endif 697cd9ee144SMatthias Ringwald #elif defined(HAVE_MALLOC) 698*2a95308bSMatthias Ringwald 699*2a95308bSMatthias Ringwald typedef struct { 700*2a95308bSMatthias Ringwald service_record_item_t data; 701*2a95308bSMatthias Ringwald btstack_memory_buffer_t tracking; 702*2a95308bSMatthias Ringwald } btstack_memory_service_record_item_t; 703*2a95308bSMatthias Ringwald 704cd9ee144SMatthias Ringwald service_record_item_t * btstack_memory_service_record_item_get(void){ 705*2a95308bSMatthias Ringwald btstack_memory_service_record_item_t * buffer = (btstack_memory_service_record_item_t *) malloc(sizeof(btstack_memory_service_record_item_t)); 706a2673d88SMatthias Ringwald if (buffer){ 707*2a95308bSMatthias Ringwald memset(buffer, 0, sizeof(service_record_item_t)); 708*2a95308bSMatthias Ringwald btstack_memory_tracking_add(&buffer->tracking); 709*2a95308bSMatthias Ringwald return &buffer->data; 710b6269742SMatthias Ringwald } else { 711b6269742SMatthias Ringwald return NULL; 712a2673d88SMatthias Ringwald } 713cd9ee144SMatthias Ringwald } 714cd9ee144SMatthias Ringwald void btstack_memory_service_record_item_free(service_record_item_t *service_record_item){ 715*2a95308bSMatthias Ringwald btstack_memory_service_record_item_t * buffer = (btstack_memory_service_record_item_t *) service_record_item; 716*2a95308bSMatthias Ringwald btstack_memory_tracking_remove(&buffer->tracking); 717b6269742SMatthias Ringwald free(buffer); 718cd9ee144SMatthias Ringwald } 719cd9ee144SMatthias Ringwald #endif 720cd9ee144SMatthias Ringwald 721cd9ee144SMatthias Ringwald 72227faf85aSMilanka Ringwald 7230e826a17SMilanka Ringwald // MARK: avdtp_stream_endpoint_t 7240e826a17SMilanka Ringwald #if !defined(HAVE_MALLOC) && !defined(MAX_NR_AVDTP_STREAM_ENDPOINTS) 7250e826a17SMilanka Ringwald #if defined(MAX_NO_AVDTP_STREAM_ENDPOINTS) 7260e826a17SMilanka 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." 72727faf85aSMilanka Ringwald #else 7280e826a17SMilanka Ringwald #define MAX_NR_AVDTP_STREAM_ENDPOINTS 0 72927faf85aSMilanka Ringwald #endif 73027faf85aSMilanka Ringwald #endif 73127faf85aSMilanka Ringwald 7320e826a17SMilanka Ringwald #ifdef MAX_NR_AVDTP_STREAM_ENDPOINTS 7330e826a17SMilanka Ringwald #if MAX_NR_AVDTP_STREAM_ENDPOINTS > 0 7340e826a17SMilanka Ringwald static avdtp_stream_endpoint_t avdtp_stream_endpoint_storage[MAX_NR_AVDTP_STREAM_ENDPOINTS]; 7350e826a17SMilanka Ringwald static btstack_memory_pool_t avdtp_stream_endpoint_pool; 7360e826a17SMilanka Ringwald avdtp_stream_endpoint_t * btstack_memory_avdtp_stream_endpoint_get(void){ 737a2673d88SMatthias Ringwald void * buffer = btstack_memory_pool_get(&avdtp_stream_endpoint_pool); 738a2673d88SMatthias Ringwald if (buffer){ 739a2673d88SMatthias Ringwald memset(buffer, 0, sizeof(avdtp_stream_endpoint_t)); 740a2673d88SMatthias Ringwald } 741a2673d88SMatthias Ringwald return (avdtp_stream_endpoint_t *) buffer; 74227faf85aSMilanka Ringwald } 7430e826a17SMilanka Ringwald void btstack_memory_avdtp_stream_endpoint_free(avdtp_stream_endpoint_t *avdtp_stream_endpoint){ 7440e826a17SMilanka Ringwald btstack_memory_pool_free(&avdtp_stream_endpoint_pool, avdtp_stream_endpoint); 74527faf85aSMilanka Ringwald } 74627faf85aSMilanka Ringwald #else 7470e826a17SMilanka Ringwald avdtp_stream_endpoint_t * btstack_memory_avdtp_stream_endpoint_get(void){ 74827faf85aSMilanka Ringwald return NULL; 74927faf85aSMilanka Ringwald } 7500e826a17SMilanka Ringwald void btstack_memory_avdtp_stream_endpoint_free(avdtp_stream_endpoint_t *avdtp_stream_endpoint){ 751b6269742SMatthias Ringwald UNUSED(avdtp_stream_endpoint); 75227faf85aSMilanka Ringwald }; 75327faf85aSMilanka Ringwald #endif 75427faf85aSMilanka Ringwald #elif defined(HAVE_MALLOC) 755*2a95308bSMatthias Ringwald 756*2a95308bSMatthias Ringwald typedef struct { 757*2a95308bSMatthias Ringwald avdtp_stream_endpoint_t data; 758*2a95308bSMatthias Ringwald btstack_memory_buffer_t tracking; 759*2a95308bSMatthias Ringwald } btstack_memory_avdtp_stream_endpoint_t; 760*2a95308bSMatthias Ringwald 7610e826a17SMilanka Ringwald avdtp_stream_endpoint_t * btstack_memory_avdtp_stream_endpoint_get(void){ 762*2a95308bSMatthias Ringwald btstack_memory_avdtp_stream_endpoint_t * buffer = (btstack_memory_avdtp_stream_endpoint_t *) malloc(sizeof(btstack_memory_avdtp_stream_endpoint_t)); 763a2673d88SMatthias Ringwald if (buffer){ 764*2a95308bSMatthias Ringwald memset(buffer, 0, sizeof(avdtp_stream_endpoint_t)); 765*2a95308bSMatthias Ringwald btstack_memory_tracking_add(&buffer->tracking); 766*2a95308bSMatthias Ringwald return &buffer->data; 767b6269742SMatthias Ringwald } else { 768b6269742SMatthias Ringwald return NULL; 769a2673d88SMatthias Ringwald } 77027faf85aSMilanka Ringwald } 7710e826a17SMilanka Ringwald void btstack_memory_avdtp_stream_endpoint_free(avdtp_stream_endpoint_t *avdtp_stream_endpoint){ 772*2a95308bSMatthias Ringwald btstack_memory_avdtp_stream_endpoint_t * buffer = (btstack_memory_avdtp_stream_endpoint_t *) avdtp_stream_endpoint; 773*2a95308bSMatthias Ringwald btstack_memory_tracking_remove(&buffer->tracking); 774b6269742SMatthias Ringwald free(buffer); 77527faf85aSMilanka Ringwald } 77627faf85aSMilanka Ringwald #endif 77727faf85aSMilanka Ringwald 77827faf85aSMilanka Ringwald 77912e7f38cSMilanka Ringwald 78012e7f38cSMilanka Ringwald // MARK: avdtp_connection_t 78112e7f38cSMilanka Ringwald #if !defined(HAVE_MALLOC) && !defined(MAX_NR_AVDTP_CONNECTIONS) 78212e7f38cSMilanka Ringwald #if defined(MAX_NO_AVDTP_CONNECTIONS) 78312e7f38cSMilanka 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." 78412e7f38cSMilanka Ringwald #else 78512e7f38cSMilanka Ringwald #define MAX_NR_AVDTP_CONNECTIONS 0 78612e7f38cSMilanka Ringwald #endif 78712e7f38cSMilanka Ringwald #endif 78812e7f38cSMilanka Ringwald 78912e7f38cSMilanka Ringwald #ifdef MAX_NR_AVDTP_CONNECTIONS 79012e7f38cSMilanka Ringwald #if MAX_NR_AVDTP_CONNECTIONS > 0 79112e7f38cSMilanka Ringwald static avdtp_connection_t avdtp_connection_storage[MAX_NR_AVDTP_CONNECTIONS]; 79212e7f38cSMilanka Ringwald static btstack_memory_pool_t avdtp_connection_pool; 79312e7f38cSMilanka Ringwald avdtp_connection_t * btstack_memory_avdtp_connection_get(void){ 794a2673d88SMatthias Ringwald void * buffer = btstack_memory_pool_get(&avdtp_connection_pool); 795a2673d88SMatthias Ringwald if (buffer){ 796a2673d88SMatthias Ringwald memset(buffer, 0, sizeof(avdtp_connection_t)); 797a2673d88SMatthias Ringwald } 798a2673d88SMatthias Ringwald return (avdtp_connection_t *) buffer; 79912e7f38cSMilanka Ringwald } 80012e7f38cSMilanka Ringwald void btstack_memory_avdtp_connection_free(avdtp_connection_t *avdtp_connection){ 80112e7f38cSMilanka Ringwald btstack_memory_pool_free(&avdtp_connection_pool, avdtp_connection); 80212e7f38cSMilanka Ringwald } 80312e7f38cSMilanka Ringwald #else 80412e7f38cSMilanka Ringwald avdtp_connection_t * btstack_memory_avdtp_connection_get(void){ 80512e7f38cSMilanka Ringwald return NULL; 80612e7f38cSMilanka Ringwald } 80712e7f38cSMilanka Ringwald void btstack_memory_avdtp_connection_free(avdtp_connection_t *avdtp_connection){ 808b6269742SMatthias Ringwald UNUSED(avdtp_connection); 80912e7f38cSMilanka Ringwald }; 81012e7f38cSMilanka Ringwald #endif 81112e7f38cSMilanka Ringwald #elif defined(HAVE_MALLOC) 812*2a95308bSMatthias Ringwald 813*2a95308bSMatthias Ringwald typedef struct { 814*2a95308bSMatthias Ringwald avdtp_connection_t data; 815*2a95308bSMatthias Ringwald btstack_memory_buffer_t tracking; 816*2a95308bSMatthias Ringwald } btstack_memory_avdtp_connection_t; 817*2a95308bSMatthias Ringwald 81812e7f38cSMilanka Ringwald avdtp_connection_t * btstack_memory_avdtp_connection_get(void){ 819*2a95308bSMatthias Ringwald btstack_memory_avdtp_connection_t * buffer = (btstack_memory_avdtp_connection_t *) malloc(sizeof(btstack_memory_avdtp_connection_t)); 820a2673d88SMatthias Ringwald if (buffer){ 821*2a95308bSMatthias Ringwald memset(buffer, 0, sizeof(avdtp_connection_t)); 822*2a95308bSMatthias Ringwald btstack_memory_tracking_add(&buffer->tracking); 823*2a95308bSMatthias Ringwald return &buffer->data; 824b6269742SMatthias Ringwald } else { 825b6269742SMatthias Ringwald return NULL; 826a2673d88SMatthias Ringwald } 82712e7f38cSMilanka Ringwald } 82812e7f38cSMilanka Ringwald void btstack_memory_avdtp_connection_free(avdtp_connection_t *avdtp_connection){ 829*2a95308bSMatthias Ringwald btstack_memory_avdtp_connection_t * buffer = (btstack_memory_avdtp_connection_t *) avdtp_connection; 830*2a95308bSMatthias Ringwald btstack_memory_tracking_remove(&buffer->tracking); 831b6269742SMatthias Ringwald free(buffer); 83212e7f38cSMilanka Ringwald } 83312e7f38cSMilanka Ringwald #endif 83412e7f38cSMilanka Ringwald 83512e7f38cSMilanka Ringwald 83691451a2bSMilanka Ringwald 83791451a2bSMilanka Ringwald // MARK: avrcp_connection_t 83891451a2bSMilanka Ringwald #if !defined(HAVE_MALLOC) && !defined(MAX_NR_AVRCP_CONNECTIONS) 83991451a2bSMilanka Ringwald #if defined(MAX_NO_AVRCP_CONNECTIONS) 84091451a2bSMilanka 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." 84191451a2bSMilanka Ringwald #else 84291451a2bSMilanka Ringwald #define MAX_NR_AVRCP_CONNECTIONS 0 84391451a2bSMilanka Ringwald #endif 84491451a2bSMilanka Ringwald #endif 84591451a2bSMilanka Ringwald 84691451a2bSMilanka Ringwald #ifdef MAX_NR_AVRCP_CONNECTIONS 84791451a2bSMilanka Ringwald #if MAX_NR_AVRCP_CONNECTIONS > 0 84891451a2bSMilanka Ringwald static avrcp_connection_t avrcp_connection_storage[MAX_NR_AVRCP_CONNECTIONS]; 84991451a2bSMilanka Ringwald static btstack_memory_pool_t avrcp_connection_pool; 85091451a2bSMilanka Ringwald avrcp_connection_t * btstack_memory_avrcp_connection_get(void){ 851a2673d88SMatthias Ringwald void * buffer = btstack_memory_pool_get(&avrcp_connection_pool); 852a2673d88SMatthias Ringwald if (buffer){ 853a2673d88SMatthias Ringwald memset(buffer, 0, sizeof(avrcp_connection_t)); 854a2673d88SMatthias Ringwald } 855a2673d88SMatthias Ringwald return (avrcp_connection_t *) buffer; 85691451a2bSMilanka Ringwald } 85791451a2bSMilanka Ringwald void btstack_memory_avrcp_connection_free(avrcp_connection_t *avrcp_connection){ 85891451a2bSMilanka Ringwald btstack_memory_pool_free(&avrcp_connection_pool, avrcp_connection); 85991451a2bSMilanka Ringwald } 86091451a2bSMilanka Ringwald #else 86191451a2bSMilanka Ringwald avrcp_connection_t * btstack_memory_avrcp_connection_get(void){ 86291451a2bSMilanka Ringwald return NULL; 86391451a2bSMilanka Ringwald } 86491451a2bSMilanka Ringwald void btstack_memory_avrcp_connection_free(avrcp_connection_t *avrcp_connection){ 865b6269742SMatthias Ringwald UNUSED(avrcp_connection); 86691451a2bSMilanka Ringwald }; 86791451a2bSMilanka Ringwald #endif 86891451a2bSMilanka Ringwald #elif defined(HAVE_MALLOC) 869*2a95308bSMatthias Ringwald 870*2a95308bSMatthias Ringwald typedef struct { 871*2a95308bSMatthias Ringwald avrcp_connection_t data; 872*2a95308bSMatthias Ringwald btstack_memory_buffer_t tracking; 873*2a95308bSMatthias Ringwald } btstack_memory_avrcp_connection_t; 874*2a95308bSMatthias Ringwald 87591451a2bSMilanka Ringwald avrcp_connection_t * btstack_memory_avrcp_connection_get(void){ 876*2a95308bSMatthias Ringwald btstack_memory_avrcp_connection_t * buffer = (btstack_memory_avrcp_connection_t *) malloc(sizeof(btstack_memory_avrcp_connection_t)); 877a2673d88SMatthias Ringwald if (buffer){ 878*2a95308bSMatthias Ringwald memset(buffer, 0, sizeof(avrcp_connection_t)); 879*2a95308bSMatthias Ringwald btstack_memory_tracking_add(&buffer->tracking); 880*2a95308bSMatthias Ringwald return &buffer->data; 881b6269742SMatthias Ringwald } else { 882b6269742SMatthias Ringwald return NULL; 883a2673d88SMatthias Ringwald } 88491451a2bSMilanka Ringwald } 88591451a2bSMilanka Ringwald void btstack_memory_avrcp_connection_free(avrcp_connection_t *avrcp_connection){ 886*2a95308bSMatthias Ringwald btstack_memory_avrcp_connection_t * buffer = (btstack_memory_avrcp_connection_t *) avrcp_connection; 887*2a95308bSMatthias Ringwald btstack_memory_tracking_remove(&buffer->tracking); 888b6269742SMatthias Ringwald free(buffer); 88991451a2bSMilanka Ringwald } 89091451a2bSMilanka Ringwald #endif 89191451a2bSMilanka Ringwald 89291451a2bSMilanka Ringwald 893f12a3722SMilanka Ringwald 894f12a3722SMilanka Ringwald // MARK: avrcp_browsing_connection_t 895f12a3722SMilanka Ringwald #if !defined(HAVE_MALLOC) && !defined(MAX_NR_AVRCP_BROWSING_CONNECTIONS) 896f12a3722SMilanka Ringwald #if defined(MAX_NO_AVRCP_BROWSING_CONNECTIONS) 897f12a3722SMilanka 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." 898f12a3722SMilanka Ringwald #else 899f12a3722SMilanka Ringwald #define MAX_NR_AVRCP_BROWSING_CONNECTIONS 0 900f12a3722SMilanka Ringwald #endif 901f12a3722SMilanka Ringwald #endif 902f12a3722SMilanka Ringwald 903f12a3722SMilanka Ringwald #ifdef MAX_NR_AVRCP_BROWSING_CONNECTIONS 904f12a3722SMilanka Ringwald #if MAX_NR_AVRCP_BROWSING_CONNECTIONS > 0 905f12a3722SMilanka Ringwald static avrcp_browsing_connection_t avrcp_browsing_connection_storage[MAX_NR_AVRCP_BROWSING_CONNECTIONS]; 906f12a3722SMilanka Ringwald static btstack_memory_pool_t avrcp_browsing_connection_pool; 907f12a3722SMilanka Ringwald avrcp_browsing_connection_t * btstack_memory_avrcp_browsing_connection_get(void){ 908a2673d88SMatthias Ringwald void * buffer = btstack_memory_pool_get(&avrcp_browsing_connection_pool); 909a2673d88SMatthias Ringwald if (buffer){ 910a2673d88SMatthias Ringwald memset(buffer, 0, sizeof(avrcp_browsing_connection_t)); 911a2673d88SMatthias Ringwald } 912a2673d88SMatthias Ringwald return (avrcp_browsing_connection_t *) buffer; 913f12a3722SMilanka Ringwald } 914f12a3722SMilanka Ringwald void btstack_memory_avrcp_browsing_connection_free(avrcp_browsing_connection_t *avrcp_browsing_connection){ 915f12a3722SMilanka Ringwald btstack_memory_pool_free(&avrcp_browsing_connection_pool, avrcp_browsing_connection); 916f12a3722SMilanka Ringwald } 917f12a3722SMilanka Ringwald #else 918f12a3722SMilanka Ringwald avrcp_browsing_connection_t * btstack_memory_avrcp_browsing_connection_get(void){ 919f12a3722SMilanka Ringwald return NULL; 920f12a3722SMilanka Ringwald } 921f12a3722SMilanka Ringwald void btstack_memory_avrcp_browsing_connection_free(avrcp_browsing_connection_t *avrcp_browsing_connection){ 922b6269742SMatthias Ringwald UNUSED(avrcp_browsing_connection); 923f12a3722SMilanka Ringwald }; 924f12a3722SMilanka Ringwald #endif 925f12a3722SMilanka Ringwald #elif defined(HAVE_MALLOC) 926*2a95308bSMatthias Ringwald 927*2a95308bSMatthias Ringwald typedef struct { 928*2a95308bSMatthias Ringwald avrcp_browsing_connection_t data; 929*2a95308bSMatthias Ringwald btstack_memory_buffer_t tracking; 930*2a95308bSMatthias Ringwald } btstack_memory_avrcp_browsing_connection_t; 931*2a95308bSMatthias Ringwald 932f12a3722SMilanka Ringwald avrcp_browsing_connection_t * btstack_memory_avrcp_browsing_connection_get(void){ 933*2a95308bSMatthias Ringwald btstack_memory_avrcp_browsing_connection_t * buffer = (btstack_memory_avrcp_browsing_connection_t *) malloc(sizeof(btstack_memory_avrcp_browsing_connection_t)); 934a2673d88SMatthias Ringwald if (buffer){ 935*2a95308bSMatthias Ringwald memset(buffer, 0, sizeof(avrcp_browsing_connection_t)); 936*2a95308bSMatthias Ringwald btstack_memory_tracking_add(&buffer->tracking); 937*2a95308bSMatthias Ringwald return &buffer->data; 938b6269742SMatthias Ringwald } else { 939b6269742SMatthias Ringwald return NULL; 940a2673d88SMatthias Ringwald } 941f12a3722SMilanka Ringwald } 942f12a3722SMilanka Ringwald void btstack_memory_avrcp_browsing_connection_free(avrcp_browsing_connection_t *avrcp_browsing_connection){ 943*2a95308bSMatthias Ringwald btstack_memory_avrcp_browsing_connection_t * buffer = (btstack_memory_avrcp_browsing_connection_t *) avrcp_browsing_connection; 944*2a95308bSMatthias Ringwald btstack_memory_tracking_remove(&buffer->tracking); 945b6269742SMatthias Ringwald free(buffer); 946f12a3722SMilanka Ringwald } 947f12a3722SMilanka Ringwald #endif 948f12a3722SMilanka Ringwald 949f12a3722SMilanka Ringwald 95044c5d856SMatthias Ringwald #endif 951a9a4c409SMatthias Ringwald #ifdef ENABLE_BLE 9522e97c149S[email protected] 9532e97c149S[email protected] // MARK: gatt_client_t 954a265b909SMatthias Ringwald #if !defined(HAVE_MALLOC) && !defined(MAX_NR_GATT_CLIENTS) 955a265b909SMatthias Ringwald #if defined(MAX_NO_GATT_CLIENTS) 95627faf85aSMilanka 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." 957a265b909SMatthias Ringwald #else 958a265b909SMatthias Ringwald #define MAX_NR_GATT_CLIENTS 0 959a265b909SMatthias Ringwald #endif 960a265b909SMatthias Ringwald #endif 961a265b909SMatthias Ringwald 962a265b909SMatthias Ringwald #ifdef MAX_NR_GATT_CLIENTS 963a265b909SMatthias Ringwald #if MAX_NR_GATT_CLIENTS > 0 964a265b909SMatthias Ringwald static gatt_client_t gatt_client_storage[MAX_NR_GATT_CLIENTS]; 96529d0c4f7SMatthias Ringwald static btstack_memory_pool_t gatt_client_pool; 966d0fdae3cS[email protected] gatt_client_t * btstack_memory_gatt_client_get(void){ 967a2673d88SMatthias Ringwald void * buffer = btstack_memory_pool_get(&gatt_client_pool); 968a2673d88SMatthias Ringwald if (buffer){ 969a2673d88SMatthias Ringwald memset(buffer, 0, sizeof(gatt_client_t)); 970a2673d88SMatthias Ringwald } 971a2673d88SMatthias Ringwald return (gatt_client_t *) buffer; 972d0fdae3cS[email protected] } 973d0fdae3cS[email protected] void btstack_memory_gatt_client_free(gatt_client_t *gatt_client){ 97429d0c4f7SMatthias Ringwald btstack_memory_pool_free(&gatt_client_pool, gatt_client); 975d0fdae3cS[email protected] } 976d0fdae3cS[email protected] #else 977d0fdae3cS[email protected] gatt_client_t * btstack_memory_gatt_client_get(void){ 978d0fdae3cS[email protected] return NULL; 979d0fdae3cS[email protected] } 980d0fdae3cS[email protected] void btstack_memory_gatt_client_free(gatt_client_t *gatt_client){ 981b6269742SMatthias Ringwald UNUSED(gatt_client); 982d0fdae3cS[email protected] }; 983d0fdae3cS[email protected] #endif 984d0fdae3cS[email protected] #elif defined(HAVE_MALLOC) 985*2a95308bSMatthias Ringwald 986*2a95308bSMatthias Ringwald typedef struct { 987*2a95308bSMatthias Ringwald gatt_client_t data; 988*2a95308bSMatthias Ringwald btstack_memory_buffer_t tracking; 989*2a95308bSMatthias Ringwald } btstack_memory_gatt_client_t; 990*2a95308bSMatthias Ringwald 991d0fdae3cS[email protected] gatt_client_t * btstack_memory_gatt_client_get(void){ 992*2a95308bSMatthias Ringwald btstack_memory_gatt_client_t * buffer = (btstack_memory_gatt_client_t *) malloc(sizeof(btstack_memory_gatt_client_t)); 993a2673d88SMatthias Ringwald if (buffer){ 994*2a95308bSMatthias Ringwald memset(buffer, 0, sizeof(gatt_client_t)); 995*2a95308bSMatthias Ringwald btstack_memory_tracking_add(&buffer->tracking); 996*2a95308bSMatthias Ringwald return &buffer->data; 997b6269742SMatthias Ringwald } else { 998b6269742SMatthias Ringwald return NULL; 999a2673d88SMatthias Ringwald } 1000d0fdae3cS[email protected] } 1001d0fdae3cS[email protected] void btstack_memory_gatt_client_free(gatt_client_t *gatt_client){ 1002*2a95308bSMatthias Ringwald btstack_memory_gatt_client_t * buffer = (btstack_memory_gatt_client_t *) gatt_client; 1003*2a95308bSMatthias Ringwald btstack_memory_tracking_remove(&buffer->tracking); 1004b6269742SMatthias Ringwald free(buffer); 1005d0fdae3cS[email protected] } 1006d0fdae3cS[email protected] #endif 10072e97c149S[email protected] 10082e97c149S[email protected] 1009656bec4fSMatthias Ringwald // MARK: whitelist_entry_t 1010a265b909SMatthias Ringwald #if !defined(HAVE_MALLOC) && !defined(MAX_NR_WHITELIST_ENTRIES) 1011a265b909SMatthias Ringwald #if defined(MAX_NO_WHITELIST_ENTRIES) 101227faf85aSMilanka 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." 1013a265b909SMatthias Ringwald #else 1014a265b909SMatthias Ringwald #define MAX_NR_WHITELIST_ENTRIES 0 1015a265b909SMatthias Ringwald #endif 1016a265b909SMatthias Ringwald #endif 1017a265b909SMatthias Ringwald 1018a265b909SMatthias Ringwald #ifdef MAX_NR_WHITELIST_ENTRIES 1019a265b909SMatthias Ringwald #if MAX_NR_WHITELIST_ENTRIES > 0 1020a265b909SMatthias Ringwald static whitelist_entry_t whitelist_entry_storage[MAX_NR_WHITELIST_ENTRIES]; 102129d0c4f7SMatthias Ringwald static btstack_memory_pool_t whitelist_entry_pool; 1022656bec4fSMatthias Ringwald whitelist_entry_t * btstack_memory_whitelist_entry_get(void){ 1023a2673d88SMatthias Ringwald void * buffer = btstack_memory_pool_get(&whitelist_entry_pool); 1024a2673d88SMatthias Ringwald if (buffer){ 1025a2673d88SMatthias Ringwald memset(buffer, 0, sizeof(whitelist_entry_t)); 1026a2673d88SMatthias Ringwald } 1027a2673d88SMatthias Ringwald return (whitelist_entry_t *) buffer; 1028656bec4fSMatthias Ringwald } 1029656bec4fSMatthias Ringwald void btstack_memory_whitelist_entry_free(whitelist_entry_t *whitelist_entry){ 103029d0c4f7SMatthias Ringwald btstack_memory_pool_free(&whitelist_entry_pool, whitelist_entry); 1031656bec4fSMatthias Ringwald } 1032656bec4fSMatthias Ringwald #else 1033656bec4fSMatthias Ringwald whitelist_entry_t * btstack_memory_whitelist_entry_get(void){ 1034656bec4fSMatthias Ringwald return NULL; 1035656bec4fSMatthias Ringwald } 1036656bec4fSMatthias Ringwald void btstack_memory_whitelist_entry_free(whitelist_entry_t *whitelist_entry){ 1037b6269742SMatthias Ringwald UNUSED(whitelist_entry); 1038656bec4fSMatthias Ringwald }; 1039656bec4fSMatthias Ringwald #endif 1040656bec4fSMatthias Ringwald #elif defined(HAVE_MALLOC) 1041*2a95308bSMatthias Ringwald 1042*2a95308bSMatthias Ringwald typedef struct { 1043*2a95308bSMatthias Ringwald whitelist_entry_t data; 1044*2a95308bSMatthias Ringwald btstack_memory_buffer_t tracking; 1045*2a95308bSMatthias Ringwald } btstack_memory_whitelist_entry_t; 1046*2a95308bSMatthias Ringwald 1047656bec4fSMatthias Ringwald whitelist_entry_t * btstack_memory_whitelist_entry_get(void){ 1048*2a95308bSMatthias Ringwald btstack_memory_whitelist_entry_t * buffer = (btstack_memory_whitelist_entry_t *) malloc(sizeof(btstack_memory_whitelist_entry_t)); 1049a2673d88SMatthias Ringwald if (buffer){ 1050*2a95308bSMatthias Ringwald memset(buffer, 0, sizeof(whitelist_entry_t)); 1051*2a95308bSMatthias Ringwald btstack_memory_tracking_add(&buffer->tracking); 1052*2a95308bSMatthias Ringwald return &buffer->data; 1053b6269742SMatthias Ringwald } else { 1054b6269742SMatthias Ringwald return NULL; 1055a2673d88SMatthias Ringwald } 1056656bec4fSMatthias Ringwald } 1057656bec4fSMatthias Ringwald void btstack_memory_whitelist_entry_free(whitelist_entry_t *whitelist_entry){ 1058*2a95308bSMatthias Ringwald btstack_memory_whitelist_entry_t * buffer = (btstack_memory_whitelist_entry_t *) whitelist_entry; 1059*2a95308bSMatthias Ringwald btstack_memory_tracking_remove(&buffer->tracking); 1060b6269742SMatthias Ringwald free(buffer); 1061656bec4fSMatthias Ringwald } 1062656bec4fSMatthias Ringwald #endif 1063656bec4fSMatthias Ringwald 1064656bec4fSMatthias Ringwald 1065cf49570bSMatthias Ringwald // MARK: sm_lookup_entry_t 1066a265b909SMatthias Ringwald #if !defined(HAVE_MALLOC) && !defined(MAX_NR_SM_LOOKUP_ENTRIES) 1067a265b909SMatthias Ringwald #if defined(MAX_NO_SM_LOOKUP_ENTRIES) 106827faf85aSMilanka 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." 1069a265b909SMatthias Ringwald #else 1070a265b909SMatthias Ringwald #define MAX_NR_SM_LOOKUP_ENTRIES 0 1071a265b909SMatthias Ringwald #endif 1072a265b909SMatthias Ringwald #endif 1073a265b909SMatthias Ringwald 1074a265b909SMatthias Ringwald #ifdef MAX_NR_SM_LOOKUP_ENTRIES 1075a265b909SMatthias Ringwald #if MAX_NR_SM_LOOKUP_ENTRIES > 0 1076a265b909SMatthias Ringwald static sm_lookup_entry_t sm_lookup_entry_storage[MAX_NR_SM_LOOKUP_ENTRIES]; 107729d0c4f7SMatthias Ringwald static btstack_memory_pool_t sm_lookup_entry_pool; 1078cf49570bSMatthias Ringwald sm_lookup_entry_t * btstack_memory_sm_lookup_entry_get(void){ 1079a2673d88SMatthias Ringwald void * buffer = btstack_memory_pool_get(&sm_lookup_entry_pool); 1080a2673d88SMatthias Ringwald if (buffer){ 1081a2673d88SMatthias Ringwald memset(buffer, 0, sizeof(sm_lookup_entry_t)); 1082a2673d88SMatthias Ringwald } 1083a2673d88SMatthias Ringwald return (sm_lookup_entry_t *) buffer; 1084cf49570bSMatthias Ringwald } 1085cf49570bSMatthias Ringwald void btstack_memory_sm_lookup_entry_free(sm_lookup_entry_t *sm_lookup_entry){ 108629d0c4f7SMatthias Ringwald btstack_memory_pool_free(&sm_lookup_entry_pool, sm_lookup_entry); 1087cf49570bSMatthias Ringwald } 1088cf49570bSMatthias Ringwald #else 1089cf49570bSMatthias Ringwald sm_lookup_entry_t * btstack_memory_sm_lookup_entry_get(void){ 1090cf49570bSMatthias Ringwald return NULL; 1091cf49570bSMatthias Ringwald } 1092cf49570bSMatthias Ringwald void btstack_memory_sm_lookup_entry_free(sm_lookup_entry_t *sm_lookup_entry){ 1093b6269742SMatthias Ringwald UNUSED(sm_lookup_entry); 1094cf49570bSMatthias Ringwald }; 1095cf49570bSMatthias Ringwald #endif 1096cf49570bSMatthias Ringwald #elif defined(HAVE_MALLOC) 1097*2a95308bSMatthias Ringwald 1098*2a95308bSMatthias Ringwald typedef struct { 1099*2a95308bSMatthias Ringwald sm_lookup_entry_t data; 1100*2a95308bSMatthias Ringwald btstack_memory_buffer_t tracking; 1101*2a95308bSMatthias Ringwald } btstack_memory_sm_lookup_entry_t; 1102*2a95308bSMatthias Ringwald 1103cf49570bSMatthias Ringwald sm_lookup_entry_t * btstack_memory_sm_lookup_entry_get(void){ 1104*2a95308bSMatthias Ringwald btstack_memory_sm_lookup_entry_t * buffer = (btstack_memory_sm_lookup_entry_t *) malloc(sizeof(btstack_memory_sm_lookup_entry_t)); 1105a2673d88SMatthias Ringwald if (buffer){ 1106*2a95308bSMatthias Ringwald memset(buffer, 0, sizeof(sm_lookup_entry_t)); 1107*2a95308bSMatthias Ringwald btstack_memory_tracking_add(&buffer->tracking); 1108*2a95308bSMatthias Ringwald return &buffer->data; 1109b6269742SMatthias Ringwald } else { 1110b6269742SMatthias Ringwald return NULL; 1111a2673d88SMatthias Ringwald } 1112cf49570bSMatthias Ringwald } 1113cf49570bSMatthias Ringwald void btstack_memory_sm_lookup_entry_free(sm_lookup_entry_t *sm_lookup_entry){ 1114*2a95308bSMatthias Ringwald btstack_memory_sm_lookup_entry_t * buffer = (btstack_memory_sm_lookup_entry_t *) sm_lookup_entry; 1115*2a95308bSMatthias Ringwald btstack_memory_tracking_remove(&buffer->tracking); 1116b6269742SMatthias Ringwald free(buffer); 1117cf49570bSMatthias Ringwald } 1118cf49570bSMatthias Ringwald #endif 1119cf49570bSMatthias Ringwald 1120cf49570bSMatthias Ringwald 112144c5d856SMatthias Ringwald #endif 112244c5d856SMatthias Ringwald #ifdef ENABLE_MESH 1123ebb73e1fSMatthias Ringwald 1124ebb73e1fSMatthias Ringwald // MARK: mesh_network_pdu_t 1125ebb73e1fSMatthias Ringwald #if !defined(HAVE_MALLOC) && !defined(MAX_NR_MESH_NETWORK_PDUS) 1126ebb73e1fSMatthias Ringwald #if defined(MAX_NO_MESH_NETWORK_PDUS) 1127ebb73e1fSMatthias 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." 1128ebb73e1fSMatthias Ringwald #else 1129ebb73e1fSMatthias Ringwald #define MAX_NR_MESH_NETWORK_PDUS 0 1130ebb73e1fSMatthias Ringwald #endif 1131ebb73e1fSMatthias Ringwald #endif 1132ebb73e1fSMatthias Ringwald 1133ebb73e1fSMatthias Ringwald #ifdef MAX_NR_MESH_NETWORK_PDUS 1134ebb73e1fSMatthias Ringwald #if MAX_NR_MESH_NETWORK_PDUS > 0 1135ebb73e1fSMatthias Ringwald static mesh_network_pdu_t mesh_network_pdu_storage[MAX_NR_MESH_NETWORK_PDUS]; 1136ebb73e1fSMatthias Ringwald static btstack_memory_pool_t mesh_network_pdu_pool; 1137ebb73e1fSMatthias Ringwald mesh_network_pdu_t * btstack_memory_mesh_network_pdu_get(void){ 11381c4e8084SMatthias Ringwald void * buffer = btstack_memory_pool_get(&mesh_network_pdu_pool); 11391c4e8084SMatthias Ringwald if (buffer){ 11401c4e8084SMatthias Ringwald memset(buffer, 0, sizeof(mesh_network_pdu_t)); 11411c4e8084SMatthias Ringwald } 11421c4e8084SMatthias Ringwald return (mesh_network_pdu_t *) buffer; 1143ebb73e1fSMatthias Ringwald } 1144ebb73e1fSMatthias Ringwald void btstack_memory_mesh_network_pdu_free(mesh_network_pdu_t *mesh_network_pdu){ 1145ebb73e1fSMatthias Ringwald btstack_memory_pool_free(&mesh_network_pdu_pool, mesh_network_pdu); 1146ebb73e1fSMatthias Ringwald } 1147ebb73e1fSMatthias Ringwald #else 1148ebb73e1fSMatthias Ringwald mesh_network_pdu_t * btstack_memory_mesh_network_pdu_get(void){ 1149ebb73e1fSMatthias Ringwald return NULL; 1150ebb73e1fSMatthias Ringwald } 1151ebb73e1fSMatthias Ringwald void btstack_memory_mesh_network_pdu_free(mesh_network_pdu_t *mesh_network_pdu){ 1152b6269742SMatthias Ringwald UNUSED(mesh_network_pdu); 1153ebb73e1fSMatthias Ringwald }; 1154ebb73e1fSMatthias Ringwald #endif 1155ebb73e1fSMatthias Ringwald #elif defined(HAVE_MALLOC) 1156*2a95308bSMatthias Ringwald 1157*2a95308bSMatthias Ringwald typedef struct { 1158*2a95308bSMatthias Ringwald mesh_network_pdu_t data; 1159*2a95308bSMatthias Ringwald btstack_memory_buffer_t tracking; 1160*2a95308bSMatthias Ringwald } btstack_memory_mesh_network_pdu_t; 1161*2a95308bSMatthias Ringwald 1162ebb73e1fSMatthias Ringwald mesh_network_pdu_t * btstack_memory_mesh_network_pdu_get(void){ 1163*2a95308bSMatthias Ringwald btstack_memory_mesh_network_pdu_t * buffer = (btstack_memory_mesh_network_pdu_t *) malloc(sizeof(btstack_memory_mesh_network_pdu_t)); 11641c4e8084SMatthias Ringwald if (buffer){ 1165*2a95308bSMatthias Ringwald memset(buffer, 0, sizeof(mesh_network_pdu_t)); 1166*2a95308bSMatthias Ringwald btstack_memory_tracking_add(&buffer->tracking); 1167*2a95308bSMatthias Ringwald return &buffer->data; 1168b6269742SMatthias Ringwald } else { 1169b6269742SMatthias Ringwald return NULL; 11701c4e8084SMatthias Ringwald } 1171ebb73e1fSMatthias Ringwald } 1172ebb73e1fSMatthias Ringwald void btstack_memory_mesh_network_pdu_free(mesh_network_pdu_t *mesh_network_pdu){ 1173*2a95308bSMatthias Ringwald btstack_memory_mesh_network_pdu_t * buffer = (btstack_memory_mesh_network_pdu_t *) mesh_network_pdu; 1174*2a95308bSMatthias Ringwald btstack_memory_tracking_remove(&buffer->tracking); 1175b6269742SMatthias Ringwald free(buffer); 1176ebb73e1fSMatthias Ringwald } 1177ebb73e1fSMatthias Ringwald #endif 1178ebb73e1fSMatthias Ringwald 1179ebb73e1fSMatthias Ringwald 1180a4bbc09dSMatthias Ringwald // MARK: mesh_segmented_pdu_t 1181a4bbc09dSMatthias Ringwald #if !defined(HAVE_MALLOC) && !defined(MAX_NR_MESH_SEGMENTED_PDUS) 1182a4bbc09dSMatthias Ringwald #if defined(MAX_NO_MESH_SEGMENTED_PDUS) 1183a4bbc09dSMatthias 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." 1184f7434c1fSMatthias Ringwald #else 1185a4bbc09dSMatthias Ringwald #define MAX_NR_MESH_SEGMENTED_PDUS 0 1186f7434c1fSMatthias Ringwald #endif 1187f7434c1fSMatthias Ringwald #endif 1188f7434c1fSMatthias Ringwald 1189a4bbc09dSMatthias Ringwald #ifdef MAX_NR_MESH_SEGMENTED_PDUS 1190a4bbc09dSMatthias Ringwald #if MAX_NR_MESH_SEGMENTED_PDUS > 0 1191a4bbc09dSMatthias Ringwald static mesh_segmented_pdu_t mesh_segmented_pdu_storage[MAX_NR_MESH_SEGMENTED_PDUS]; 1192a4bbc09dSMatthias Ringwald static btstack_memory_pool_t mesh_segmented_pdu_pool; 1193a4bbc09dSMatthias Ringwald mesh_segmented_pdu_t * btstack_memory_mesh_segmented_pdu_get(void){ 1194a4bbc09dSMatthias Ringwald void * buffer = btstack_memory_pool_get(&mesh_segmented_pdu_pool); 1195f7434c1fSMatthias Ringwald if (buffer){ 1196a4bbc09dSMatthias Ringwald memset(buffer, 0, sizeof(mesh_segmented_pdu_t)); 1197f7434c1fSMatthias Ringwald } 1198a4bbc09dSMatthias Ringwald return (mesh_segmented_pdu_t *) buffer; 1199f7434c1fSMatthias Ringwald } 1200a4bbc09dSMatthias Ringwald void btstack_memory_mesh_segmented_pdu_free(mesh_segmented_pdu_t *mesh_segmented_pdu){ 1201a4bbc09dSMatthias Ringwald btstack_memory_pool_free(&mesh_segmented_pdu_pool, mesh_segmented_pdu); 1202f7434c1fSMatthias Ringwald } 1203f7434c1fSMatthias Ringwald #else 1204a4bbc09dSMatthias Ringwald mesh_segmented_pdu_t * btstack_memory_mesh_segmented_pdu_get(void){ 1205f7434c1fSMatthias Ringwald return NULL; 1206f7434c1fSMatthias Ringwald } 1207a4bbc09dSMatthias Ringwald void btstack_memory_mesh_segmented_pdu_free(mesh_segmented_pdu_t *mesh_segmented_pdu){ 1208b6269742SMatthias Ringwald UNUSED(mesh_segmented_pdu); 1209f7434c1fSMatthias Ringwald }; 1210f7434c1fSMatthias Ringwald #endif 1211f7434c1fSMatthias Ringwald #elif defined(HAVE_MALLOC) 1212*2a95308bSMatthias Ringwald 1213*2a95308bSMatthias Ringwald typedef struct { 1214*2a95308bSMatthias Ringwald mesh_segmented_pdu_t data; 1215*2a95308bSMatthias Ringwald btstack_memory_buffer_t tracking; 1216*2a95308bSMatthias Ringwald } btstack_memory_mesh_segmented_pdu_t; 1217*2a95308bSMatthias Ringwald 1218a4bbc09dSMatthias Ringwald mesh_segmented_pdu_t * btstack_memory_mesh_segmented_pdu_get(void){ 1219*2a95308bSMatthias Ringwald btstack_memory_mesh_segmented_pdu_t * buffer = (btstack_memory_mesh_segmented_pdu_t *) malloc(sizeof(btstack_memory_mesh_segmented_pdu_t)); 1220f7434c1fSMatthias Ringwald if (buffer){ 1221*2a95308bSMatthias Ringwald memset(buffer, 0, sizeof(mesh_segmented_pdu_t)); 1222*2a95308bSMatthias Ringwald btstack_memory_tracking_add(&buffer->tracking); 1223*2a95308bSMatthias Ringwald return &buffer->data; 1224b6269742SMatthias Ringwald } else { 1225b6269742SMatthias Ringwald return NULL; 1226f7434c1fSMatthias Ringwald } 1227f7434c1fSMatthias Ringwald } 1228a4bbc09dSMatthias Ringwald void btstack_memory_mesh_segmented_pdu_free(mesh_segmented_pdu_t *mesh_segmented_pdu){ 1229*2a95308bSMatthias Ringwald btstack_memory_mesh_segmented_pdu_t * buffer = (btstack_memory_mesh_segmented_pdu_t *) mesh_segmented_pdu; 1230*2a95308bSMatthias Ringwald btstack_memory_tracking_remove(&buffer->tracking); 1231b6269742SMatthias Ringwald free(buffer); 1232f7434c1fSMatthias Ringwald } 1233f7434c1fSMatthias Ringwald #endif 1234f7434c1fSMatthias Ringwald 1235f7434c1fSMatthias Ringwald 1236491f99b3SMatthias Ringwald // MARK: mesh_upper_transport_pdu_t 1237491f99b3SMatthias Ringwald #if !defined(HAVE_MALLOC) && !defined(MAX_NR_MESH_UPPER_TRANSPORT_PDUS) 1238491f99b3SMatthias Ringwald #if defined(MAX_NO_MESH_UPPER_TRANSPORT_PDUS) 1239491f99b3SMatthias 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." 1240491f99b3SMatthias Ringwald #else 1241491f99b3SMatthias Ringwald #define MAX_NR_MESH_UPPER_TRANSPORT_PDUS 0 1242491f99b3SMatthias Ringwald #endif 1243491f99b3SMatthias Ringwald #endif 1244491f99b3SMatthias Ringwald 1245491f99b3SMatthias Ringwald #ifdef MAX_NR_MESH_UPPER_TRANSPORT_PDUS 1246491f99b3SMatthias Ringwald #if MAX_NR_MESH_UPPER_TRANSPORT_PDUS > 0 1247491f99b3SMatthias Ringwald static mesh_upper_transport_pdu_t mesh_upper_transport_pdu_storage[MAX_NR_MESH_UPPER_TRANSPORT_PDUS]; 1248491f99b3SMatthias Ringwald static btstack_memory_pool_t mesh_upper_transport_pdu_pool; 1249491f99b3SMatthias Ringwald mesh_upper_transport_pdu_t * btstack_memory_mesh_upper_transport_pdu_get(void){ 1250491f99b3SMatthias Ringwald void * buffer = btstack_memory_pool_get(&mesh_upper_transport_pdu_pool); 1251491f99b3SMatthias Ringwald if (buffer){ 1252491f99b3SMatthias Ringwald memset(buffer, 0, sizeof(mesh_upper_transport_pdu_t)); 1253491f99b3SMatthias Ringwald } 1254491f99b3SMatthias Ringwald return (mesh_upper_transport_pdu_t *) buffer; 1255491f99b3SMatthias Ringwald } 1256491f99b3SMatthias Ringwald void btstack_memory_mesh_upper_transport_pdu_free(mesh_upper_transport_pdu_t *mesh_upper_transport_pdu){ 1257491f99b3SMatthias Ringwald btstack_memory_pool_free(&mesh_upper_transport_pdu_pool, mesh_upper_transport_pdu); 1258491f99b3SMatthias Ringwald } 1259491f99b3SMatthias Ringwald #else 1260491f99b3SMatthias Ringwald mesh_upper_transport_pdu_t * btstack_memory_mesh_upper_transport_pdu_get(void){ 1261491f99b3SMatthias Ringwald return NULL; 1262491f99b3SMatthias Ringwald } 1263491f99b3SMatthias Ringwald void btstack_memory_mesh_upper_transport_pdu_free(mesh_upper_transport_pdu_t *mesh_upper_transport_pdu){ 1264b6269742SMatthias Ringwald UNUSED(mesh_upper_transport_pdu); 1265491f99b3SMatthias Ringwald }; 1266491f99b3SMatthias Ringwald #endif 1267491f99b3SMatthias Ringwald #elif defined(HAVE_MALLOC) 1268*2a95308bSMatthias Ringwald 1269*2a95308bSMatthias Ringwald typedef struct { 1270*2a95308bSMatthias Ringwald mesh_upper_transport_pdu_t data; 1271*2a95308bSMatthias Ringwald btstack_memory_buffer_t tracking; 1272*2a95308bSMatthias Ringwald } btstack_memory_mesh_upper_transport_pdu_t; 1273*2a95308bSMatthias Ringwald 1274491f99b3SMatthias Ringwald mesh_upper_transport_pdu_t * btstack_memory_mesh_upper_transport_pdu_get(void){ 1275*2a95308bSMatthias 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)); 1276491f99b3SMatthias Ringwald if (buffer){ 1277*2a95308bSMatthias Ringwald memset(buffer, 0, sizeof(mesh_upper_transport_pdu_t)); 1278*2a95308bSMatthias Ringwald btstack_memory_tracking_add(&buffer->tracking); 1279*2a95308bSMatthias Ringwald return &buffer->data; 1280b6269742SMatthias Ringwald } else { 1281b6269742SMatthias Ringwald return NULL; 1282491f99b3SMatthias Ringwald } 1283491f99b3SMatthias Ringwald } 1284491f99b3SMatthias Ringwald void btstack_memory_mesh_upper_transport_pdu_free(mesh_upper_transport_pdu_t *mesh_upper_transport_pdu){ 1285*2a95308bSMatthias Ringwald btstack_memory_mesh_upper_transport_pdu_t * buffer = (btstack_memory_mesh_upper_transport_pdu_t *) mesh_upper_transport_pdu; 1286*2a95308bSMatthias Ringwald btstack_memory_tracking_remove(&buffer->tracking); 1287b6269742SMatthias Ringwald free(buffer); 1288491f99b3SMatthias Ringwald } 1289491f99b3SMatthias Ringwald #endif 1290491f99b3SMatthias Ringwald 1291491f99b3SMatthias Ringwald 1292c0a711d9SMatthias Ringwald // MARK: mesh_network_key_t 1293c0a711d9SMatthias Ringwald #if !defined(HAVE_MALLOC) && !defined(MAX_NR_MESH_NETWORK_KEYS) 1294c0a711d9SMatthias Ringwald #if defined(MAX_NO_MESH_NETWORK_KEYS) 1295c0a711d9SMatthias 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." 1296c0a711d9SMatthias Ringwald #else 1297c0a711d9SMatthias Ringwald #define MAX_NR_MESH_NETWORK_KEYS 0 1298c0a711d9SMatthias Ringwald #endif 1299c0a711d9SMatthias Ringwald #endif 1300c0a711d9SMatthias Ringwald 1301c0a711d9SMatthias Ringwald #ifdef MAX_NR_MESH_NETWORK_KEYS 1302c0a711d9SMatthias Ringwald #if MAX_NR_MESH_NETWORK_KEYS > 0 1303c0a711d9SMatthias Ringwald static mesh_network_key_t mesh_network_key_storage[MAX_NR_MESH_NETWORK_KEYS]; 1304c0a711d9SMatthias Ringwald static btstack_memory_pool_t mesh_network_key_pool; 1305c0a711d9SMatthias Ringwald mesh_network_key_t * btstack_memory_mesh_network_key_get(void){ 13061c4e8084SMatthias Ringwald void * buffer = btstack_memory_pool_get(&mesh_network_key_pool); 13071c4e8084SMatthias Ringwald if (buffer){ 13081c4e8084SMatthias Ringwald memset(buffer, 0, sizeof(mesh_network_key_t)); 13091c4e8084SMatthias Ringwald } 13101c4e8084SMatthias Ringwald return (mesh_network_key_t *) buffer; 1311c0a711d9SMatthias Ringwald } 1312c0a711d9SMatthias Ringwald void btstack_memory_mesh_network_key_free(mesh_network_key_t *mesh_network_key){ 1313c0a711d9SMatthias Ringwald btstack_memory_pool_free(&mesh_network_key_pool, mesh_network_key); 1314c0a711d9SMatthias Ringwald } 1315c0a711d9SMatthias Ringwald #else 1316c0a711d9SMatthias Ringwald mesh_network_key_t * btstack_memory_mesh_network_key_get(void){ 1317c0a711d9SMatthias Ringwald return NULL; 1318c0a711d9SMatthias Ringwald } 1319c0a711d9SMatthias Ringwald void btstack_memory_mesh_network_key_free(mesh_network_key_t *mesh_network_key){ 1320b6269742SMatthias Ringwald UNUSED(mesh_network_key); 1321c0a711d9SMatthias Ringwald }; 1322c0a711d9SMatthias Ringwald #endif 1323c0a711d9SMatthias Ringwald #elif defined(HAVE_MALLOC) 1324*2a95308bSMatthias Ringwald 1325*2a95308bSMatthias Ringwald typedef struct { 1326*2a95308bSMatthias Ringwald mesh_network_key_t data; 1327*2a95308bSMatthias Ringwald btstack_memory_buffer_t tracking; 1328*2a95308bSMatthias Ringwald } btstack_memory_mesh_network_key_t; 1329*2a95308bSMatthias Ringwald 1330c0a711d9SMatthias Ringwald mesh_network_key_t * btstack_memory_mesh_network_key_get(void){ 1331*2a95308bSMatthias Ringwald btstack_memory_mesh_network_key_t * buffer = (btstack_memory_mesh_network_key_t *) malloc(sizeof(btstack_memory_mesh_network_key_t)); 13321c4e8084SMatthias Ringwald if (buffer){ 1333*2a95308bSMatthias Ringwald memset(buffer, 0, sizeof(mesh_network_key_t)); 1334*2a95308bSMatthias Ringwald btstack_memory_tracking_add(&buffer->tracking); 1335*2a95308bSMatthias Ringwald return &buffer->data; 1336b6269742SMatthias Ringwald } else { 1337b6269742SMatthias Ringwald return NULL; 13381c4e8084SMatthias Ringwald } 1339c0a711d9SMatthias Ringwald } 1340c0a711d9SMatthias Ringwald void btstack_memory_mesh_network_key_free(mesh_network_key_t *mesh_network_key){ 1341*2a95308bSMatthias Ringwald btstack_memory_mesh_network_key_t * buffer = (btstack_memory_mesh_network_key_t *) mesh_network_key; 1342*2a95308bSMatthias Ringwald btstack_memory_tracking_remove(&buffer->tracking); 1343b6269742SMatthias Ringwald free(buffer); 1344c0a711d9SMatthias Ringwald } 1345c0a711d9SMatthias Ringwald #endif 1346c0a711d9SMatthias Ringwald 1347c0a711d9SMatthias Ringwald 134801e2bf94SMatthias Ringwald // MARK: mesh_transport_key_t 134901e2bf94SMatthias Ringwald #if !defined(HAVE_MALLOC) && !defined(MAX_NR_MESH_TRANSPORT_KEYS) 135001e2bf94SMatthias Ringwald #if defined(MAX_NO_MESH_TRANSPORT_KEYS) 135101e2bf94SMatthias 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." 135201e2bf94SMatthias Ringwald #else 135301e2bf94SMatthias Ringwald #define MAX_NR_MESH_TRANSPORT_KEYS 0 135401e2bf94SMatthias Ringwald #endif 135501e2bf94SMatthias Ringwald #endif 135601e2bf94SMatthias Ringwald 135701e2bf94SMatthias Ringwald #ifdef MAX_NR_MESH_TRANSPORT_KEYS 135801e2bf94SMatthias Ringwald #if MAX_NR_MESH_TRANSPORT_KEYS > 0 135901e2bf94SMatthias Ringwald static mesh_transport_key_t mesh_transport_key_storage[MAX_NR_MESH_TRANSPORT_KEYS]; 136001e2bf94SMatthias Ringwald static btstack_memory_pool_t mesh_transport_key_pool; 136101e2bf94SMatthias Ringwald mesh_transport_key_t * btstack_memory_mesh_transport_key_get(void){ 136201e2bf94SMatthias Ringwald void * buffer = btstack_memory_pool_get(&mesh_transport_key_pool); 136301e2bf94SMatthias Ringwald if (buffer){ 136401e2bf94SMatthias Ringwald memset(buffer, 0, sizeof(mesh_transport_key_t)); 136501e2bf94SMatthias Ringwald } 136601e2bf94SMatthias Ringwald return (mesh_transport_key_t *) buffer; 136701e2bf94SMatthias Ringwald } 136801e2bf94SMatthias Ringwald void btstack_memory_mesh_transport_key_free(mesh_transport_key_t *mesh_transport_key){ 136901e2bf94SMatthias Ringwald btstack_memory_pool_free(&mesh_transport_key_pool, mesh_transport_key); 137001e2bf94SMatthias Ringwald } 137101e2bf94SMatthias Ringwald #else 137201e2bf94SMatthias Ringwald mesh_transport_key_t * btstack_memory_mesh_transport_key_get(void){ 137301e2bf94SMatthias Ringwald return NULL; 137401e2bf94SMatthias Ringwald } 137501e2bf94SMatthias Ringwald void btstack_memory_mesh_transport_key_free(mesh_transport_key_t *mesh_transport_key){ 1376b6269742SMatthias Ringwald UNUSED(mesh_transport_key); 137701e2bf94SMatthias Ringwald }; 137801e2bf94SMatthias Ringwald #endif 137901e2bf94SMatthias Ringwald #elif defined(HAVE_MALLOC) 1380*2a95308bSMatthias Ringwald 1381*2a95308bSMatthias Ringwald typedef struct { 1382*2a95308bSMatthias Ringwald mesh_transport_key_t data; 1383*2a95308bSMatthias Ringwald btstack_memory_buffer_t tracking; 1384*2a95308bSMatthias Ringwald } btstack_memory_mesh_transport_key_t; 1385*2a95308bSMatthias Ringwald 138601e2bf94SMatthias Ringwald mesh_transport_key_t * btstack_memory_mesh_transport_key_get(void){ 1387*2a95308bSMatthias Ringwald btstack_memory_mesh_transport_key_t * buffer = (btstack_memory_mesh_transport_key_t *) malloc(sizeof(btstack_memory_mesh_transport_key_t)); 138801e2bf94SMatthias Ringwald if (buffer){ 1389*2a95308bSMatthias Ringwald memset(buffer, 0, sizeof(mesh_transport_key_t)); 1390*2a95308bSMatthias Ringwald btstack_memory_tracking_add(&buffer->tracking); 1391*2a95308bSMatthias Ringwald return &buffer->data; 1392b6269742SMatthias Ringwald } else { 1393b6269742SMatthias Ringwald return NULL; 139401e2bf94SMatthias Ringwald } 139501e2bf94SMatthias Ringwald } 139601e2bf94SMatthias Ringwald void btstack_memory_mesh_transport_key_free(mesh_transport_key_t *mesh_transport_key){ 1397*2a95308bSMatthias Ringwald btstack_memory_mesh_transport_key_t * buffer = (btstack_memory_mesh_transport_key_t *) mesh_transport_key; 1398*2a95308bSMatthias Ringwald btstack_memory_tracking_remove(&buffer->tracking); 1399b6269742SMatthias Ringwald free(buffer); 140001e2bf94SMatthias Ringwald } 140101e2bf94SMatthias Ringwald #endif 140201e2bf94SMatthias Ringwald 140301e2bf94SMatthias Ringwald 14041f45d603SMatthias Ringwald // MARK: mesh_virtual_address_t 14051f45d603SMatthias Ringwald #if !defined(HAVE_MALLOC) && !defined(MAX_NR_MESH_VIRTUAL_ADDRESSS) 14061f45d603SMatthias Ringwald #if defined(MAX_NO_MESH_VIRTUAL_ADDRESSS) 14071f45d603SMatthias 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." 14081f45d603SMatthias Ringwald #else 14091f45d603SMatthias Ringwald #define MAX_NR_MESH_VIRTUAL_ADDRESSS 0 14101f45d603SMatthias Ringwald #endif 14111f45d603SMatthias Ringwald #endif 14121f45d603SMatthias Ringwald 14131f45d603SMatthias Ringwald #ifdef MAX_NR_MESH_VIRTUAL_ADDRESSS 14141f45d603SMatthias Ringwald #if MAX_NR_MESH_VIRTUAL_ADDRESSS > 0 14151f45d603SMatthias Ringwald static mesh_virtual_address_t mesh_virtual_address_storage[MAX_NR_MESH_VIRTUAL_ADDRESSS]; 14161f45d603SMatthias Ringwald static btstack_memory_pool_t mesh_virtual_address_pool; 14171f45d603SMatthias Ringwald mesh_virtual_address_t * btstack_memory_mesh_virtual_address_get(void){ 14181f45d603SMatthias Ringwald void * buffer = btstack_memory_pool_get(&mesh_virtual_address_pool); 14191f45d603SMatthias Ringwald if (buffer){ 14201f45d603SMatthias Ringwald memset(buffer, 0, sizeof(mesh_virtual_address_t)); 14211f45d603SMatthias Ringwald } 14221f45d603SMatthias Ringwald return (mesh_virtual_address_t *) buffer; 14231f45d603SMatthias Ringwald } 14241f45d603SMatthias Ringwald void btstack_memory_mesh_virtual_address_free(mesh_virtual_address_t *mesh_virtual_address){ 14251f45d603SMatthias Ringwald btstack_memory_pool_free(&mesh_virtual_address_pool, mesh_virtual_address); 14261f45d603SMatthias Ringwald } 14271f45d603SMatthias Ringwald #else 14281f45d603SMatthias Ringwald mesh_virtual_address_t * btstack_memory_mesh_virtual_address_get(void){ 14291f45d603SMatthias Ringwald return NULL; 14301f45d603SMatthias Ringwald } 14311f45d603SMatthias Ringwald void btstack_memory_mesh_virtual_address_free(mesh_virtual_address_t *mesh_virtual_address){ 1432b6269742SMatthias Ringwald UNUSED(mesh_virtual_address); 14331f45d603SMatthias Ringwald }; 14341f45d603SMatthias Ringwald #endif 14351f45d603SMatthias Ringwald #elif defined(HAVE_MALLOC) 1436*2a95308bSMatthias Ringwald 1437*2a95308bSMatthias Ringwald typedef struct { 1438*2a95308bSMatthias Ringwald mesh_virtual_address_t data; 1439*2a95308bSMatthias Ringwald btstack_memory_buffer_t tracking; 1440*2a95308bSMatthias Ringwald } btstack_memory_mesh_virtual_address_t; 1441*2a95308bSMatthias Ringwald 14421f45d603SMatthias Ringwald mesh_virtual_address_t * btstack_memory_mesh_virtual_address_get(void){ 1443*2a95308bSMatthias Ringwald btstack_memory_mesh_virtual_address_t * buffer = (btstack_memory_mesh_virtual_address_t *) malloc(sizeof(btstack_memory_mesh_virtual_address_t)); 14441f45d603SMatthias Ringwald if (buffer){ 1445*2a95308bSMatthias Ringwald memset(buffer, 0, sizeof(mesh_virtual_address_t)); 1446*2a95308bSMatthias Ringwald btstack_memory_tracking_add(&buffer->tracking); 1447*2a95308bSMatthias Ringwald return &buffer->data; 1448b6269742SMatthias Ringwald } else { 1449b6269742SMatthias Ringwald return NULL; 14501f45d603SMatthias Ringwald } 14511f45d603SMatthias Ringwald } 14521f45d603SMatthias Ringwald void btstack_memory_mesh_virtual_address_free(mesh_virtual_address_t *mesh_virtual_address){ 1453*2a95308bSMatthias Ringwald btstack_memory_mesh_virtual_address_t * buffer = (btstack_memory_mesh_virtual_address_t *) mesh_virtual_address; 1454*2a95308bSMatthias Ringwald btstack_memory_tracking_remove(&buffer->tracking); 1455b6269742SMatthias Ringwald free(buffer); 14561f45d603SMatthias Ringwald } 14571f45d603SMatthias Ringwald #endif 14581f45d603SMatthias Ringwald 14591f45d603SMatthias Ringwald 146001122b73SMatthias Ringwald // MARK: mesh_subnet_t 146101122b73SMatthias Ringwald #if !defined(HAVE_MALLOC) && !defined(MAX_NR_MESH_SUBNETS) 146201122b73SMatthias Ringwald #if defined(MAX_NO_MESH_SUBNETS) 146301122b73SMatthias 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." 146401122b73SMatthias Ringwald #else 146501122b73SMatthias Ringwald #define MAX_NR_MESH_SUBNETS 0 146601122b73SMatthias Ringwald #endif 146701122b73SMatthias Ringwald #endif 146801122b73SMatthias Ringwald 146901122b73SMatthias Ringwald #ifdef MAX_NR_MESH_SUBNETS 147001122b73SMatthias Ringwald #if MAX_NR_MESH_SUBNETS > 0 147101122b73SMatthias Ringwald static mesh_subnet_t mesh_subnet_storage[MAX_NR_MESH_SUBNETS]; 147201122b73SMatthias Ringwald static btstack_memory_pool_t mesh_subnet_pool; 147301122b73SMatthias Ringwald mesh_subnet_t * btstack_memory_mesh_subnet_get(void){ 147401122b73SMatthias Ringwald void * buffer = btstack_memory_pool_get(&mesh_subnet_pool); 147501122b73SMatthias Ringwald if (buffer){ 147601122b73SMatthias Ringwald memset(buffer, 0, sizeof(mesh_subnet_t)); 147701122b73SMatthias Ringwald } 147801122b73SMatthias Ringwald return (mesh_subnet_t *) buffer; 147901122b73SMatthias Ringwald } 148001122b73SMatthias Ringwald void btstack_memory_mesh_subnet_free(mesh_subnet_t *mesh_subnet){ 148101122b73SMatthias Ringwald btstack_memory_pool_free(&mesh_subnet_pool, mesh_subnet); 148201122b73SMatthias Ringwald } 148301122b73SMatthias Ringwald #else 148401122b73SMatthias Ringwald mesh_subnet_t * btstack_memory_mesh_subnet_get(void){ 148501122b73SMatthias Ringwald return NULL; 148601122b73SMatthias Ringwald } 148701122b73SMatthias Ringwald void btstack_memory_mesh_subnet_free(mesh_subnet_t *mesh_subnet){ 1488b6269742SMatthias Ringwald UNUSED(mesh_subnet); 148901122b73SMatthias Ringwald }; 149001122b73SMatthias Ringwald #endif 149101122b73SMatthias Ringwald #elif defined(HAVE_MALLOC) 1492*2a95308bSMatthias Ringwald 1493*2a95308bSMatthias Ringwald typedef struct { 1494*2a95308bSMatthias Ringwald mesh_subnet_t data; 1495*2a95308bSMatthias Ringwald btstack_memory_buffer_t tracking; 1496*2a95308bSMatthias Ringwald } btstack_memory_mesh_subnet_t; 1497*2a95308bSMatthias Ringwald 149801122b73SMatthias Ringwald mesh_subnet_t * btstack_memory_mesh_subnet_get(void){ 1499*2a95308bSMatthias Ringwald btstack_memory_mesh_subnet_t * buffer = (btstack_memory_mesh_subnet_t *) malloc(sizeof(btstack_memory_mesh_subnet_t)); 150001122b73SMatthias Ringwald if (buffer){ 1501*2a95308bSMatthias Ringwald memset(buffer, 0, sizeof(mesh_subnet_t)); 1502*2a95308bSMatthias Ringwald btstack_memory_tracking_add(&buffer->tracking); 1503*2a95308bSMatthias Ringwald return &buffer->data; 1504b6269742SMatthias Ringwald } else { 1505b6269742SMatthias Ringwald return NULL; 150601122b73SMatthias Ringwald } 150701122b73SMatthias Ringwald } 150801122b73SMatthias Ringwald void btstack_memory_mesh_subnet_free(mesh_subnet_t *mesh_subnet){ 1509*2a95308bSMatthias Ringwald btstack_memory_mesh_subnet_t * buffer = (btstack_memory_mesh_subnet_t *) mesh_subnet; 1510*2a95308bSMatthias Ringwald btstack_memory_tracking_remove(&buffer->tracking); 1511b6269742SMatthias Ringwald free(buffer); 151201122b73SMatthias Ringwald } 151301122b73SMatthias Ringwald #endif 151401122b73SMatthias Ringwald 151501122b73SMatthias Ringwald 15162e97c149S[email protected] #endif 1517a3b02b71Smatthias.ringwald // init 1518a3b02b71Smatthias.ringwald void btstack_memory_init(void){ 1519a265b909SMatthias Ringwald #if MAX_NR_HCI_CONNECTIONS > 0 1520a265b909SMatthias Ringwald btstack_memory_pool_create(&hci_connection_pool, hci_connection_storage, MAX_NR_HCI_CONNECTIONS, sizeof(hci_connection_t)); 1521a3b02b71Smatthias.ringwald #endif 1522a265b909SMatthias Ringwald #if MAX_NR_L2CAP_SERVICES > 0 1523a265b909SMatthias Ringwald btstack_memory_pool_create(&l2cap_service_pool, l2cap_service_storage, MAX_NR_L2CAP_SERVICES, sizeof(l2cap_service_t)); 1524a3b02b71Smatthias.ringwald #endif 1525a265b909SMatthias Ringwald #if MAX_NR_L2CAP_CHANNELS > 0 1526a265b909SMatthias Ringwald btstack_memory_pool_create(&l2cap_channel_pool, l2cap_channel_storage, MAX_NR_L2CAP_CHANNELS, sizeof(l2cap_channel_t)); 1527a3b02b71Smatthias.ringwald #endif 152844c5d856SMatthias Ringwald #ifdef ENABLE_CLASSIC 152950dc57fcSMatthias Ringwald #if MAX_NR_RFCOMM_MULTIPLEXERS > 0 153050dc57fcSMatthias Ringwald btstack_memory_pool_create(&rfcomm_multiplexer_pool, rfcomm_multiplexer_storage, MAX_NR_RFCOMM_MULTIPLEXERS, sizeof(rfcomm_multiplexer_t)); 1531a3b02b71Smatthias.ringwald #endif 153250dc57fcSMatthias Ringwald #if MAX_NR_RFCOMM_SERVICES > 0 153350dc57fcSMatthias Ringwald btstack_memory_pool_create(&rfcomm_service_pool, rfcomm_service_storage, MAX_NR_RFCOMM_SERVICES, sizeof(rfcomm_service_t)); 1534a3b02b71Smatthias.ringwald #endif 153550dc57fcSMatthias Ringwald #if MAX_NR_RFCOMM_CHANNELS > 0 153650dc57fcSMatthias Ringwald btstack_memory_pool_create(&rfcomm_channel_pool, rfcomm_channel_storage, MAX_NR_RFCOMM_CHANNELS, sizeof(rfcomm_channel_t)); 153750dc57fcSMatthias Ringwald #endif 153850dc57fcSMatthias Ringwald #if MAX_NR_BTSTACK_LINK_KEY_DB_MEMORY_ENTRIES > 0 153950dc57fcSMatthias 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)); 154050dc57fcSMatthias Ringwald #endif 154150dc57fcSMatthias Ringwald #if MAX_NR_BNEP_SERVICES > 0 154250dc57fcSMatthias Ringwald btstack_memory_pool_create(&bnep_service_pool, bnep_service_storage, MAX_NR_BNEP_SERVICES, sizeof(bnep_service_t)); 154350dc57fcSMatthias Ringwald #endif 154450dc57fcSMatthias Ringwald #if MAX_NR_BNEP_CHANNELS > 0 154550dc57fcSMatthias Ringwald btstack_memory_pool_create(&bnep_channel_pool, bnep_channel_storage, MAX_NR_BNEP_CHANNELS, sizeof(bnep_channel_t)); 154650dc57fcSMatthias Ringwald #endif 154750dc57fcSMatthias Ringwald #if MAX_NR_HFP_CONNECTIONS > 0 154850dc57fcSMatthias Ringwald btstack_memory_pool_create(&hfp_connection_pool, hfp_connection_storage, MAX_NR_HFP_CONNECTIONS, sizeof(hfp_connection_t)); 154950dc57fcSMatthias Ringwald #endif 155050dc57fcSMatthias Ringwald #if MAX_NR_SERVICE_RECORD_ITEMS > 0 155150dc57fcSMatthias Ringwald btstack_memory_pool_create(&service_record_item_pool, service_record_item_storage, MAX_NR_SERVICE_RECORD_ITEMS, sizeof(service_record_item_t)); 155250dc57fcSMatthias Ringwald #endif 155350dc57fcSMatthias Ringwald #if MAX_NR_AVDTP_STREAM_ENDPOINTS > 0 155450dc57fcSMatthias Ringwald btstack_memory_pool_create(&avdtp_stream_endpoint_pool, avdtp_stream_endpoint_storage, MAX_NR_AVDTP_STREAM_ENDPOINTS, sizeof(avdtp_stream_endpoint_t)); 155550dc57fcSMatthias Ringwald #endif 155650dc57fcSMatthias Ringwald #if MAX_NR_AVDTP_CONNECTIONS > 0 155750dc57fcSMatthias Ringwald btstack_memory_pool_create(&avdtp_connection_pool, avdtp_connection_storage, MAX_NR_AVDTP_CONNECTIONS, sizeof(avdtp_connection_t)); 155850dc57fcSMatthias Ringwald #endif 155950dc57fcSMatthias Ringwald #if MAX_NR_AVRCP_CONNECTIONS > 0 156050dc57fcSMatthias Ringwald btstack_memory_pool_create(&avrcp_connection_pool, avrcp_connection_storage, MAX_NR_AVRCP_CONNECTIONS, sizeof(avrcp_connection_t)); 156150dc57fcSMatthias Ringwald #endif 156250dc57fcSMatthias Ringwald #if MAX_NR_AVRCP_BROWSING_CONNECTIONS > 0 156350dc57fcSMatthias Ringwald btstack_memory_pool_create(&avrcp_browsing_connection_pool, avrcp_browsing_connection_storage, MAX_NR_AVRCP_BROWSING_CONNECTIONS, sizeof(avrcp_browsing_connection_t)); 1564a3b02b71Smatthias.ringwald #endif 1565f12a3722SMilanka Ringwald #endif 1566a9a4c409SMatthias Ringwald #ifdef ENABLE_BLE 1567a265b909SMatthias Ringwald #if MAX_NR_GATT_CLIENTS > 0 1568a265b909SMatthias Ringwald btstack_memory_pool_create(&gatt_client_pool, gatt_client_storage, MAX_NR_GATT_CLIENTS, sizeof(gatt_client_t)); 1569d0fdae3cS[email protected] #endif 1570a265b909SMatthias Ringwald #if MAX_NR_WHITELIST_ENTRIES > 0 1571a265b909SMatthias Ringwald btstack_memory_pool_create(&whitelist_entry_pool, whitelist_entry_storage, MAX_NR_WHITELIST_ENTRIES, sizeof(whitelist_entry_t)); 1572656bec4fSMatthias Ringwald #endif 1573a265b909SMatthias Ringwald #if MAX_NR_SM_LOOKUP_ENTRIES > 0 1574a265b909SMatthias Ringwald btstack_memory_pool_create(&sm_lookup_entry_pool, sm_lookup_entry_storage, MAX_NR_SM_LOOKUP_ENTRIES, sizeof(sm_lookup_entry_t)); 1575cf49570bSMatthias Ringwald #endif 1576ebb73e1fSMatthias Ringwald #endif 157744c5d856SMatthias Ringwald #ifdef ENABLE_MESH 157850dc57fcSMatthias Ringwald #if MAX_NR_MESH_NETWORK_PDUS > 0 157950dc57fcSMatthias Ringwald btstack_memory_pool_create(&mesh_network_pdu_pool, mesh_network_pdu_storage, MAX_NR_MESH_NETWORK_PDUS, sizeof(mesh_network_pdu_t)); 158044c5d856SMatthias Ringwald #endif 1581a4bbc09dSMatthias Ringwald #if MAX_NR_MESH_SEGMENTED_PDUS > 0 1582a4bbc09dSMatthias Ringwald btstack_memory_pool_create(&mesh_segmented_pdu_pool, mesh_segmented_pdu_storage, MAX_NR_MESH_SEGMENTED_PDUS, sizeof(mesh_segmented_pdu_t)); 1583f7434c1fSMatthias Ringwald #endif 1584491f99b3SMatthias Ringwald #if MAX_NR_MESH_UPPER_TRANSPORT_PDUS > 0 1585491f99b3SMatthias 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)); 1586491f99b3SMatthias Ringwald #endif 158750dc57fcSMatthias Ringwald #if MAX_NR_MESH_NETWORK_KEYS > 0 158850dc57fcSMatthias Ringwald btstack_memory_pool_create(&mesh_network_key_pool, mesh_network_key_storage, MAX_NR_MESH_NETWORK_KEYS, sizeof(mesh_network_key_t)); 1589c0a711d9SMatthias Ringwald #endif 159001e2bf94SMatthias Ringwald #if MAX_NR_MESH_TRANSPORT_KEYS > 0 159101e2bf94SMatthias Ringwald btstack_memory_pool_create(&mesh_transport_key_pool, mesh_transport_key_storage, MAX_NR_MESH_TRANSPORT_KEYS, sizeof(mesh_transport_key_t)); 159201e2bf94SMatthias Ringwald #endif 15931f45d603SMatthias Ringwald #if MAX_NR_MESH_VIRTUAL_ADDRESSS > 0 15941f45d603SMatthias Ringwald btstack_memory_pool_create(&mesh_virtual_address_pool, mesh_virtual_address_storage, MAX_NR_MESH_VIRTUAL_ADDRESSS, sizeof(mesh_virtual_address_t)); 15951f45d603SMatthias Ringwald #endif 159601122b73SMatthias Ringwald #if MAX_NR_MESH_SUBNETS > 0 159701122b73SMatthias Ringwald btstack_memory_pool_create(&mesh_subnet_pool, mesh_subnet_storage, MAX_NR_MESH_SUBNETS, sizeof(mesh_subnet_t)); 159801122b73SMatthias Ringwald #endif 1599a7d12effS[email protected] #endif 1600a3b02b71Smatthias.ringwald } 1601