JBBoardに接続したモーター2つをRCBControllerでコントロールするテストです。
Dependencies: FatFileSystem TB6612FNG2 mbed
Fork of JBB_BTLE_Test by
BTstack/btstack_memory.c@1:6078e430af82, 2013-02-07 (annotated)
- Committer:
- todotani
- Date:
- Thu Feb 07 14:01:01 2013 +0000
- Revision:
- 1:6078e430af82
- Parent:
- 0:1ed23ab1345f
BLE demo for mbed; Ported SBDBT (RunningElectronics) firmware for BLE to mbed. It can communicate with iOS
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
todotani | 1:6078e430af82 | 1 | /* |
todotani | 1:6078e430af82 | 2 | * Copyright (C) 2009-2012 by Matthias Ringwald |
todotani | 1:6078e430af82 | 3 | * |
todotani | 1:6078e430af82 | 4 | * Redistribution and use in source and binary forms, with or without |
todotani | 1:6078e430af82 | 5 | * modification, are permitted provided that the following conditions |
todotani | 1:6078e430af82 | 6 | * are met: |
todotani | 1:6078e430af82 | 7 | * |
todotani | 1:6078e430af82 | 8 | * 1. Redistributions of source code must retain the above copyright |
todotani | 1:6078e430af82 | 9 | * notice, this list of conditions and the following disclaimer. |
todotani | 1:6078e430af82 | 10 | * 2. Redistributions in binary form must reproduce the above copyright |
todotani | 1:6078e430af82 | 11 | * notice, this list of conditions and the following disclaimer in the |
todotani | 1:6078e430af82 | 12 | * documentation and/or other materials provided with the distribution. |
todotani | 1:6078e430af82 | 13 | * 3. Neither the name of the copyright holders nor the names of |
todotani | 1:6078e430af82 | 14 | * contributors may be used to endorse or promote products derived |
todotani | 1:6078e430af82 | 15 | * from this software without specific prior written permission. |
todotani | 1:6078e430af82 | 16 | * 4. Any redistribution, use, or modification is done solely for |
todotani | 1:6078e430af82 | 17 | * personal benefit and not for any commercial purpose or for |
todotani | 1:6078e430af82 | 18 | * monetary gain. |
todotani | 1:6078e430af82 | 19 | * |
todotani | 1:6078e430af82 | 20 | * THIS SOFTWARE IS PROVIDED BY MATTHIAS RINGWALD AND CONTRIBUTORS |
todotani | 1:6078e430af82 | 21 | * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
todotani | 1:6078e430af82 | 22 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS |
todotani | 1:6078e430af82 | 23 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL MATTHIAS |
todotani | 1:6078e430af82 | 24 | * RINGWALD OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, |
todotani | 1:6078e430af82 | 25 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, |
todotani | 1:6078e430af82 | 26 | * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS |
todotani | 1:6078e430af82 | 27 | * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED |
todotani | 1:6078e430af82 | 28 | * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, |
todotani | 1:6078e430af82 | 29 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF |
todotani | 1:6078e430af82 | 30 | * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
todotani | 1:6078e430af82 | 31 | * SUCH DAMAGE. |
todotani | 1:6078e430af82 | 32 | * |
todotani | 1:6078e430af82 | 33 | * Please inquire about commercial licensing options at btstack@ringwald.ch |
todotani | 1:6078e430af82 | 34 | * |
todotani | 1:6078e430af82 | 35 | */ |
todotani | 1:6078e430af82 | 36 | |
todotani | 1:6078e430af82 | 37 | /* |
todotani | 1:6078e430af82 | 38 | * btstsack_memory.h |
todotani | 1:6078e430af82 | 39 | * |
todotani | 1:6078e430af82 | 40 | * @brief BTstack memory management via configurable memory pools |
todotani | 1:6078e430af82 | 41 | * |
todotani | 1:6078e430af82 | 42 | * @note code semi-atuomatically generated by btstack_memory_generator.py |
todotani | 1:6078e430af82 | 43 | * |
todotani | 1:6078e430af82 | 44 | */ |
todotani | 1:6078e430af82 | 45 | |
todotani | 1:6078e430af82 | 46 | #include "btstack_memory.h" |
todotani | 1:6078e430af82 | 47 | #include "btstack/memory_pool.h" |
todotani | 1:6078e430af82 | 48 | |
todotani | 1:6078e430af82 | 49 | #include <stdlib.h> |
todotani | 1:6078e430af82 | 50 | |
todotani | 1:6078e430af82 | 51 | #include "config.h" |
todotani | 1:6078e430af82 | 52 | #include "hci.h" |
todotani | 1:6078e430af82 | 53 | #include "l2cap.h" |
todotani | 1:6078e430af82 | 54 | #include "rfcomm.h" |
todotani | 1:6078e430af82 | 55 | |
todotani | 1:6078e430af82 | 56 | // MARK: hci_connection_t |
todotani | 1:6078e430af82 | 57 | #ifdef MAX_NO_HCI_CONNECTIONS |
todotani | 1:6078e430af82 | 58 | #if MAX_NO_HCI_CONNECTIONS > 0 |
todotani | 1:6078e430af82 | 59 | static hci_connection_t hci_connection_storage[MAX_NO_HCI_CONNECTIONS]; |
todotani | 1:6078e430af82 | 60 | static memory_pool_t hci_connection_pool; |
todotani | 1:6078e430af82 | 61 | void * btstack_memory_hci_connection_get(void){ |
todotani | 1:6078e430af82 | 62 | return memory_pool_get(&hci_connection_pool); |
todotani | 1:6078e430af82 | 63 | } |
todotani | 1:6078e430af82 | 64 | void btstack_memory_hci_connection_free(void *hci_connection){ |
todotani | 1:6078e430af82 | 65 | memory_pool_free(&hci_connection_pool, hci_connection); |
todotani | 1:6078e430af82 | 66 | } |
todotani | 1:6078e430af82 | 67 | #else |
todotani | 1:6078e430af82 | 68 | void * btstack_memory_hci_connection_get(void){ |
todotani | 1:6078e430af82 | 69 | return NULL; |
todotani | 1:6078e430af82 | 70 | } |
todotani | 1:6078e430af82 | 71 | void btstack_memory_hci_connection_free(void *hci_connection){ |
todotani | 1:6078e430af82 | 72 | }; |
todotani | 1:6078e430af82 | 73 | #endif |
todotani | 1:6078e430af82 | 74 | #elif defined(HAVE_MALLOC) |
todotani | 1:6078e430af82 | 75 | void * btstack_memory_hci_connection_get(void){ |
todotani | 1:6078e430af82 | 76 | return malloc(sizeof(hci_connection_t)); |
todotani | 1:6078e430af82 | 77 | } |
todotani | 1:6078e430af82 | 78 | void btstack_memory_hci_connection_free(void *hci_connection){ |
todotani | 1:6078e430af82 | 79 | free(hci_connection); |
todotani | 1:6078e430af82 | 80 | } |
todotani | 1:6078e430af82 | 81 | #endif |
todotani | 1:6078e430af82 | 82 | |
todotani | 1:6078e430af82 | 83 | |
todotani | 1:6078e430af82 | 84 | // MARK: l2cap_service_t |
todotani | 1:6078e430af82 | 85 | #ifdef MAX_NO_L2CAP_SERVICES |
todotani | 1:6078e430af82 | 86 | #if MAX_NO_L2CAP_SERVICES > 0 |
todotani | 1:6078e430af82 | 87 | static l2cap_service_t l2cap_service_storage[MAX_NO_L2CAP_SERVICES]; |
todotani | 1:6078e430af82 | 88 | static memory_pool_t l2cap_service_pool; |
todotani | 1:6078e430af82 | 89 | void * btstack_memory_l2cap_service_get(void){ |
todotani | 1:6078e430af82 | 90 | return memory_pool_get(&l2cap_service_pool); |
todotani | 1:6078e430af82 | 91 | } |
todotani | 1:6078e430af82 | 92 | void btstack_memory_l2cap_service_free(void *l2cap_service){ |
todotani | 1:6078e430af82 | 93 | memory_pool_free(&l2cap_service_pool, l2cap_service); |
todotani | 1:6078e430af82 | 94 | } |
todotani | 1:6078e430af82 | 95 | #else |
todotani | 1:6078e430af82 | 96 | void * btstack_memory_l2cap_service_get(void){ |
todotani | 1:6078e430af82 | 97 | return NULL; |
todotani | 1:6078e430af82 | 98 | } |
todotani | 1:6078e430af82 | 99 | void btstack_memory_l2cap_service_free(void *l2cap_service){ |
todotani | 1:6078e430af82 | 100 | }; |
todotani | 1:6078e430af82 | 101 | #endif |
todotani | 1:6078e430af82 | 102 | #elif defined(HAVE_MALLOC) |
todotani | 1:6078e430af82 | 103 | void * btstack_memory_l2cap_service_get(void){ |
todotani | 1:6078e430af82 | 104 | return malloc(sizeof(l2cap_service_t)); |
todotani | 1:6078e430af82 | 105 | } |
todotani | 1:6078e430af82 | 106 | void btstack_memory_l2cap_service_free(void *l2cap_service){ |
todotani | 1:6078e430af82 | 107 | free(l2cap_service); |
todotani | 1:6078e430af82 | 108 | } |
todotani | 1:6078e430af82 | 109 | #endif |
todotani | 1:6078e430af82 | 110 | |
todotani | 1:6078e430af82 | 111 | |
todotani | 1:6078e430af82 | 112 | // MARK: l2cap_channel_t |
todotani | 1:6078e430af82 | 113 | #ifdef MAX_NO_L2CAP_CHANNELS |
todotani | 1:6078e430af82 | 114 | #if MAX_NO_L2CAP_CHANNELS > 0 |
todotani | 1:6078e430af82 | 115 | static l2cap_channel_t l2cap_channel_storage[MAX_NO_L2CAP_CHANNELS]; |
todotani | 1:6078e430af82 | 116 | static memory_pool_t l2cap_channel_pool; |
todotani | 1:6078e430af82 | 117 | void * btstack_memory_l2cap_channel_get(void){ |
todotani | 1:6078e430af82 | 118 | return memory_pool_get(&l2cap_channel_pool); |
todotani | 1:6078e430af82 | 119 | } |
todotani | 1:6078e430af82 | 120 | void btstack_memory_l2cap_channel_free(void *l2cap_channel){ |
todotani | 1:6078e430af82 | 121 | memory_pool_free(&l2cap_channel_pool, l2cap_channel); |
todotani | 1:6078e430af82 | 122 | } |
todotani | 1:6078e430af82 | 123 | #else |
todotani | 1:6078e430af82 | 124 | void * btstack_memory_l2cap_channel_get(void){ |
todotani | 1:6078e430af82 | 125 | return NULL; |
todotani | 1:6078e430af82 | 126 | } |
todotani | 1:6078e430af82 | 127 | void btstack_memory_l2cap_channel_free(void *l2cap_channel){ |
todotani | 1:6078e430af82 | 128 | }; |
todotani | 1:6078e430af82 | 129 | #endif |
todotani | 1:6078e430af82 | 130 | #elif defined(HAVE_MALLOC) |
todotani | 1:6078e430af82 | 131 | void * btstack_memory_l2cap_channel_get(void){ |
todotani | 1:6078e430af82 | 132 | return malloc(sizeof(l2cap_channel_t)); |
todotani | 1:6078e430af82 | 133 | } |
todotani | 1:6078e430af82 | 134 | void btstack_memory_l2cap_channel_free(void *l2cap_channel){ |
todotani | 1:6078e430af82 | 135 | free(l2cap_channel); |
todotani | 1:6078e430af82 | 136 | } |
todotani | 1:6078e430af82 | 137 | #endif |
todotani | 1:6078e430af82 | 138 | |
todotani | 1:6078e430af82 | 139 | |
todotani | 1:6078e430af82 | 140 | // MARK: rfcomm_multiplexer_t |
todotani | 1:6078e430af82 | 141 | #ifdef MAX_NO_RFCOMM_MULTIPLEXERS |
todotani | 1:6078e430af82 | 142 | #if MAX_NO_RFCOMM_MULTIPLEXERS > 0 |
todotani | 1:6078e430af82 | 143 | static rfcomm_multiplexer_t rfcomm_multiplexer_storage[MAX_NO_RFCOMM_MULTIPLEXERS]; |
todotani | 1:6078e430af82 | 144 | static memory_pool_t rfcomm_multiplexer_pool; |
todotani | 1:6078e430af82 | 145 | void * btstack_memory_rfcomm_multiplexer_get(void){ |
todotani | 1:6078e430af82 | 146 | return memory_pool_get(&rfcomm_multiplexer_pool); |
todotani | 1:6078e430af82 | 147 | } |
todotani | 1:6078e430af82 | 148 | void btstack_memory_rfcomm_multiplexer_free(void *rfcomm_multiplexer){ |
todotani | 1:6078e430af82 | 149 | memory_pool_free(&rfcomm_multiplexer_pool, rfcomm_multiplexer); |
todotani | 1:6078e430af82 | 150 | } |
todotani | 1:6078e430af82 | 151 | #else |
todotani | 1:6078e430af82 | 152 | void * btstack_memory_rfcomm_multiplexer_get(void){ |
todotani | 1:6078e430af82 | 153 | return NULL; |
todotani | 1:6078e430af82 | 154 | } |
todotani | 1:6078e430af82 | 155 | void btstack_memory_rfcomm_multiplexer_free(void *rfcomm_multiplexer){ |
todotani | 1:6078e430af82 | 156 | }; |
todotani | 1:6078e430af82 | 157 | #endif |
todotani | 1:6078e430af82 | 158 | #elif defined(HAVE_MALLOC) |
todotani | 1:6078e430af82 | 159 | void * btstack_memory_rfcomm_multiplexer_get(void){ |
todotani | 1:6078e430af82 | 160 | return malloc(sizeof(rfcomm_multiplexer_t)); |
todotani | 1:6078e430af82 | 161 | } |
todotani | 1:6078e430af82 | 162 | void btstack_memory_rfcomm_multiplexer_free(void *rfcomm_multiplexer){ |
todotani | 1:6078e430af82 | 163 | free(rfcomm_multiplexer); |
todotani | 1:6078e430af82 | 164 | } |
todotani | 1:6078e430af82 | 165 | #endif |
todotani | 1:6078e430af82 | 166 | |
todotani | 1:6078e430af82 | 167 | |
todotani | 1:6078e430af82 | 168 | // MARK: rfcomm_service_t |
todotani | 1:6078e430af82 | 169 | #ifdef MAX_NO_RFCOMM_SERVICES |
todotani | 1:6078e430af82 | 170 | #if MAX_NO_RFCOMM_SERVICES > 0 |
todotani | 1:6078e430af82 | 171 | static rfcomm_service_t rfcomm_service_storage[MAX_NO_RFCOMM_SERVICES]; |
todotani | 1:6078e430af82 | 172 | static memory_pool_t rfcomm_service_pool; |
todotani | 1:6078e430af82 | 173 | void * btstack_memory_rfcomm_service_get(void){ |
todotani | 1:6078e430af82 | 174 | return memory_pool_get(&rfcomm_service_pool); |
todotani | 1:6078e430af82 | 175 | } |
todotani | 1:6078e430af82 | 176 | void btstack_memory_rfcomm_service_free(void *rfcomm_service){ |
todotani | 1:6078e430af82 | 177 | memory_pool_free(&rfcomm_service_pool, rfcomm_service); |
todotani | 1:6078e430af82 | 178 | } |
todotani | 1:6078e430af82 | 179 | #else |
todotani | 1:6078e430af82 | 180 | void * btstack_memory_rfcomm_service_get(void){ |
todotani | 1:6078e430af82 | 181 | return NULL; |
todotani | 1:6078e430af82 | 182 | } |
todotani | 1:6078e430af82 | 183 | void btstack_memory_rfcomm_service_free(void *rfcomm_service){ |
todotani | 1:6078e430af82 | 184 | }; |
todotani | 1:6078e430af82 | 185 | #endif |
todotani | 1:6078e430af82 | 186 | #elif defined(HAVE_MALLOC) |
todotani | 1:6078e430af82 | 187 | void * btstack_memory_rfcomm_service_get(void){ |
todotani | 1:6078e430af82 | 188 | return malloc(sizeof(rfcomm_service_t)); |
todotani | 1:6078e430af82 | 189 | } |
todotani | 1:6078e430af82 | 190 | void btstack_memory_rfcomm_service_free(void *rfcomm_service){ |
todotani | 1:6078e430af82 | 191 | free(rfcomm_service); |
todotani | 1:6078e430af82 | 192 | } |
todotani | 1:6078e430af82 | 193 | #endif |
todotani | 1:6078e430af82 | 194 | |
todotani | 1:6078e430af82 | 195 | |
todotani | 1:6078e430af82 | 196 | // MARK: rfcomm_channel_t |
todotani | 1:6078e430af82 | 197 | #ifdef MAX_NO_RFCOMM_CHANNELS |
todotani | 1:6078e430af82 | 198 | #if MAX_NO_RFCOMM_CHANNELS > 0 |
todotani | 1:6078e430af82 | 199 | static rfcomm_channel_t rfcomm_channel_storage[MAX_NO_RFCOMM_CHANNELS]; |
todotani | 1:6078e430af82 | 200 | static memory_pool_t rfcomm_channel_pool; |
todotani | 1:6078e430af82 | 201 | void * btstack_memory_rfcomm_channel_get(void){ |
todotani | 1:6078e430af82 | 202 | return memory_pool_get(&rfcomm_channel_pool); |
todotani | 1:6078e430af82 | 203 | } |
todotani | 1:6078e430af82 | 204 | void btstack_memory_rfcomm_channel_free(void *rfcomm_channel){ |
todotani | 1:6078e430af82 | 205 | memory_pool_free(&rfcomm_channel_pool, rfcomm_channel); |
todotani | 1:6078e430af82 | 206 | } |
todotani | 1:6078e430af82 | 207 | #else |
todotani | 1:6078e430af82 | 208 | void * btstack_memory_rfcomm_channel_get(void){ |
todotani | 1:6078e430af82 | 209 | return NULL; |
todotani | 1:6078e430af82 | 210 | } |
todotani | 1:6078e430af82 | 211 | void btstack_memory_rfcomm_channel_free(void *rfcomm_channel){ |
todotani | 1:6078e430af82 | 212 | }; |
todotani | 1:6078e430af82 | 213 | #endif |
todotani | 1:6078e430af82 | 214 | #elif defined(HAVE_MALLOC) |
todotani | 1:6078e430af82 | 215 | void * btstack_memory_rfcomm_channel_get(void){ |
todotani | 1:6078e430af82 | 216 | return malloc(sizeof(rfcomm_channel_t)); |
todotani | 1:6078e430af82 | 217 | } |
todotani | 1:6078e430af82 | 218 | void btstack_memory_rfcomm_channel_free(void *rfcomm_channel){ |
todotani | 1:6078e430af82 | 219 | free(rfcomm_channel); |
todotani | 1:6078e430af82 | 220 | } |
todotani | 1:6078e430af82 | 221 | #endif |
todotani | 1:6078e430af82 | 222 | |
todotani | 1:6078e430af82 | 223 | |
todotani | 1:6078e430af82 | 224 | // MARK: db_mem_device_name_t |
todotani | 1:6078e430af82 | 225 | #ifdef MAX_NO_DB_MEM_DEVICE_NAMES |
todotani | 1:6078e430af82 | 226 | #if MAX_NO_DB_MEM_DEVICE_NAMES > 0 |
todotani | 1:6078e430af82 | 227 | static db_mem_device_name_t db_mem_device_name_storage[MAX_NO_DB_MEM_DEVICE_NAMES]; |
todotani | 1:6078e430af82 | 228 | static memory_pool_t db_mem_device_name_pool; |
todotani | 1:6078e430af82 | 229 | void * btstack_memory_db_mem_device_name_get(void){ |
todotani | 1:6078e430af82 | 230 | return memory_pool_get(&db_mem_device_name_pool); |
todotani | 1:6078e430af82 | 231 | } |
todotani | 1:6078e430af82 | 232 | void btstack_memory_db_mem_device_name_free(void *db_mem_device_name){ |
todotani | 1:6078e430af82 | 233 | memory_pool_free(&db_mem_device_name_pool, db_mem_device_name); |
todotani | 1:6078e430af82 | 234 | } |
todotani | 1:6078e430af82 | 235 | #else |
todotani | 1:6078e430af82 | 236 | void * btstack_memory_db_mem_device_name_get(void){ |
todotani | 1:6078e430af82 | 237 | return NULL; |
todotani | 1:6078e430af82 | 238 | } |
todotani | 1:6078e430af82 | 239 | void btstack_memory_db_mem_device_name_free(void *db_mem_device_name){ |
todotani | 1:6078e430af82 | 240 | }; |
todotani | 1:6078e430af82 | 241 | #endif |
todotani | 1:6078e430af82 | 242 | #elif defined(HAVE_MALLOC) |
todotani | 1:6078e430af82 | 243 | void * btstack_memory_db_mem_device_name_get(void){ |
todotani | 1:6078e430af82 | 244 | return malloc(sizeof(db_mem_device_name_t)); |
todotani | 1:6078e430af82 | 245 | } |
todotani | 1:6078e430af82 | 246 | void btstack_memory_db_mem_device_name_free(void *db_mem_device_name){ |
todotani | 1:6078e430af82 | 247 | free(db_mem_device_name); |
todotani | 1:6078e430af82 | 248 | } |
todotani | 1:6078e430af82 | 249 | #endif |
todotani | 1:6078e430af82 | 250 | |
todotani | 1:6078e430af82 | 251 | |
todotani | 1:6078e430af82 | 252 | // MARK: db_mem_device_link_key_t |
todotani | 1:6078e430af82 | 253 | #ifdef MAX_NO_DB_MEM_DEVICE_LINK_KEYS |
todotani | 1:6078e430af82 | 254 | #if MAX_NO_DB_MEM_DEVICE_LINK_KEYS > 0 |
todotani | 1:6078e430af82 | 255 | static db_mem_device_link_key_t db_mem_device_link_key_storage[MAX_NO_DB_MEM_DEVICE_LINK_KEYS]; |
todotani | 1:6078e430af82 | 256 | static memory_pool_t db_mem_device_link_key_pool; |
todotani | 1:6078e430af82 | 257 | void * btstack_memory_db_mem_device_link_key_get(void){ |
todotani | 1:6078e430af82 | 258 | return memory_pool_get(&db_mem_device_link_key_pool); |
todotani | 1:6078e430af82 | 259 | } |
todotani | 1:6078e430af82 | 260 | void btstack_memory_db_mem_device_link_key_free(void *db_mem_device_link_key){ |
todotani | 1:6078e430af82 | 261 | memory_pool_free(&db_mem_device_link_key_pool, db_mem_device_link_key); |
todotani | 1:6078e430af82 | 262 | } |
todotani | 1:6078e430af82 | 263 | #else |
todotani | 1:6078e430af82 | 264 | void * btstack_memory_db_mem_device_link_key_get(void){ |
todotani | 1:6078e430af82 | 265 | return NULL; |
todotani | 1:6078e430af82 | 266 | } |
todotani | 1:6078e430af82 | 267 | void btstack_memory_db_mem_device_link_key_free(void *db_mem_device_link_key){ |
todotani | 1:6078e430af82 | 268 | }; |
todotani | 1:6078e430af82 | 269 | #endif |
todotani | 1:6078e430af82 | 270 | #elif defined(HAVE_MALLOC) |
todotani | 1:6078e430af82 | 271 | void * btstack_memory_db_mem_device_link_key_get(void){ |
todotani | 1:6078e430af82 | 272 | return malloc(sizeof(db_mem_device_link_key_t)); |
todotani | 1:6078e430af82 | 273 | } |
todotani | 1:6078e430af82 | 274 | void btstack_memory_db_mem_device_link_key_free(void *db_mem_device_link_key){ |
todotani | 1:6078e430af82 | 275 | free(db_mem_device_link_key); |
todotani | 1:6078e430af82 | 276 | } |
todotani | 1:6078e430af82 | 277 | #endif |
todotani | 1:6078e430af82 | 278 | |
todotani | 1:6078e430af82 | 279 | |
todotani | 1:6078e430af82 | 280 | // MARK: db_mem_service_t |
todotani | 1:6078e430af82 | 281 | #ifdef MAX_NO_DB_MEM_SERVICES |
todotani | 1:6078e430af82 | 282 | #if MAX_NO_DB_MEM_SERVICES > 0 |
todotani | 1:6078e430af82 | 283 | static db_mem_service_t db_mem_service_storage[MAX_NO_DB_MEM_SERVICES]; |
todotani | 1:6078e430af82 | 284 | static memory_pool_t db_mem_service_pool; |
todotani | 1:6078e430af82 | 285 | void * btstack_memory_db_mem_service_get(void){ |
todotani | 1:6078e430af82 | 286 | return memory_pool_get(&db_mem_service_pool); |
todotani | 1:6078e430af82 | 287 | } |
todotani | 1:6078e430af82 | 288 | void btstack_memory_db_mem_service_free(void *db_mem_service){ |
todotani | 1:6078e430af82 | 289 | memory_pool_free(&db_mem_service_pool, db_mem_service); |
todotani | 1:6078e430af82 | 290 | } |
todotani | 1:6078e430af82 | 291 | #else |
todotani | 1:6078e430af82 | 292 | void * btstack_memory_db_mem_service_get(void){ |
todotani | 1:6078e430af82 | 293 | return NULL; |
todotani | 1:6078e430af82 | 294 | } |
todotani | 1:6078e430af82 | 295 | void btstack_memory_db_mem_service_free(void *db_mem_service){ |
todotani | 1:6078e430af82 | 296 | }; |
todotani | 1:6078e430af82 | 297 | #endif |
todotani | 1:6078e430af82 | 298 | #elif defined(HAVE_MALLOC) |
todotani | 1:6078e430af82 | 299 | void * btstack_memory_db_mem_service_get(void){ |
todotani | 1:6078e430af82 | 300 | return malloc(sizeof(db_mem_service_t)); |
todotani | 1:6078e430af82 | 301 | } |
todotani | 1:6078e430af82 | 302 | void btstack_memory_db_mem_service_free(void *db_mem_service){ |
todotani | 1:6078e430af82 | 303 | free(db_mem_service); |
todotani | 1:6078e430af82 | 304 | } |
todotani | 1:6078e430af82 | 305 | #endif |
todotani | 1:6078e430af82 | 306 | |
todotani | 1:6078e430af82 | 307 | // init |
todotani | 1:6078e430af82 | 308 | void btstack_memory_init(void){ |
todotani | 1:6078e430af82 | 309 | #if MAX_NO_HCI_CONNECTIONS > 0 |
todotani | 1:6078e430af82 | 310 | memory_pool_create(&hci_connection_pool, hci_connection_storage, MAX_NO_HCI_CONNECTIONS, sizeof(hci_connection_t)); |
todotani | 1:6078e430af82 | 311 | #endif |
todotani | 1:6078e430af82 | 312 | #if MAX_NO_L2CAP_SERVICES > 0 |
todotani | 1:6078e430af82 | 313 | memory_pool_create(&l2cap_service_pool, l2cap_service_storage, MAX_NO_L2CAP_SERVICES, sizeof(l2cap_service_t)); |
todotani | 1:6078e430af82 | 314 | #endif |
todotani | 1:6078e430af82 | 315 | #if MAX_NO_L2CAP_CHANNELS > 0 |
todotani | 1:6078e430af82 | 316 | memory_pool_create(&l2cap_channel_pool, l2cap_channel_storage, MAX_NO_L2CAP_CHANNELS, sizeof(l2cap_channel_t)); |
todotani | 1:6078e430af82 | 317 | #endif |
todotani | 1:6078e430af82 | 318 | #if MAX_NO_RFCOMM_MULTIPLEXERS > 0 |
todotani | 1:6078e430af82 | 319 | memory_pool_create(&rfcomm_multiplexer_pool, rfcomm_multiplexer_storage, MAX_NO_RFCOMM_MULTIPLEXERS, sizeof(rfcomm_multiplexer_t)); |
todotani | 1:6078e430af82 | 320 | #endif |
todotani | 1:6078e430af82 | 321 | #if MAX_NO_RFCOMM_SERVICES > 0 |
todotani | 1:6078e430af82 | 322 | memory_pool_create(&rfcomm_service_pool, rfcomm_service_storage, MAX_NO_RFCOMM_SERVICES, sizeof(rfcomm_service_t)); |
todotani | 1:6078e430af82 | 323 | #endif |
todotani | 1:6078e430af82 | 324 | #if MAX_NO_RFCOMM_CHANNELS > 0 |
todotani | 1:6078e430af82 | 325 | memory_pool_create(&rfcomm_channel_pool, rfcomm_channel_storage, MAX_NO_RFCOMM_CHANNELS, sizeof(rfcomm_channel_t)); |
todotani | 1:6078e430af82 | 326 | #endif |
todotani | 1:6078e430af82 | 327 | #if MAX_NO_DB_MEM_DEVICE_NAMES > 0 |
todotani | 1:6078e430af82 | 328 | memory_pool_create(&db_mem_device_name_pool, db_mem_device_name_storage, MAX_NO_DB_MEM_DEVICE_NAMES, sizeof(db_mem_device_name_t)); |
todotani | 1:6078e430af82 | 329 | #endif |
todotani | 1:6078e430af82 | 330 | #if MAX_NO_DB_MEM_DEVICE_LINK_KEYS > 0 |
todotani | 1:6078e430af82 | 331 | memory_pool_create(&db_mem_device_link_key_pool, db_mem_device_link_key_storage, MAX_NO_DB_MEM_DEVICE_LINK_KEYS, sizeof(db_mem_device_link_key_t)); |
todotani | 1:6078e430af82 | 332 | #endif |
todotani | 1:6078e430af82 | 333 | #if MAX_NO_DB_MEM_SERVICES > 0 |
todotani | 1:6078e430af82 | 334 | memory_pool_create(&db_mem_service_pool, db_mem_service_storage, MAX_NO_DB_MEM_SERVICES, sizeof(db_mem_service_t)); |
todotani | 1:6078e430af82 | 335 | #endif |
todotani | 1:6078e430af82 | 336 | } |