return NULL;
hci = new0(struct bt_hci, 1);
- if (!hci)
- return NULL;
-
hci->io = io_new(fd);
if (!hci->io) {
free(hci);
hci->next_evt_id = 1;
hci->cmd_queue = queue_new();
- if (!hci->cmd_queue) {
- io_destroy(hci->io);
- free(hci);
- return NULL;
- }
-
hci->rsp_queue = queue_new();
- if (!hci->rsp_queue) {
- queue_destroy(hci->cmd_queue, NULL);
- io_destroy(hci->io);
- free(hci);
- return NULL;
- }
-
hci->evt_list = queue_new();
- if (!hci->evt_list) {
- queue_destroy(hci->rsp_queue, NULL);
- queue_destroy(hci->cmd_queue, NULL);
- io_destroy(hci->io);
- free(hci);
- return NULL;
- }
if (!io_set_read_handler(hci->io, io_read_callback, hci, NULL)) {
queue_destroy(hci->evt_list, NULL);
return 0;
cmd = new0(struct cmd, 1);
- if (!cmd)
- return 0;
-
cmd->opcode = opcode;
cmd->size = size;
return 0;
evt = new0(struct evt, 1);
- if (!evt)
- return 0;
-
evt->event = event;
if (hci->next_evt_id < 1)