本文整理汇总了C++中osi_free函数的典型用法代码示例。如果您正苦于以下问题:C++ osi_free函数的具体用法?C++ osi_free怎么用?C++ osi_free使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了osi_free函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: btc_ble_gattc_get_include_service
esp_gatt_status_t btc_ble_gattc_get_include_service(uint16_t conn_id,
uint16_t start_handle,
uint16_t end_handle,
esp_bt_uuid_t *incl_uuid,
esp_gattc_incl_svc_elem_t *result,
uint16_t *count)
{
esp_gatt_status_t status;
btgatt_db_element_t *db = NULL;
int incl_num = 0;
tBT_UUID bta_uuid = {0};
if (incl_uuid != NULL) {
btc_to_bta_uuid(&bta_uuid, incl_uuid);
BTA_GATTC_GetIncludeService(conn_id, start_handle, end_handle, &bta_uuid, &db, &incl_num);
} else {
BTA_GATTC_GetIncludeService(conn_id, start_handle, end_handle, NULL, &db, &incl_num);
}
if ((status = btc_gattc_check_valid_param(incl_num, 0)) != ESP_GATT_OK) {
if (db) {
osi_free(db);
}
return status;
}else {
btc_gattc_fill_gatt_db_conversion(*count, (uint16_t)incl_num, ESP_GATT_DB_INCLUDED_SERVICE, 0, (void *)result, db);
}
*count = incl_num;
//don't forget to free the db buffer after used.
if (db) {
osi_free(db);
}
return ESP_GATT_OK;
}
示例2: avdt_ccb_clear_ccb
/*******************************************************************************
**
** Function avdt_ccb_clear_ccb
**
** Description This function clears out certain buffers, queues, and
** other data elements of a ccb.
**
**
** Returns void.
**
*******************************************************************************/
static void avdt_ccb_clear_ccb(tAVDT_CCB *p_ccb)
{
BT_HDR *p_buf;
/* clear certain ccb variables */
p_ccb->cong = FALSE;
p_ccb->ret_count = 0;
/* free message being fragmented */
if (p_ccb->p_curr_msg != NULL) {
osi_free(p_ccb->p_curr_msg);
p_ccb->p_curr_msg = NULL;
}
/* free message being reassembled */
if (p_ccb->p_rx_msg != NULL) {
osi_free(p_ccb->p_rx_msg);
p_ccb->p_rx_msg = NULL;
}
/* clear out response queue */
while ((p_buf = (BT_HDR *) fixed_queue_try_dequeue(p_ccb->rsp_q)) != NULL) {
osi_free(p_buf);
}
}
示例3: bta_hf_client_at_parse
/******************************************************************************
**
** MAIN PARSING FUNCTION
**
**
*******************************************************************************/
void bta_hf_client_at_parse(char *buf, unsigned int len)
{
APPL_TRACE_DEBUG("%s offset: %u len: %u", __FUNCTION__, bta_hf_client_cb.scb.at_cb.offset, len);
if (len + bta_hf_client_cb.scb.at_cb.offset > BTA_HF_CLIENT_AT_PARSER_MAX_LEN) {
unsigned int tmp = bta_hf_client_cb.scb.at_cb.offset;
unsigned int space_left = BTA_HF_CLIENT_AT_PARSER_MAX_LEN - bta_hf_client_cb.scb.at_cb.offset;
char *tmp_buff = osi_malloc(BTA_HF_CLIENT_AT_PARSER_MAX_LEN);
if (tmp_buff == NULL) {
APPL_TRACE_ERROR("No mem %s", __FUNCTION__);
return;
}
APPL_TRACE_DEBUG("%s overrun, trying to recover", __FUNCTION__);
/* fill up parser buffer */
memcpy(bta_hf_client_cb.scb.at_cb.buf + bta_hf_client_cb.scb.at_cb.offset, buf, space_left);
len -= space_left;
buf += space_left;
bta_hf_client_cb.scb.at_cb.offset += space_left;
/* find end of last complete command before proceeding */
while (bta_hf_client_check_at_complete() == FALSE) {
if (bta_hf_client_cb.scb.at_cb.offset == 0) {
APPL_TRACE_ERROR("HFPClient: AT parser buffer overrun, disconnecting");
bta_hf_client_at_reset();
bta_hf_client_sm_execute(BTA_HF_CLIENT_API_CLOSE_EVT, NULL);
osi_free(tmp_buff);
return;
}
bta_hf_client_cb.scb.at_cb.offset--;
}
/* cut buffer to complete AT event and keep cut data */
tmp += space_left - bta_hf_client_cb.scb.at_cb.offset;
memcpy(tmp_buff, bta_hf_client_cb.scb.at_cb.buf + bta_hf_client_cb.scb.at_cb.offset, tmp);
bta_hf_client_cb.scb.at_cb.buf[bta_hf_client_cb.scb.at_cb.offset] = '\0';
/* parse */
bta_hf_client_at_parse_start();
bta_hf_client_at_clear_buf();
/* recover cut data */
memcpy(bta_hf_client_cb.scb.at_cb.buf, tmp_buff, tmp);
bta_hf_client_cb.scb.at_cb.offset += tmp;
osi_free(tmp_buff);
}
memcpy(bta_hf_client_cb.scb.at_cb.buf + bta_hf_client_cb.scb.at_cb.offset, buf, len);
bta_hf_client_cb.scb.at_cb.offset += len;
/* If last event is complete, parsing can be started */
if (bta_hf_client_check_at_complete() == TRUE) {
bta_hf_client_at_parse_start();
bta_hf_client_at_clear_buf();
}
}
示例4: rfc_port_sm_sabme_wait_ua
/*******************************************************************************
**
** Function rfc_port_sm_sabme_wait_ua
**
** Description This function handles events when SABME on the DLC was
** sent and SM is waiting for UA or DM.
**
** Returns void
**
*******************************************************************************/
void rfc_port_sm_sabme_wait_ua (tPORT *p_port, UINT16 event, void *p_data)
{
switch (event) {
case RFC_EVENT_OPEN:
case RFC_EVENT_ESTABLISH_RSP:
RFCOMM_TRACE_ERROR ("Port error state %d event %d", p_port->rfc.state, event);
return;
case RFC_EVENT_CLOSE:
rfc_port_timer_start (p_port, RFC_DISC_TIMEOUT);
rfc_send_disc (p_port->rfc.p_mcb, p_port->dlci);
p_port->rfc.expected_rsp = 0;
p_port->rfc.state = RFC_STATE_DISC_WAIT_UA;
return;
case RFC_EVENT_CLEAR:
rfc_port_closed (p_port);
return;
case RFC_EVENT_DATA:
osi_free (p_data);
break;
case RFC_EVENT_UA:
rfc_port_timer_stop (p_port);
p_port->rfc.state = RFC_STATE_OPENED;
PORT_DlcEstablishCnf (p_port->rfc.p_mcb, p_port->dlci, p_port->rfc.p_mcb->peer_l2cap_mtu, RFCOMM_SUCCESS);
return;
case RFC_EVENT_DM:
p_port->rfc.p_mcb->is_disc_initiator = TRUE;
PORT_DlcEstablishCnf (p_port->rfc.p_mcb, p_port->dlci, p_port->rfc.p_mcb->peer_l2cap_mtu, RFCOMM_ERROR);
rfc_port_closed (p_port);
return;
case RFC_EVENT_DISC:
rfc_send_ua (p_port->rfc.p_mcb, p_port->dlci);
PORT_DlcEstablishCnf (p_port->rfc.p_mcb, p_port->dlci, p_port->rfc.p_mcb->peer_l2cap_mtu, RFCOMM_ERROR);
rfc_port_closed (p_port);
return;
case RFC_EVENT_SABME:
/* Continue to wait for the UA the SABME this side sent */
rfc_send_ua (p_port->rfc.p_mcb, p_port->dlci);
return;
case RFC_EVENT_UIH:
osi_free (p_data);
return;
case RFC_EVENT_TIMEOUT:
p_port->rfc.state = RFC_STATE_CLOSED;
PORT_DlcEstablishCnf (p_port->rfc.p_mcb, p_port->dlci, p_port->rfc.p_mcb->peer_l2cap_mtu, RFCOMM_ERROR);
return;
}
RFCOMM_TRACE_WARNING ("Port state sabme_wait_ua Event ignored %d", event);
}
示例5: rfc_port_sm_state_closed
/*******************************************************************************
**
** Function rfc_port_sm_state_closed
**
** Description This function handles events when the port is in
** CLOSED state. This state exists when port is
** being initially established.
**
** Returns void
**
*******************************************************************************/
void rfc_port_sm_state_closed (tPORT *p_port, UINT16 event, void *p_data)
{
switch (event) {
case RFC_EVENT_OPEN:
p_port->rfc.state = RFC_STATE_ORIG_WAIT_SEC_CHECK;
btm_sec_mx_access_request (p_port->rfc.p_mcb->bd_addr, BT_PSM_RFCOMM, TRUE,
BTM_SEC_PROTO_RFCOMM, (UINT32)(p_port->dlci / 2),
&rfc_sec_check_complete, p_port);
return;
case RFC_EVENT_CLOSE:
break;
case RFC_EVENT_CLEAR:
return;
case RFC_EVENT_DATA:
osi_free (p_data);
break;
case RFC_EVENT_SABME:
/* make sure the multiplexer disconnect timer is not running (reconnect case) */
rfc_timer_stop(p_port->rfc.p_mcb );
/* Open will be continued after security checks are passed */
p_port->rfc.state = RFC_STATE_TERM_WAIT_SEC_CHECK;
btm_sec_mx_access_request (p_port->rfc.p_mcb->bd_addr, BT_PSM_RFCOMM, FALSE,
BTM_SEC_PROTO_RFCOMM, (UINT32)(p_port->dlci / 2),
&rfc_sec_check_complete, p_port);
return;
case RFC_EVENT_UA:
return;
case RFC_EVENT_DM:
rfc_port_closed (p_port);
return;
case RFC_EVENT_UIH:
osi_free (p_data);
rfc_send_dm (p_port->rfc.p_mcb, p_port->dlci, FALSE);
return;
case RFC_EVENT_DISC:
rfc_send_dm (p_port->rfc.p_mcb, p_port->dlci, FALSE);
return;
case RFC_EVENT_TIMEOUT:
Port_TimeOutCloseMux( p_port->rfc.p_mcb ) ;
RFCOMM_TRACE_ERROR ("Port error state %d event %d", p_port->rfc.state, event);
return;
}
RFCOMM_TRACE_WARNING ("Port state closed Event ignored %d", event);
return;
}
示例6: entry_free
static void entry_free(void *ptr)
{
if (!ptr) {
return;
}
entry_t *entry = ptr;
osi_free(entry->key);
osi_free(entry->value);
osi_free(entry);
}
示例7: section_free
static void section_free(void *ptr)
{
if (!ptr) {
return;
}
section_t *section = ptr;
osi_free(section->name);
list_free(section->entries);
osi_free(section);
}
示例8: data_dispatcher_free
void data_dispatcher_free(data_dispatcher_t *dispatcher) {
if (!dispatcher)
return;
hash_map_free(dispatcher->dispatch_table);
if (dispatcher->name)
osi_free(dispatcher->name);
osi_free(dispatcher);
}
示例9: buffer_free
void buffer_free(buffer_t *buffer) {
if (!buffer)
return;
if (buffer->root != buffer) {
// We're a leaf node. Delete the root node if we're the last referent.
if (--buffer->root->refcount == 0)
osi_free(buffer->root);
osi_free(buffer);
} else if (--buffer->refcount == 0) {
// We're a root node. Roots are only deleted when their refcount goes to 0.
osi_free(buffer);
}
}
示例10: osi_malloc
static char *bta_hf_client_parse_cind_list(char *buffer)
{
int offset;
char *name = osi_malloc(129);
UINT32 min, max;
UINT32 index = 0;
int res;
if (name == NULL) {
APPL_TRACE_ERROR("No mem %s", __FUNCTION__);
return NULL;
}
while ((res = sscanf(buffer, "(\"%128[^\"]\",(%u%*[-,]%u))%n", name, &min, &max, &offset)) > 2) {
bta_hf_client_handle_cind_list_item(name, min, max, index);
buffer += offset;
index++;
if (*buffer != ',') {
break;
}
buffer++;
}
osi_free(name);
if (res > 2) {
AT_CHECK_RN(buffer);
return buffer;
}
return NULL;
}
示例11: bta_hf_client_send_at_bia
void bta_hf_client_send_at_bia(void)
{
char *buf;
int at_len;
int i;
APPL_TRACE_DEBUG("%s", __FUNCTION__);
if (bta_hf_client_cb.scb.peer_version < HFP_VERSION_1_6) {
APPL_TRACE_DEBUG("Remote does not Support AT+BIA");
return;
}
buf = osi_malloc(BTA_HF_CLIENT_AT_MAX_LEN);
if (buf == NULL) {
APPL_TRACE_ERROR("No mem %s", __FUNCTION__);
return;
}
at_len = snprintf(buf, BTA_HF_CLIENT_AT_MAX_LEN, "AT+BIA=");
for (i = 0; i < BTA_HF_CLIENT_AT_INDICATOR_COUNT; i++) {
int sup = bta_hf_client_cb.scb.at_cb.indicator_lookup[i] == -1 ? 0 : 1;
at_len += snprintf(buf + at_len, BTA_HF_CLIENT_AT_MAX_LEN - at_len, "%u,", sup);
}
buf[at_len - 1] = '\r';
bta_hf_client_send_at(BTA_HF_CLIENT_AT_BIA, buf, at_len);
osi_free(buf);
}
示例12: btc_a2dp_sink_ctrl_handler
static void btc_a2dp_sink_ctrl_handler(BtTaskEvt_t *e)
{
if (e == NULL) {
return;
}
switch (e->sig) {
case BTC_MEDIA_TASK_SINK_INIT:
btc_a2dp_sink_thread_init(NULL);
break;
case BTC_MEDIA_TASK_SINK_CLEAN_UP:
btc_a2dp_sink_thread_cleanup(NULL);
break;
case BTC_MEDIA_AUDIO_SINK_CFG_UPDATE:
btc_a2dp_sink_handle_decoder_reset(e->par);
break;
case BTC_MEDIA_AUDIO_SINK_CLEAR_TRACK:
btc_a2dp_sink_handle_clear_track();
break;
case BTC_MEDIA_FLUSH_AA_RX:
btc_a2dp_sink_rx_flush();
break;
default:
APPL_TRACE_WARNING("media task unhandled evt: 0x%x\n", e->sig);
}
if (e->par != NULL) {
osi_free(e->par);
}
}
示例13: LOG_ERROR
socket_t *socket_new(void) {
socket_t *ret = (socket_t *)osi_calloc(sizeof(socket_t));
if (!ret) {
LOG_ERROR("%s unable to allocate memory for socket.", __func__);
goto error;
}
ret->fd = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
if (ret->fd == INVALID_FD) {
LOG_ERROR("%s unable to create socket: %s", __func__, strerror(errno));
goto error;
}
int enable = 1;
if (setsockopt(ret->fd, SOL_SOCKET, SO_REUSEADDR, &enable, sizeof(enable)) == -1) {
LOG_ERROR("%s unable to set SO_REUSEADDR: %s", __func__, strerror(errno));
goto error;
}
return ret;
error:;
if (ret)
close(ret->fd);
osi_free(ret);
return NULL;
}
示例14: avdt_ccb_cmd_fail
/*******************************************************************************
**
** Function avdt_ccb_cmd_fail
**
** Description This function is called when there is a response timeout.
** The currently pending command is freed and we fake a
** reject message back to ourselves.
**
**
** Returns void.
**
*******************************************************************************/
void avdt_ccb_cmd_fail(tAVDT_CCB *p_ccb, tAVDT_CCB_EVT *p_data)
{
tAVDT_MSG msg;
UINT8 evt;
tAVDT_SCB *p_scb;
if (p_ccb->p_curr_cmd != NULL) {
/* set up data */
msg.hdr.err_code = p_data->err_code;
msg.hdr.err_param = 0;
msg.hdr.ccb_idx = avdt_ccb_to_idx(p_ccb);
/* pretend that we received a rej message */
evt = avdt_msg_rej_2_evt[p_ccb->p_curr_cmd->event - 1];
if (evt & AVDT_CCB_MKR) {
avdt_ccb_event(p_ccb, (UINT8) (evt & ~AVDT_CCB_MKR), (tAVDT_CCB_EVT *) &msg);
} else {
/* we get the scb out of the current cmd */
p_scb = avdt_scb_by_hdl(*((UINT8 *)(p_ccb->p_curr_cmd + 1)));
if (p_scb != NULL) {
avdt_scb_event(p_scb, evt, (tAVDT_SCB_EVT *) &msg);
}
}
osi_free(p_ccb->p_curr_cmd);
p_ccb->p_curr_cmd = NULL;
}
}
示例15: non_repeating_timer_free
void non_repeating_timer_free(non_repeating_timer_t *timer) {
if (!timer)
return;
alarm_free(timer->alarm);
osi_free(timer);
}