static oc_rep_t * _alloc_rep(void) { oc_rep_t *rep = os_memblock_get(&oc_rep_objects); #ifdef DEBUG oc_assert(rep != NULL); #endif return rep; }
static struct nffs_file * nffs_file_alloc(void) { struct nffs_file *file; file = os_memblock_get(&nffs_file_pool); if (file != NULL) { memset(file, 0, sizeof *file); } return file; }
static struct nffs_dir * nffs_dir_alloc(void) { struct nffs_dir *dir; dir = os_memblock_get(&nffs_dir_pool); if (dir != NULL) { memset(dir, 0, sizeof *dir); } return dir; }
struct nffs_hash_entry * nffs_block_entry_alloc(void) { struct nffs_hash_entry *entry; entry = os_memblock_get(&nffs_block_entry_pool); if (entry != NULL) { memset(entry, 0, sizeof *entry); } return entry; }
static struct ble_hci_sched_entry * ble_hci_sched_entry_alloc(void) { struct ble_hci_sched_entry *entry; entry = os_memblock_get(&ble_hci_sched_entry_pool); if (entry != NULL) { memset(entry, 0, sizeof *entry); } return entry; }
/* XXX: For now, put this here */ int ble_hci_transport_ctlr_event_send(uint8_t *hci_ev) { os_error_t err; struct os_event *ev; assert(hci_ev != NULL); /* Get an event structure off the queue */ ev = (struct os_event *)os_memblock_get(&g_hci_os_event_pool); if (!ev) { err = os_memblock_put(&g_hci_cmd_pool, hci_ev); assert(err == OS_OK); return -1; } /* Fill out the event and post to Link Layer */ ev->ev_queued = 0; ev->ev_type = BLE_HOST_HCI_EVENT_CTLR_EVENT; ev->ev_arg = hci_ev; os_eventq_put(&ble_hs_evq, ev); return 0; }
int host_hci_cmd_send(uint8_t ogf, uint8_t ocf, uint8_t len, void *cmddata) { int rc; uint8_t *cmd; uint16_t opcode; /* Don't allow multiple commands "in flight." */ assert(host_hci_outstanding_opcode == 0); rc = -1; cmd = os_memblock_get(&g_hci_cmd_pool); if (cmd) { opcode = (ogf << 10) | ocf; htole16(cmd, opcode); cmd[2] = len; if (len) { memcpy(cmd + BLE_HCI_CMD_HDR_LEN, cmddata, len); } rc = host_hci_cmd_transport(cmd); BLE_HS_LOG(DEBUG, "host_hci_cmd_send: ogf=0x%02x ocf=0x%02x len=%d\n", ogf, ocf, len); if (rc == 0) { host_hci_outstanding_opcode = opcode; } } /* Cancel ack callback if transmission failed. */ if (rc != 0) { ble_hci_sched_set_ack_cb(NULL, NULL); } else { STATS_INC(ble_hs_stats, hci_cmd); } return rc; }