mirror of
https://github.com/bluekitchen/btstack.git
synced 2025-03-21 22:20:57 +00:00
added sm_lookup_entry_t to memory pools
This commit is contained in:
parent
d3862db066
commit
cf49570bee
@ -33,6 +33,6 @@
|
||||
#define MAX_ATT_DB_SIZE 200
|
||||
#define MAX_NO_HFP_CONNECTIONS 0
|
||||
#define MAX_NO_WHITELIST_ENTRIES 1
|
||||
|
||||
#define MAX_NO_SM_LOOKUP_ENTRIES 3
|
||||
|
||||
#endif
|
@ -36,6 +36,7 @@
|
||||
#define MAX_NO_DB_MEM_SERVICES 1
|
||||
#define MAX_NO_HFP_CONNECTIONS 0
|
||||
#define MAX_NO_WHITELIST_ENTRIES 1
|
||||
#define MAX_NO_SM_LOOKUP_ENTRIES 3
|
||||
|
||||
#endif
|
||||
|
||||
|
@ -36,6 +36,7 @@
|
||||
#define MAX_NO_DB_MEM_SERVICES 1
|
||||
#define MAX_NO_HFP_CONNECTIONS 0
|
||||
#define MAX_NO_WHITELIST_ENTRIES 1
|
||||
#define MAX_NO_SM_LOOKUP_ENTRIES 3
|
||||
|
||||
#endif
|
||||
|
||||
|
@ -36,6 +36,7 @@
|
||||
#define MAX_NO_DB_MEM_SERVICES 1
|
||||
#define MAX_NO_HFP_CONNECTIONS 0
|
||||
#define MAX_NO_WHITELIST_ENTRIES 1
|
||||
#define MAX_NO_SM_LOOKUP_ENTRIES 3
|
||||
|
||||
#endif
|
||||
|
||||
|
@ -33,5 +33,6 @@
|
||||
#define MAX_NO_BNEP_CHANNELS 0
|
||||
#define MAX_NO_HFP_CONNECTIONS 0
|
||||
#define MAX_NO_WHITELIST_ENTRIES 1
|
||||
#define MAX_NO_SM_LOOKUP_ENTRIES 3
|
||||
|
||||
#endif
|
@ -33,5 +33,6 @@
|
||||
#define MAX_NO_BNEP_CHANNELS 0
|
||||
#define MAX_NO_HFP_CONNECTIONS 0
|
||||
#define MAX_NO_WHITELIST_ENTRIES 1
|
||||
#define MAX_NO_SM_LOOKUP_ENTRIES 3
|
||||
|
||||
#endif
|
@ -539,6 +539,38 @@ void btstack_memory_whitelist_entry_free(whitelist_entry_t *whitelist_entry){
|
||||
#endif
|
||||
|
||||
|
||||
// MARK: sm_lookup_entry_t
|
||||
#ifdef MAX_NO_SM_LOOKUP_ENTRIES
|
||||
#if MAX_NO_SM_LOOKUP_ENTRIES > 0
|
||||
static sm_lookup_entry_t sm_lookup_entry_storage[MAX_NO_SM_LOOKUP_ENTRIES];
|
||||
static memory_pool_t sm_lookup_entry_pool;
|
||||
sm_lookup_entry_t * btstack_memory_sm_lookup_entry_get(void){
|
||||
return (sm_lookup_entry_t *) memory_pool_get(&sm_lookup_entry_pool);
|
||||
}
|
||||
void btstack_memory_sm_lookup_entry_free(sm_lookup_entry_t *sm_lookup_entry){
|
||||
memory_pool_free(&sm_lookup_entry_pool, sm_lookup_entry);
|
||||
}
|
||||
#else
|
||||
sm_lookup_entry_t * btstack_memory_sm_lookup_entry_get(void){
|
||||
return NULL;
|
||||
}
|
||||
void btstack_memory_sm_lookup_entry_free(sm_lookup_entry_t *sm_lookup_entry){
|
||||
// silence compiler warning about unused parameter in a portable way
|
||||
(void) sm_lookup_entry;
|
||||
};
|
||||
#endif
|
||||
#elif defined(HAVE_MALLOC)
|
||||
sm_lookup_entry_t * btstack_memory_sm_lookup_entry_get(void){
|
||||
return (sm_lookup_entry_t*) malloc(sizeof(sm_lookup_entry_t));
|
||||
}
|
||||
void btstack_memory_sm_lookup_entry_free(sm_lookup_entry_t *sm_lookup_entry){
|
||||
free(sm_lookup_entry);
|
||||
}
|
||||
#else
|
||||
#error "Neither HAVE_MALLOC nor MAX_NO_SM_LOOKUP_ENTRIES for struct sm_lookup_entry is defined. Please, edit the config file."
|
||||
#endif
|
||||
|
||||
|
||||
#endif
|
||||
// init
|
||||
void btstack_memory_init(void){
|
||||
@ -588,5 +620,8 @@ void btstack_memory_init(void){
|
||||
#if MAX_NO_WHITELIST_ENTRIES > 0
|
||||
memory_pool_create(&whitelist_entry_pool, whitelist_entry_storage, MAX_NO_WHITELIST_ENTRIES, sizeof(whitelist_entry_t));
|
||||
#endif
|
||||
#if MAX_NO_SM_LOOKUP_ENTRIES > 0
|
||||
memory_pool_create(&sm_lookup_entry_pool, sm_lookup_entry_storage, MAX_NO_SM_LOOKUP_ENTRIES, sizeof(sm_lookup_entry_t));
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
@ -38,7 +38,7 @@
|
||||
|
||||
|
||||
/*
|
||||
* btstsack_memory.h
|
||||
* btstack_memory.h
|
||||
*
|
||||
* @brief BTstack memory management via configurable memory pools
|
||||
*
|
||||
@ -62,6 +62,7 @@ extern "C" {
|
||||
|
||||
#ifdef HAVE_BLE
|
||||
#include "gatt_client.h"
|
||||
#include "sm.h"
|
||||
#endif
|
||||
|
||||
/* API_START */
|
||||
@ -110,13 +111,15 @@ hfp_connection_t * btstack_memory_hfp_connection_get(void);
|
||||
void btstack_memory_hfp_connection_free(hfp_connection_t *hfp_connection);
|
||||
|
||||
#ifdef HAVE_BLE
|
||||
// gatt_client, gatt_subclient, whitelist_entry
|
||||
// gatt_client, gatt_subclient, whitelist_entry, sm_lookup_entry
|
||||
gatt_client_t * btstack_memory_gatt_client_get(void);
|
||||
void btstack_memory_gatt_client_free(gatt_client_t *gatt_client);
|
||||
gatt_subclient_t * btstack_memory_gatt_subclient_get(void);
|
||||
void btstack_memory_gatt_subclient_free(gatt_subclient_t *gatt_subclient);
|
||||
whitelist_entry_t * btstack_memory_whitelist_entry_get(void);
|
||||
void btstack_memory_whitelist_entry_free(whitelist_entry_t *whitelist_entry);
|
||||
sm_lookup_entry_t * btstack_memory_sm_lookup_entry_get(void);
|
||||
void btstack_memory_sm_lookup_entry_free(sm_lookup_entry_t *sm_lookup_entry);
|
||||
#endif
|
||||
|
||||
#if defined __cplusplus
|
||||
|
@ -41,7 +41,7 @@ copyright = """/*
|
||||
hfile_header_begin = """
|
||||
|
||||
/*
|
||||
* btstsack_memory.h
|
||||
* btstack_memory.h
|
||||
*
|
||||
* @brief BTstack memory management via configurable memory pools
|
||||
*
|
||||
@ -65,6 +65,7 @@ extern "C" {
|
||||
|
||||
#ifdef HAVE_BLE
|
||||
#include "gatt_client.h"
|
||||
#include "sm.h"
|
||||
#endif
|
||||
|
||||
/* API_START */
|
||||
@ -156,7 +157,7 @@ def replacePlaceholder(template, struct_name):
|
||||
return snippet
|
||||
|
||||
list_of_structs = [ ["hci_connection"], ["l2cap_service", "l2cap_channel"], ["rfcomm_multiplexer", "rfcomm_service", "rfcomm_channel"], ["db_mem_device_name", "db_mem_device_link_key", "db_mem_service"], ["bnep_service", "bnep_channel"], ["hfp_connection"]]
|
||||
list_of_le_structs = [["gatt_client", "gatt_subclient","whitelist_entry"]]
|
||||
list_of_le_structs = [["gatt_client", "gatt_subclient", "whitelist_entry", "sm_lookup_entry"]]
|
||||
|
||||
file_name = "../src/btstack_memory"
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user