mirror of
https://github.com/bluekitchen/btstack.git
synced 2024-12-29 09:26:08 +00:00
initialze other malloc'ed memory
This commit is contained in:
parent
6fff232482
commit
c77e7c454e
@ -133,6 +133,7 @@ static void btstack_run_loop_corefoundation_add_data_source(btstack_data_source_
|
||||
CFRunLoopSourceRef socket_run_loop = CFSocketCreateRunLoopSource ( kCFAllocatorDefault, socket, 0);
|
||||
|
||||
// store CFSocketRef and CFRunLoopSource in struct on heap
|
||||
memset(references, 0, sizeof(btstack_corefoundation_data_source_helper_t));
|
||||
references->socket = socket;
|
||||
references->socket_run_loop = socket_run_loop;
|
||||
|
||||
|
@ -282,6 +282,7 @@ static void add_uint32_to_list(btstack_linked_list_t *list, uint32_t value){
|
||||
|
||||
btstack_linked_list_uint32_t * item = malloc(sizeof(btstack_linked_list_uint32_t));
|
||||
if (!item) return;
|
||||
memset(item, 0, sizeof(btstack_linked_list_uint32_t));
|
||||
item->value = value;
|
||||
btstack_linked_list_add(list, (btstack_linked_item_t *) item);
|
||||
}
|
||||
@ -1311,6 +1312,7 @@ static int btstack_command_handler(connection_t *connection, uint8_t *packet, ui
|
||||
// start listening
|
||||
btstack_linked_list_gatt_client_notification_t * linked_notification = malloc(sizeof(btstack_linked_list_gatt_client_notification_t));
|
||||
if (!linked_notification) break;
|
||||
memset(linked_notification, 0, sizeof(btstack_linked_list_gatt_client_notification_t));
|
||||
log_info("Start gatt notification listener %p", linked_notification);
|
||||
gatt_client_listen_for_characteristic_value_updates(&linked_notification->notification_listener, &handle_gatt_client_event, gatt_helper->con_handle, &characteristic);
|
||||
btstack_linked_list_add(&gatt_helper->gatt_client_notifications, (btstack_linked_item_t *) linked_notification);
|
||||
|
@ -78,6 +78,7 @@ uint8_t rfcomm_service_db_channel_for_service(const char *serviceName){
|
||||
|
||||
if (!newItem) return 0;
|
||||
|
||||
memset(new, 0, sizeof(db_mem_service_t));
|
||||
strncpy(newItem->service_name, serviceName, MAX_NAME_LEN);
|
||||
newItem->service_name[MAX_NAME_LEN] = 0;
|
||||
newItem->channel = max_channel;
|
||||
|
@ -1100,6 +1100,7 @@ static int usb_open(void){
|
||||
usb_close();
|
||||
return 1;
|
||||
}
|
||||
memset(pollfd_data_sources, 0, sizeof(btstack_data_source_t) * num_pollfds);
|
||||
for (r = 0 ; r < num_pollfds ; r++) {
|
||||
btstack_data_source_t *ds = &pollfd_data_sources[r];
|
||||
btstack_run_loop_set_data_source_fd(ds, pollfd[r]->fd);
|
||||
|
@ -146,8 +146,10 @@ static int btstack_tlv_posix_store_tag(void * context, uint32_t tag, const uint8
|
||||
}
|
||||
|
||||
// create new entry
|
||||
tlv_entry_t * new_entry = (tlv_entry_t *) malloc(sizeof(tlv_entry_t) - DUMMY_SIZE + data_size);
|
||||
uint32_t entry_size = sizeof(tlv_entry_t) - DUMMY_SIZE + data_size;
|
||||
tlv_entry_t * new_entry = (tlv_entry_t *) malloc(entry_size);
|
||||
if (!new_entry) return 0;
|
||||
memset(new_entry, 0, entry_size);
|
||||
new_entry->tag = tag;
|
||||
new_entry->len = data_size;
|
||||
memcpy(&new_entry->value[0], data, data_size);
|
||||
|
Loading…
Reference in New Issue
Block a user