prefix linked_list

This commit is contained in:
Matthias Ringwald 2015-12-22 21:48:13 +01:00
parent 8b7ee932e0
commit 8736ab0cf2
26 changed files with 84 additions and 84 deletions

View File

@ -56,7 +56,7 @@
#include <getopt.h>
#include "btstack.h"
#include "linked_list.h"
#include "bk_linked_list.h"
#include "run_loop.h"
#include "hci_cmds.h"
#include "version.h"
@ -122,12 +122,12 @@ typedef struct {
// connection
connection_t * connection;
linked_list_t rfcomm_cids;
linked_list_t rfcomm_services;
linked_list_t l2cap_cids;
linked_list_t l2cap_psms;
linked_list_t sdp_record_handles;
linked_list_t gatt_con_handles;
bk_linked_list_t rfcomm_cids;
bk_linked_list_t rfcomm_services;
bk_linked_list_t l2cap_cids;
bk_linked_list_t l2cap_psms;
bk_linked_list_t sdp_record_handles;
bk_linked_list_t gatt_con_handles;
// power mode
HCI_POWER_MODE power_mode;
@ -150,7 +150,7 @@ typedef struct linked_list_gatt_client_helper{
linked_item_t item;
uint16_t con_handle;
connection_t * active_connection; // the one that started the current query
linked_list_t all_connections; // list of all connections that ever used this helper
bk_linked_list_t all_connections; // list of all connections that ever used this helper
uint16_t characteristic_length;
uint16_t characteristic_handle;
uint8_t characteristic_buffer[10 + ATT_MAX_LONG_ATTRIBUTE_SIZE]; // header for sending event right away
@ -176,9 +176,9 @@ static hci_uart_config_t config;
static timer_source_t timeout;
static uint8_t timeout_active = 0;
static int power_management_sleep = 0;
static linked_list_t clients = NULL; // list of connected clients `
static bk_linked_list_t clients = NULL; // list of connected clients `
#ifdef HAVE_BLE
static linked_list_t gatt_client_helpers = NULL; // list of used gatt client (helpers)
static bk_linked_list_t gatt_client_helpers = NULL; // list of used gatt client (helpers)
static uint16_t gatt_client_id = 0;
#endif
@ -208,7 +208,7 @@ static void daemon_no_connections_timeout(struct timer *ts){
}
static void add_uint32_to_list(linked_list_t *list, uint32_t value){
static void add_uint32_to_list(bk_linked_list_t *list, uint32_t value){
linked_list_iterator_t it;
linked_list_iterator_init(&it, list);
while (linked_list_iterator_has_next(&it)){
@ -222,7 +222,7 @@ static void add_uint32_to_list(linked_list_t *list, uint32_t value){
linked_list_add(list, (linked_item_t *) item);
}
static void remove_and_free_uint32_from_list(linked_list_t *list, uint32_t value){
static void remove_and_free_uint32_from_list(bk_linked_list_t *list, uint32_t value){
linked_list_iterator_t it;
linked_list_iterator_init(&it, list);
while (linked_list_iterator_has_next(&it)){
@ -451,8 +451,8 @@ static void daemon_remove_gatt_client_helper(uint32_t con_handle){
static void daemon_rfcomm_close_connection(client_state_t * daemon_client){
linked_list_iterator_t it;
linked_list_t *rfcomm_services = &daemon_client->rfcomm_services;
linked_list_t *rfcomm_cids = &daemon_client->rfcomm_cids;
bk_linked_list_t *rfcomm_services = &daemon_client->rfcomm_services;
bk_linked_list_t *rfcomm_cids = &daemon_client->rfcomm_cids;
linked_list_iterator_init(&it, rfcomm_services);
while (linked_list_iterator_has_next(&it)){
@ -474,8 +474,8 @@ static void daemon_rfcomm_close_connection(client_state_t * daemon_client){
static void daemon_l2cap_close_connection(client_state_t * daemon_client){
linked_list_iterator_t it;
linked_list_t *l2cap_psms = &daemon_client->l2cap_psms;
linked_list_t *l2cap_cids = &daemon_client->l2cap_cids;
bk_linked_list_t *l2cap_psms = &daemon_client->l2cap_psms;
bk_linked_list_t *l2cap_cids = &daemon_client->l2cap_cids;
linked_list_iterator_init(&it, l2cap_psms);
while (linked_list_iterator_has_next(&it)){
@ -495,7 +495,7 @@ static void daemon_l2cap_close_connection(client_state_t * daemon_client){
}
static void daemon_sdp_close_connection(client_state_t * daemon_client){
linked_list_t * list = &daemon_client->sdp_record_handles;
bk_linked_list_t * list = &daemon_client->sdp_record_handles;
linked_list_iterator_t it;
linked_list_iterator_init(&it, list);
while (linked_list_iterator_has_next(&it)){

View File

@ -120,8 +120,8 @@ struct connection {
};
/** list of socket connections */
static linked_list_t connections = NULL;
static linked_list_t parked = NULL;
static bk_linked_list_t connections = NULL;
static bk_linked_list_t parked = NULL;
/** client packet handler */

View File

@ -54,7 +54,7 @@
#include "run_loop.h"
#include "linked_list.h"
#include "bk_linked_list.h"
#include "hal_tick.h"
#include "hal_cpu.h"
@ -76,10 +76,10 @@
#endif
// the run loop
static linked_list_t data_sources;
static bk_linked_list_t data_sources;
#ifdef TIMER_SUPPORT
static linked_list_t timers;
static bk_linked_list_t timers;
#endif
#ifdef HAVE_TICK

View File

@ -42,7 +42,7 @@
*/
#include "run_loop.h"
#include "linked_list.h"
#include "bk_linked_list.h"
#include "debug.h"
#include "run_loop_private.h"
@ -61,9 +61,9 @@ static int posix_timeval_compare(struct timeval *a, struct timeval *b);
static int posix_timer_compare(timer_source_t *a, timer_source_t *b);
// the run loop
static linked_list_t data_sources;
static bk_linked_list_t data_sources;
static int data_sources_modified;
static linked_list_t timers;
static bk_linked_list_t timers;
static struct timeval init_tv;
/**
* Add data_source to run_loop

View File

@ -41,21 +41,21 @@
* Created by Matthias Ringwald on 7/13/09.
*/
#include "linked_list.h"
#include "bk_linked_list.h"
#include <stdlib.h>
#include <stdio.h>
/**
* tests if list is empty
*/
int linked_list_empty(linked_list_t * list){
int linked_list_empty(bk_linked_list_t * list){
return *list == (void *) 0;
}
/**
* linked_list_get_last_item
*/
linked_item_t * linked_list_get_last_item(linked_list_t * list){ // <-- find the last item in the list
linked_item_t * linked_list_get_last_item(bk_linked_list_t * list){ // <-- find the last item in the list
linked_item_t *lastItem = NULL;
linked_item_t *it;
for (it = *list; it ; it = it->next){
@ -70,7 +70,7 @@ linked_item_t * linked_list_get_last_item(linked_list_t * list){ // <-- f
/**
* linked_list_add
*/
void linked_list_add(linked_list_t * list, linked_item_t *item){ // <-- add item to list
void linked_list_add(bk_linked_list_t * list, linked_item_t *item){ // <-- add item to list
// check if already in list
linked_item_t *it;
for (it = *list; it ; it = it->next){
@ -83,7 +83,7 @@ void linked_list_add(linked_list_t * list, linked_item_t *item){ // <-- a
*list = item;
}
void linked_list_add_tail(linked_list_t * list, linked_item_t *item){ // <-- add item to list as last element
void linked_list_add_tail(bk_linked_list_t * list, linked_item_t *item){ // <-- add item to list as last element
// check if already in list
linked_item_t *it;
for (it = (linked_item_t *) list; it->next ; it = it->next){
@ -100,7 +100,7 @@ void linked_list_add_tail(linked_list_t * list, linked_item_t *item){ // <-- a
*
* @note: assumes that data_source_t.next is first element in data_source
*/
int linked_list_remove(linked_list_t * list, linked_item_t *item){ // <-- remove item from list
int linked_list_remove(bk_linked_list_t * list, linked_item_t *item){ // <-- remove item from list
if (!item) return -1;
linked_item_t *it;
for (it = (linked_item_t *) list; it ; it = it->next){
@ -115,7 +115,7 @@ int linked_list_remove(linked_list_t * list, linked_item_t *item){ // <-- re
/**
* @returns number of items in list
*/
int linked_list_count(linked_list_t * list){
int linked_list_count(bk_linked_list_t * list){
linked_item_t *it;
int counter = 0;
for (it = (linked_item_t *) list; it ; it = it->next) {
@ -138,7 +138,7 @@ void * linked_item_get_user(linked_item_t *item) {
// Linked List Iterator implementation
//
void linked_list_iterator_init(linked_list_iterator_t * it, linked_list_t * head){
void linked_list_iterator_init(linked_list_iterator_t * it, bk_linked_list_t * head){
it->advance_on_next = 0;
it->prev = (linked_item_t*) head;
it->curr = * head;

View File

@ -53,7 +53,7 @@ typedef struct linked_item {
void *user_data; // <-- pointer to struct base
} linked_item_t;
typedef linked_item_t * linked_list_t;
typedef linked_item_t * bk_linked_list_t;
typedef struct {
int advance_on_next;
@ -64,22 +64,22 @@ typedef struct {
void linked_item_set_user(linked_item_t *item, void *user_data); // <-- set user data
void * linked_item_get_user(linked_item_t *item); // <-- get user data
int linked_list_empty(linked_list_t * list);
void linked_list_add(linked_list_t * list, linked_item_t *item); // <-- add item to list as first element
void linked_list_add_tail(linked_list_t * list, linked_item_t *item); // <-- add item to list as last element
int linked_list_remove(linked_list_t * list, linked_item_t *item); // <-- remove item from list
linked_item_t * linked_list_get_last_item(linked_list_t * list); // <-- find the last item in the list
int linked_list_empty(bk_linked_list_t * list);
void linked_list_add(bk_linked_list_t * list, linked_item_t *item); // <-- add item to list as first element
void linked_list_add_tail(bk_linked_list_t * list, linked_item_t *item); // <-- add item to list as last element
int linked_list_remove(bk_linked_list_t * list, linked_item_t *item); // <-- remove item from list
linked_item_t * linked_list_get_last_item(bk_linked_list_t * list); // <-- find the last item in the list
/**
* @brief Counts number of items in list
* @returns number of items in list
*/
int linked_list_count(linked_list_t * list);
int linked_list_count(bk_linked_list_t * list);
//
// iterator for linked lists. alloes to remove current element. also robust against removal of current element by linked_list_remove
//
void linked_list_iterator_init(linked_list_iterator_t * it, linked_list_t * list);
void linked_list_iterator_init(linked_list_iterator_t * it, bk_linked_list_t * list);
int linked_list_iterator_has_next(linked_list_iterator_t * it);
linked_item_t * linked_list_iterator_next(linked_list_iterator_t * it);
void linked_list_iterator_remove(linked_list_iterator_t * it);

View File

@ -59,8 +59,8 @@
#include "ble/sm.h"
#include "ble/le_device_db.h"
static linked_list_t gatt_client_connections = NULL;
static linked_list_t gatt_subclients = NULL;
static bk_linked_list_t gatt_client_connections = NULL;
static bk_linked_list_t gatt_subclients = NULL;
static uint16_t next_gatt_client_id = 0;
static uint8_t pts_suppress_mtu_exchange;

View File

@ -39,7 +39,7 @@
#include <string.h>
#include <inttypes.h>
#include "linked_list.h"
#include "bk_linked_list.h"
#include "btstack_memory.h"
#include "debug.h"
@ -164,7 +164,7 @@ static uint8_t sm_address_resolution_addr_type;
static bd_addr_t sm_address_resolution_address;
static void * sm_address_resolution_context;
static address_resolution_mode_t sm_address_resolution_mode;
static linked_list_t sm_address_resolution_general_queue;
static bk_linked_list_t sm_address_resolution_general_queue;
// aes128 crypto engine. store current sm_connection_t in sm_aes128_context
static sm_aes128_state_t sm_aes128_state;

View File

@ -59,7 +59,7 @@
#include "hci_transport.h"
#include "l2cap.h"
#include "l2cap_signaling.h"
#include "linked_list.h"
#include "bk_linked_list.h"
#include "memory_pool.h"
#include "run_loop.h"
#include "run_loop_private.h"

View File

@ -61,8 +61,8 @@
#define BNEP_CONNECTION_TIMEOUT_MS 10000
#define BNEP_CONNECTION_MAX_RETRIES 1
static linked_list_t bnep_services = NULL;
static linked_list_t bnep_channels = NULL;
static bk_linked_list_t bnep_services = NULL;
static bk_linked_list_t bnep_channels = NULL;
static gap_security_level_t bnep_security_level;

View File

@ -100,7 +100,7 @@ static const char * hfp_ag_features[] = {
static int hfp_generic_status_indicators_nr = 0;
static hfp_generic_status_indicator_t hfp_generic_status_indicators[HFP_MAX_NUM_HF_INDICATORS];
static linked_list_t hfp_connections = NULL;
static bk_linked_list_t hfp_connections = NULL;
static void parse_sequence(hfp_connection_t * context);
hfp_generic_status_indicator_t * get_hfp_generic_status_indicators(void){
@ -229,8 +229,8 @@ static void hfp_emit_audio_connection_established_event(hfp_callback_t callback,
(*callback)(event, sizeof(event));
}
linked_list_t * hfp_get_connections(){
return (linked_list_t *) &hfp_connections;
bk_linked_list_t * hfp_get_connections(){
return (bk_linked_list_t *) &hfp_connections;
}
hfp_connection_t * get_hfp_connection_context_for_rfcomm_cid(uint16_t cid){

View File

@ -620,7 +620,7 @@ int get_hfp_generic_status_indicators_nr(void);
hfp_generic_status_indicator_t * get_hfp_generic_status_indicators(void);
void set_hfp_generic_status_indicators(hfp_generic_status_indicator_t * indicators, int indicator_nr);
linked_list_t * hfp_get_connections(void);
bk_linked_list_t * hfp_get_connections(void);
void hfp_parse(hfp_connection_t * context, uint8_t byte, int isHandsFree);
void hfp_init(uint16_t rfcomm_channel_nr);

View File

@ -92,7 +92,7 @@ const remote_device_db_t * remote_device_db_fs_instance(void);
/* API_END */
// MARK: non-persistent implementation
#include "linked_list.h"
#include "bk_linked_list.h"
#define MAX_NAME_LEN 32
typedef struct {
// linked list - assert: first field

View File

@ -43,12 +43,12 @@
#include "debug.h"
#include "utils.h"
#include "linked_list.h"
#include "bk_linked_list.h"
// This lists should be only accessed by tests.
linked_list_t db_mem_link_keys = NULL;
linked_list_t db_mem_names = NULL;
static linked_list_t db_mem_services = NULL;
bk_linked_list_t db_mem_link_keys = NULL;
bk_linked_list_t db_mem_names = NULL;
static bk_linked_list_t db_mem_services = NULL;
// Device info
static void db_open(void){
@ -57,7 +57,7 @@ static void db_open(void){
static void db_close(void){
}
static db_mem_device_t * get_item(linked_list_t list, bd_addr_t bd_addr) {
static db_mem_device_t * get_item(bk_linked_list_t list, bd_addr_t bd_addr) {
linked_item_t *it;
for (it = (linked_item_t *) list; it ; it = it->next){
db_mem_device_t * item = (db_mem_device_t *) it;

View File

@ -78,9 +78,9 @@
static uint16_t rfcomm_client_cid_generator; // used for client channel IDs
// linked lists for all
static linked_list_t rfcomm_multiplexers = NULL;
static linked_list_t rfcomm_channels = NULL;
static linked_list_t rfcomm_services = NULL;
static bk_linked_list_t rfcomm_multiplexers = NULL;
static bk_linked_list_t rfcomm_channels = NULL;
static bk_linked_list_t rfcomm_services = NULL;
static gap_security_level_t rfcomm_security_level;

View File

@ -61,7 +61,7 @@
static void sdp_packet_handler(uint8_t packet_type, uint16_t channel, uint8_t *packet, uint16_t size);
// registered service records
static linked_list_t sdp_service_records = NULL;
static bk_linked_list_t sdp_service_records = NULL;
// our handles start after the reserved range
static uint32_t sdp_next_service_record_handle = ((uint32_t) maxReservedServiceRecordHandle) + 2;

View File

@ -38,7 +38,7 @@
#define __SDP_H
#include <stdint.h>
#include "linked_list.h"
#include "bk_linked_list.h"
#include "btstack-config.h"

View File

@ -69,7 +69,7 @@
#include "debug.h"
#include "hci_dump.h"
#include "linked_list.h"
#include "bk_linked_list.h"
#include "hci_cmds.h"
#define HCI_CONNECTION_TIMEOUT_MS 10000

View File

@ -52,7 +52,7 @@
#include "classic/remote_device_db.h"
#include "hci_cmds.h"
#include "hci_transport.h"
#include "linked_list.h"
#include "bk_linked_list.h"
#include "utils.h"
#include <stdint.h>
@ -521,7 +521,7 @@ typedef struct {
bt_control_t * control;
// list of existing baseband connections
linked_list_t connections;
bk_linked_list_t connections;
// single buffer for HCI packet assembly + additional prebuffer for H4 drivers
uint8_t hci_packet_buffer_prefix[HCI_OUTGOING_PRE_BUFFER_SIZE];
@ -621,7 +621,7 @@ typedef struct {
// LE Whitelist Management
uint16_t le_whitelist_capacity;
linked_list_t le_whitelist;
bk_linked_list_t le_whitelist;
// custom BD ADDR
bd_addr_t custom_bd_addr;

View File

@ -73,10 +73,10 @@ static void l2cap_packet_handler(uint8_t packet_type, uint8_t *packet, uint16_t
static l2cap_signaling_response_t signaling_responses[NR_PENDING_SIGNALING_RESPONSES];
static int signaling_responses_pending;
static linked_list_t l2cap_channels;
static linked_list_t l2cap_services;
static linked_list_t l2cap_le_channels;
static linked_list_t l2cap_le_services;
static bk_linked_list_t l2cap_channels;
static bk_linked_list_t l2cap_services;
static bk_linked_list_t l2cap_le_channels;
static bk_linked_list_t l2cap_le_services;
static void (*packet_handler) (uint8_t packet_type, uint16_t channel, uint8_t *packet, uint16_t size) = null_packet_handler;
static btstack_packet_handler_t attribute_protocol_packet_handler;
@ -1486,7 +1486,7 @@ void l2cap_finialize_channel_close(l2cap_channel_t *channel){
btstack_memory_l2cap_channel_free(channel);
}
static l2cap_service_t * l2cap_get_service_internal(linked_list_t * services, uint16_t psm){
static l2cap_service_t * l2cap_get_service_internal(bk_linked_list_t * services, uint16_t psm){
linked_list_iterator_t it;
linked_list_iterator_init(&it, services);
while (linked_list_iterator_has_next(&it)){

View File

@ -14,7 +14,7 @@
static btstack_packet_handler_t att_packet_handler;
static void (*registered_l2cap_packet_handler) (uint8_t packet_type, uint16_t channel, uint8_t *packet, uint16_t size) = NULL;
static linked_list_t connections;
static bk_linked_list_t connections;
static const uint16_t max_mtu = 23;
static uint8_t l2cap_stack_buffer[HCI_INCOMING_PRE_BUFFER_SIZE + 8 + max_mtu]; // pre buffer + HCI Header + L2CAP header
uint16_t gatt_client_handle = 0x40;

View File

@ -1 +1 @@
linked_list_test
bk_linked_list_test

View File

@ -17,14 +17,14 @@ COMMON = \
COMMON_OBJ = $(COMMON:.c=.o)
all: linked_list_test
all: bk_linked_list_test
linked_list_test: ${COMMON_OBJ} linked_list_test.c
bk_linked_list_test: ${COMMON_OBJ} bk_linked_list_test.c
${CC} $^ ${CFLAGS} ${LDFLAGS} -o $@
test: all
./linked_list_test
./bk_linked_list_test
clean:
rm -fr linked_list_test *.dSYM *.o ../src/*.o
rm -fr bk_linked_list_test *.dSYM *.o ../src/*.o

View File

@ -1,8 +1,8 @@
#include "CppUTest/TestHarness.h"
#include "CppUTest/CommandLineTestRunner.h"
#include "linked_list.h"
#include "bk_linked_list.h"
linked_list_t testList;
bk_linked_list_t testList;
linked_item_t itemA;
linked_item_t itemB;
linked_item_t itemC;

View File

@ -9,12 +9,12 @@
#include "btstack-config.h"
extern linked_list_t db_mem_link_keys ;
extern linked_list_t db_mem_names ;
extern bk_linked_list_t db_mem_link_keys ;
extern bk_linked_list_t db_mem_names ;
// const extern "C" db_mem_device_name_t * btstack_memory_db_mem_device_name_get(void);
// const extern "C" void btstack_memory_init(void);
void dump(linked_list_t list){
void dump(bk_linked_list_t list){
printf("dump:\n");
int i;

View File

@ -19,7 +19,7 @@ static uint16_t packet_buffer_len = 0;
static uint8_t aes128_cyphertext[16];
static hci_connection_t the_connection;
static linked_list_t connections;
static bk_linked_list_t connections;
void mock_init(void){
the_connection.item.next = NULL;