mirror of
https://github.com/bluekitchen/btstack.git
synced 2025-02-11 00:40:00 +00:00
remove explicit memset call for buffers from btstack_memory
This commit is contained in:
parent
a2673d8810
commit
6fff232482
@ -162,7 +162,6 @@ static gatt_client_t * provide_context_for_conn_handle(hci_con_handle_t con_hand
|
|||||||
context = btstack_memory_gatt_client_get();
|
context = btstack_memory_gatt_client_get();
|
||||||
if (!context) return NULL;
|
if (!context) return NULL;
|
||||||
// init state
|
// init state
|
||||||
memset(context, 0, sizeof(gatt_client_t));
|
|
||||||
context->con_handle = con_handle;
|
context->con_handle = con_handle;
|
||||||
context->mtu = ATT_DEFAULT_MTU;
|
context->mtu = ATT_DEFAULT_MTU;
|
||||||
if (mtu_exchange_enabled){
|
if (mtu_exchange_enabled){
|
||||||
|
@ -316,7 +316,6 @@ avdtp_connection_t * avdtp_create_connection(bd_addr_t remote_addr, avdtp_contex
|
|||||||
log_error("Not enough memory to create connection");
|
log_error("Not enough memory to create connection");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
memset(connection, 0, sizeof(avdtp_connection_t));
|
|
||||||
connection->state = AVDTP_SIGNALING_CONNECTION_IDLE;
|
connection->state = AVDTP_SIGNALING_CONNECTION_IDLE;
|
||||||
connection->initiator_transaction_label = avdtp_get_next_initiator_transaction_label(context);
|
connection->initiator_transaction_label = avdtp_get_next_initiator_transaction_label(context);
|
||||||
connection->avdtp_cid = avdtp_get_next_avdtp_cid();
|
connection->avdtp_cid = avdtp_get_next_avdtp_cid();
|
||||||
@ -332,7 +331,6 @@ avdtp_stream_endpoint_t * avdtp_create_stream_endpoint(avdtp_sep_type_t sep_type
|
|||||||
log_error("Not enough memory to create stream endpoint");
|
log_error("Not enough memory to create stream endpoint");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
memset(stream_endpoint, 0, sizeof(avdtp_stream_endpoint_t));
|
|
||||||
stream_endpoint->sep.seid = avdtp_get_next_local_seid(context);
|
stream_endpoint->sep.seid = avdtp_get_next_local_seid(context);
|
||||||
stream_endpoint->sep.media_type = media_type;
|
stream_endpoint->sep.media_type = media_type;
|
||||||
stream_endpoint->sep.type = sep_type;
|
stream_endpoint->sep.type = sep_type;
|
||||||
|
@ -371,7 +371,6 @@ static avrcp_connection_t * avrcp_create_connection(bd_addr_t remote_addr, avrcp
|
|||||||
log_error("avrcp: not enough memory to create connection");
|
log_error("avrcp: not enough memory to create connection");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
memset(connection, 0, sizeof(avrcp_connection_t));
|
|
||||||
connection->state = AVCTP_CONNECTION_IDLE;
|
connection->state = AVCTP_CONNECTION_IDLE;
|
||||||
connection->transaction_label = 0xFF;
|
connection->transaction_label = 0xFF;
|
||||||
connection->max_num_fragments = 0xFF;
|
connection->max_num_fragments = 0xFF;
|
||||||
|
@ -127,7 +127,6 @@ static void avrcp_emit_browsing_connection_closed(btstack_packet_handler_t callb
|
|||||||
|
|
||||||
static avrcp_browsing_connection_t * avrcp_browsing_create_connection(avrcp_connection_t * avrcp_connection){
|
static avrcp_browsing_connection_t * avrcp_browsing_create_connection(avrcp_connection_t * avrcp_connection){
|
||||||
avrcp_browsing_connection_t * connection = btstack_memory_avrcp_browsing_connection_get();
|
avrcp_browsing_connection_t * connection = btstack_memory_avrcp_browsing_connection_get();
|
||||||
memset(connection, 0, sizeof(avrcp_browsing_connection_t));
|
|
||||||
connection->state = AVCTP_CONNECTION_IDLE;
|
connection->state = AVCTP_CONNECTION_IDLE;
|
||||||
connection->transaction_label = 0xFF;
|
connection->transaction_label = 0xFF;
|
||||||
avrcp_connection->avrcp_browsing_cid = avrcp_get_next_cid();
|
avrcp_connection->avrcp_browsing_cid = avrcp_get_next_cid();
|
||||||
|
@ -198,7 +198,6 @@ static void avrcp_emit_browsing_connection_closed(btstack_packet_handler_t callb
|
|||||||
|
|
||||||
static avrcp_browsing_connection_t * avrcp_browsing_create_connection(avrcp_connection_t * avrcp_connection){
|
static avrcp_browsing_connection_t * avrcp_browsing_create_connection(avrcp_connection_t * avrcp_connection){
|
||||||
avrcp_browsing_connection_t * connection = btstack_memory_avrcp_browsing_connection_get();
|
avrcp_browsing_connection_t * connection = btstack_memory_avrcp_browsing_connection_get();
|
||||||
memset(connection, 0, sizeof(avrcp_browsing_connection_t));
|
|
||||||
connection->state = AVCTP_CONNECTION_IDLE;
|
connection->state = AVCTP_CONNECTION_IDLE;
|
||||||
connection->transaction_label = 0xFF;
|
connection->transaction_label = 0xFF;
|
||||||
avrcp_connection->avrcp_browsing_cid = avrcp_get_next_cid();
|
avrcp_connection->avrcp_browsing_cid = avrcp_get_next_cid();
|
||||||
|
@ -703,9 +703,6 @@ static bnep_channel_t * bnep_channel_create_for_addr(bd_addr_t addr)
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Initialize the channel struct */
|
|
||||||
memset(channel, 0, sizeof(bnep_channel_t));
|
|
||||||
|
|
||||||
channel->state = BNEP_CHANNEL_STATE_CLOSED;
|
channel->state = BNEP_CHANNEL_STATE_CLOSED;
|
||||||
channel->max_frame_size = bnep_max_frame_size_for_l2cap_mtu(l2cap_max_mtu());
|
channel->max_frame_size = bnep_max_frame_size_for_l2cap_mtu(l2cap_max_mtu());
|
||||||
bd_addr_copy(channel->remote_addr, addr);
|
bd_addr_copy(channel->remote_addr, addr);
|
||||||
@ -1600,7 +1597,6 @@ uint8_t bnep_register_service(btstack_packet_handler_t packet_handler, uint16_t
|
|||||||
if (!service) {
|
if (!service) {
|
||||||
return BTSTACK_MEMORY_ALLOC_FAILED;
|
return BTSTACK_MEMORY_ALLOC_FAILED;
|
||||||
}
|
}
|
||||||
memset(service, 0, sizeof(bnep_service_t));
|
|
||||||
|
|
||||||
/* register with l2cap if not registered before, max MTU */
|
/* register with l2cap if not registered before, max MTU */
|
||||||
l2cap_register_service(bnep_packet_handler, BLUETOOTH_PROTOCOL_BNEP, 0xffff, bnep_security_level);
|
l2cap_register_service(bnep_packet_handler, BLUETOOTH_PROTOCOL_BNEP, 0xffff, bnep_security_level);
|
||||||
|
@ -355,8 +355,6 @@ void hfp_reset_context_flags(hfp_connection_t * hfp_connection){
|
|||||||
static hfp_connection_t * create_hfp_connection_context(void){
|
static hfp_connection_t * create_hfp_connection_context(void){
|
||||||
hfp_connection_t * hfp_connection = btstack_memory_hfp_connection_get();
|
hfp_connection_t * hfp_connection = btstack_memory_hfp_connection_get();
|
||||||
if (!hfp_connection) return NULL;
|
if (!hfp_connection) return NULL;
|
||||||
// init state
|
|
||||||
memset(hfp_connection,0, sizeof(hfp_connection_t));
|
|
||||||
|
|
||||||
hfp_connection->state = HFP_IDLE;
|
hfp_connection->state = HFP_IDLE;
|
||||||
hfp_connection->call_state = HFP_CALL_IDLE;
|
hfp_connection->call_state = HFP_CALL_IDLE;
|
||||||
|
@ -284,9 +284,6 @@ static uint16_t rfcomm_max_frame_size_for_l2cap_mtu(uint16_t l2cap_mtu){
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void rfcomm_multiplexer_initialize(rfcomm_multiplexer_t *multiplexer){
|
static void rfcomm_multiplexer_initialize(rfcomm_multiplexer_t *multiplexer){
|
||||||
|
|
||||||
memset(multiplexer, 0, sizeof(rfcomm_multiplexer_t));
|
|
||||||
|
|
||||||
multiplexer->state = RFCOMM_MULTIPLEXER_CLOSED;
|
multiplexer->state = RFCOMM_MULTIPLEXER_CLOSED;
|
||||||
multiplexer->fcon = 1;
|
multiplexer->fcon = 1;
|
||||||
multiplexer->send_dm_for_dlci = 0;
|
multiplexer->send_dm_for_dlci = 0;
|
||||||
@ -363,10 +360,7 @@ static void rfcomm_channel_initialize(rfcomm_channel_t *channel, rfcomm_multiple
|
|||||||
|
|
||||||
// don't use 0 as channel id
|
// don't use 0 as channel id
|
||||||
if (rfcomm_client_cid_generator == 0) ++rfcomm_client_cid_generator;
|
if (rfcomm_client_cid_generator == 0) ++rfcomm_client_cid_generator;
|
||||||
|
|
||||||
// setup channel
|
|
||||||
memset(channel, 0, sizeof(rfcomm_channel_t));
|
|
||||||
|
|
||||||
// set defaults for port configuration (even for services)
|
// set defaults for port configuration (even for services)
|
||||||
rfcomm_rpn_data_set_defaults(&channel->rpn_data);
|
rfcomm_rpn_data_set_defaults(&channel->rpn_data);
|
||||||
|
|
||||||
|
@ -186,7 +186,6 @@ static hci_connection_t * create_connection_for_bd_addr_and_type(bd_addr_t addr,
|
|||||||
log_info("create_connection_for_addr %s, type %x", bd_addr_to_str(addr), addr_type);
|
log_info("create_connection_for_addr %s, type %x", bd_addr_to_str(addr), addr_type);
|
||||||
hci_connection_t * conn = btstack_memory_hci_connection_get();
|
hci_connection_t * conn = btstack_memory_hci_connection_get();
|
||||||
if (!conn) return NULL;
|
if (!conn) return NULL;
|
||||||
memset(conn, 0, sizeof(hci_connection_t));
|
|
||||||
bd_addr_copy(conn->address, addr);
|
bd_addr_copy(conn->address, addr);
|
||||||
conn->address_type = addr_type;
|
conn->address_type = addr_type;
|
||||||
conn->con_handle = 0xffff;
|
conn->con_handle = 0xffff;
|
||||||
|
@ -1799,9 +1799,6 @@ static l2cap_channel_t * l2cap_create_channel_entry(btstack_packet_handler_t pac
|
|||||||
if (!channel) {
|
if (!channel) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Init memory (make valgrind happy)
|
|
||||||
memset(channel, 0, sizeof(l2cap_channel_t));
|
|
||||||
|
|
||||||
// fill in
|
// fill in
|
||||||
channel->packet_handler = packet_handler;
|
channel->packet_handler = packet_handler;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user