本文整理汇总了C++中sal_free函数的典型用法代码示例。如果您正苦于以下问题:C++ sal_free函数的具体用法?C++ sal_free怎么用?C++ sal_free使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了sal_free函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: sal_config_file_set
int
sal_config_file_set(const char *fname, const char *tname)
{
if (sal_config_file_name != NULL) {
sal_free(sal_config_file_name);
sal_config_file_name = NULL;
}
if (sal_config_temp_name != NULL) {
sal_free(sal_config_temp_name);
sal_config_temp_name = NULL;
}
if (fname != NULL) {
sal_config_file_name = sal_strdup(fname);
if (fname[0] != 0) {
if (tname == NULL || tname[0] == 0) {
return -1;
}
sal_config_temp_name = sal_strdup(tname);
}
}
return 0;
}
开发者ID:ariavie,项目名称:bcm,代码行数:27,代码来源:config.c
示例2: soc_robo_dos_monitor_init
/*
* Function:
* soc_robo_dos_monitor_init (internal)
* Purpose:
* dos monitor init
* Parameters:
* unit - unit number.
* interval - time between resynchronization passes
* Returns:
* SOC_E_INTERNAL if can't create threads.
*/
int
soc_robo_dos_monitor_init(int unit)
{
drv_robo_dos_monitor_t *dm;
if (drv_dm_control[unit] != NULL){
SOC_IF_ERROR_RETURN(soc_robo_dos_monitor_deinit(unit));
}
if ((dm = sal_alloc(sizeof(drv_robo_dos_monitor_t), "dos_monitor")) ==
NULL){
return SOC_E_MEMORY;
}
/* allocate dm and set init value */
sal_memset(dm, 0, sizeof (drv_robo_dos_monitor_t));
dm->dm_lock = sal_mutex_create("soc_dos_monitor_lock");
if (dm->dm_lock == NULL){
sal_free(dm);
return SOC_E_MEMORY;
}
dm->dm_sema = sal_sem_create("robo_HWDOS_MONITOR_SLEEP",
sal_sem_BINARY, 0);
if (dm->dm_sema == NULL) {
sal_mutex_destroy(dm->dm_lock);
sal_free(dm);
return SOC_E_MEMORY;
}
dm->dm_thread = NULL;
drv_dm_control[unit] = dm;
return SOC_E_NONE;
}
开发者ID:Reedgarden,项目名称:bcm-sdk-xgs,代码行数:46,代码来源:dos.c
示例3: soc_mmu_error_init
int
soc_mmu_error_init(int unit)
{
soc_control_t *soc = SOC_CONTROL(unit);
soc_mmu_error_t *mmu_errors;
soc_port_t port;
uint32 regval;
int rv;
/* Don't want any interrupts from MMU until initialized */
/* This will be turned on by soc_mmu_init in drv.c */
soc_pci_write(unit, CMIC_MMUIRQ_MASK, 0);
/* Free if allocated ... */
if (soc->mmu_errors) {
sal_free(soc->mmu_errors);
}
mmu_errors = sal_alloc(sizeof(soc_mmu_error_t) * SOC_MAX_NUM_PORTS,
"MMU error counters");
if (mmu_errors == NULL) {
return SOC_E_MEMORY;
}
sal_memset(mmu_errors, 0, sizeof(soc_mmu_error_t) * SOC_MAX_NUM_PORTS);
PBMP_ALL_ITER(unit, port) {
mmu_errors[port].xq_parity = 0;
mmu_errors[port].lla_parity = 0;
mmu_errors[port].upk_parity = 0;
mmu_errors[port].ing_parity = 0;
mmu_errors[port].egr_parity = 0;
if ((rv = READ_MMU_PP_SBE_CNTr(unit, port, ®val)) < 0) {
sal_free(mmu_errors);
return rv;
}
mmu_errors[port].pp_sbe_blocks =
mmu_errors[port].pp_sbe_blocks_init =
soc_reg_field_get(unit, MMU_PP_SBE_CNTr, regval, BLOCKCOUNTf);
mmu_errors[port].pp_sbe_cells =
mmu_errors[port].pp_sbe_cells_init =
soc_reg_field_get(unit, MMU_PP_SBE_CNTr, regval, CELLCOUNTf);
if ((rv = READ_MMU_PP_DBE_CNTr(unit, port, ®val)) < 0) {
sal_free(mmu_errors);
return rv;
}
mmu_errors[port].pp_dbe_blocks =
mmu_errors[port].pp_dbe_blocks_init =
soc_reg_field_get(unit, MMU_PP_DBE_CNTr, regval, BLOCKCOUNTf);
mmu_errors[port].pp_dbe_cells =
mmu_errors[port].pp_dbe_cells_init =
soc_reg_field_get(unit, MMU_PP_DBE_CNTr, regval, CELLCOUNTf);
}
开发者ID:ariavie,项目名称:bcm,代码行数:60,代码来源:mmuerr.c
示例4: ctclib_hash_free
/* Free hash memory. You may call hash_clean before call this
function. */
void
ctclib_hash_free (ctclib_hash_t *hash)
{
sal_free (hash->index);
sal_free (hash);
return;
}
开发者ID:AlickHill,项目名称:Lantern,代码行数:10,代码来源:ctclib_hash.c
示例5: bcm_pkt_clear
int
bcm_pkt_clear(int unit, bcm_pkt_t *pkt, bcm_pkt_blk_t *blks, int blk_count,
uint32 flags, bcm_pkt_t **pkt_buf)
{
int rv, i;
int bytes = 0;
int local_alloc = FALSE;
UNIT_VALID(unit);
if (pkt == NULL) { /* Allocate new packet */
local_alloc = TRUE;
if ((pkt = sal_alloc(sizeof(bcm_pkt_t), "pkt_setup")) == NULL) {
*pkt_buf = NULL;
return BCM_E_MEMORY;
}
}
sal_memset(pkt, 0, sizeof(bcm_pkt_t));
pkt->unit = unit;
if (blk_count == 0) {
/*
* Permit allocation of an empty packet structure.
* A single buffer can be added alter using the
* BCM_PKT_ONE_BUF_SETUP macro.
*/
bcm_pkt_flags_init(unit, pkt, flags);
} else {
for (i = 0; i < blk_count; i++) {
bytes += blks[i].len;
}
if (bytes < BCM_PKT_ALLOC_MIN) {
*pkt_buf = NULL;
if (local_alloc) {
sal_free(pkt);
}
return BCM_E_MEMORY;
}
pkt->pkt_data = blks;
pkt->blk_count = blk_count;
rv = bcm_pkt_flags_len_setup(unit, pkt, bytes, -1, flags);
if (BCM_FAILURE(rv)) {
*pkt_buf = NULL;
if (local_alloc) {
sal_free(pkt);
}
return rv;
}
}
*pkt_buf = pkt;
return BCM_E_NONE;
}
开发者ID:ariavie,项目名称:bcm,代码行数:56,代码来源:pkt.c
示例6: test_parameters
cmd_result_t
test_parameters(int u, args_t *a)
/*
* Function: test_parameters
* Purpose: Set the parameters for the specified tests.
* Parameters: u - unit number
* a - arguments, expects tuples of the form:
* [Test name/#] Arguments.
* if arguments is null string ("") then previously
* set arguments are discarded and defaults used.
* Returns: cmd_result_t.
*/
{
char *tid, *p; /* Testid, parameters */
test_t *t; /* Test pointer */
COMPILER_REFERENCE(u);
if (0 == ARG_CNT(a)) {
return(CMD_USAGE);
}
while (NULL != (tid = ARG_GET(a))) {
p = ARG_GET(a); /* Parameter */
t = test_find(tid);
if (NULL == t) {
cli_out("%s: Error: Unable to find test: %s\n", ARG_CMD(a), tid);
return(CMD_FAIL);
}
if (!p || !*p) { /* Clear parameter */
if (!t->t_override_string) {
cli_out("%s: Warning: No arguments to clear for test: %s\n",
ARG_CMD(a), t->t_name);
continue;
}
sal_free(t->t_override_string);
t->t_override_string = NULL;
} else { /* Set Arguments */
if (t->t_override_string) {
sal_free(t->t_override_string);
}
if (!(t->t_override_string =
(char *)sal_alloc(strlen(p) + 1, "test_parm"))) {
cli_out("%s: Error: Out of memory\n", ARG_CMD(a));
return(CMD_FAIL);
}
sal_strcpy(t->t_override_string, p);
cli_out("%s: Parameter set: %s(\"%s\")\n", ARG_CMD(a), t->t_name,
t->t_override_string);
}
}
return(CMD_OK);
}
开发者ID:ariavie,项目名称:bcm,代码行数:53,代码来源:test.c
示例7: txrx_pkt_free
STATIC void
txrx_pkt_free(int unit, bcm_pkt_t *pkt)
{
int i;
for (i = 0; i < pkt->blk_count; i++) {
soc_cm_sfree(unit, pkt->pkt_data[i].data);
}
if (pkt->pkt_data != &pkt->_pkt_data) {
sal_free(pkt->pkt_data);
}
sal_free(pkt);
}
开发者ID:ariavie,项目名称:bcm,代码行数:15,代码来源:txrx.c
示例8: fetion_contact_list_find_by_sipuri
Contact* fetion_contact_list_find_by_sipuri(Contact* contactlist , const char* sipuri)
{
Contact *cl_cur;
char *sid , *sid1;
foreach_contactlist(contactlist , cl_cur){
sid = fetion_sip_get_sid_by_sipuri(cl_cur->sipuri);
sid1 = fetion_sip_get_sid_by_sipuri(sipuri);
if(strcmp(sid , sid1) == 0){
sal_free(sid);
sal_free(sid1);
return cl_cur;
}
sal_free(sid);
sal_free(sid1);
}
开发者ID:amoid,项目名称:oslabs,代码行数:15,代码来源:fetion_contact.c
示例9: bcm_pkt_blk_alloc
int
bcm_pkt_blk_alloc(int unit, int count, int size, uint32 flags,
bcm_pkt_t ***packet_array)
{
bcm_pkt_t **p_array;
int i, j;
UNIT_VALID(unit);
if (!(p_array = sal_alloc(count * sizeof(bcm_pkt_t *), "pkt_blk"))) {
*packet_array = NULL;
return (BCM_E_MEMORY);
}
for (i = 0; i < count; i++) {
if (BCM_FAILURE(bcm_pkt_alloc(unit, size, flags, p_array + i))) {
for (j = 0; j < i; j++) {
bcm_pkt_free(unit, p_array[j]);
}
sal_free(p_array);
*packet_array = NULL;
return (BCM_E_MEMORY);
}
}
*packet_array = p_array;
return BCM_E_NONE;
}
开发者ID:ariavie,项目名称:bcm,代码行数:29,代码来源:pkt.c
示例10: bcm_pkt_alloc
int
bcm_pkt_alloc(int unit, int size, uint32 flags, bcm_pkt_t **pkt_buf)
{
bcm_pkt_t *pkt;
int rv = BCM_E_INTERNAL;
UNIT_VALID(unit);
pkt = sal_alloc(sizeof(bcm_pkt_t), "bcm_pkt_alloc");
if (!pkt) {
*pkt_buf = NULL;
return BCM_E_MEMORY;
}
sal_memset(pkt, 0, sizeof(bcm_pkt_t));
pkt->pkt_data = &pkt->_pkt_data;
pkt->blk_count = 1;
rv = _bcm_pkt_data_alloc(unit, size, pkt->pkt_data);
if (BCM_FAILURE(rv)) {
sal_free(pkt);
*pkt_buf = NULL;
return rv;
}
bcm_pkt_flags_init(unit, pkt, flags);
*pkt_buf = pkt;
return BCM_E_NONE;
}
开发者ID:ariavie,项目名称:bcm,代码行数:30,代码来源:pkt.c
示例11: phy_mac_driver_attach
/*
* Allocate mac control block and attach the MAC driver.
*/
phy_mac_ctrl_t*
phy_mac_driver_attach(blmi_dev_addr_t dev_addr,
phy_mactype_t mac_type,
blmi_dev_io_f mmi_cbf)
{
phy_mac_ctrl_t *mmc;
mmc = sal_alloc(sizeof(phy_mac_ctrl_t),
"bmac_driver");
if (mmc == NULL) {
return NULL;
}
if (mac_type == PHY_MAC_CORE_UNIMAC) {
sal_memcpy(&mmc->mac_drv, &phy_unimac_drv, sizeof(phy_mac_drv_t));
#if 0
} else if (mac_type == PHY_MAC_CORE_BIGMAC) {
sal_memcpy(&mmc->mac_drv, &phy_bigmac_drv, sizeof(phy_mac_drv_t));
#endif
} else if (mac_type == PHY_MAC_CORE_XMAC) {
sal_memcpy(&mmc->mac_drv, &phy_xmac_drv, sizeof(phy_mac_drv_t));
} else {
sal_free(mmc);
mmc = NULL;
}
if (mmc) {
mmc->devio_f = mmi_cbf;
mmc->dev_addr = dev_addr;
mmc->flag = 0;
}
return mmc;
}
开发者ID:ariavie,项目名称:bcm,代码行数:37,代码来源:phy_mac_ctrl.c
示例12: _ctclib_hash_create_size
/* Allocate a new hash. */
static ctclib_hash_t *
_ctclib_hash_create_size (uint32 size, hash_mem_type_t type,
uint32 (*hash_key) (), bool (*hash_cmp) ())
{
ctclib_hash_t *hash;
hash = sal_malloc (sizeof (ctclib_hash_t));
if (NULL == hash)
return NULL;
#ifdef _USER_KERNEL_SHM_
if(CTCLIB_HASH_SYS_MEM == type)
hash->index = XCALLOC (CTCLLB_MEM_HASH_MODULE, sizeof (ctclib_hash_backet_t *) * size);
else
hash->index = XCALLOC_SHM (CTCLLB_MEM_HASH_MODULE, sizeof (ctclib_hash_backet_t *) * size);
#else
hash->index = sal_calloc (sizeof (ctclib_hash_backet_t *) * size);
#endif
if (NULL == hash->index)
{
sal_free(hash);
return NULL;
}
hash->size = size;
hash->hash_key = hash_key;
hash->hash_cmp = hash_cmp;
hash->count = 0;
return hash;
}
开发者ID:AlickHill,项目名称:Lantern,代码行数:33,代码来源:ctclib_hash.c
示例13: ctclib_hash_release
/* This function release registered value from specified hash. When
release is successfully finished, return the data pointer in the
hash bucket. */
void *
ctclib_hash_release (ctclib_hash_t *hash, void *data)
{
void *ret;
uint32 key;
uint32 index;
ctclib_hash_backet_t *backet;
ctclib_hash_backet_t *pp;
key = (*hash->hash_key) (data);
index = key % hash->size;
for (backet = pp = hash->index[index]; backet; backet = backet->next)
{
if (backet->key == key && (*hash->hash_cmp) (backet->data, data) == TRUE)
{
if (backet == pp)
{
hash->index[index] = backet->next;
}
else
{
pp->next = backet->next;
}
ret = backet->data;
sal_free (backet);
hash->count--;
return ret;
}
pp = backet;
}
return NULL;
}
开发者ID:AlickHill,项目名称:Lantern,代码行数:37,代码来源:ctclib_hash.c
示例14: _auth_field_install_all
STATIC int
_auth_field_install_all(int unit, int port)
{
auth_mac_t **list=&auth_cntl[unit][port].macList;
auth_mac_p entry = NULL;
int rv = BCM_E_NONE;
bcm_mac_t mac_zero = {0};
if (auth_cntl[unit][port].mac_set) {
return BCM_E_EXISTS;
}
/* No accepted MAC addresses, drop all for default */
if (*list == NULL) {
rv = _auth_field_install(unit, port, mac_zero);
if (rv < 0) {
return rv;
}
}
while (*list != NULL) {
rv = _auth_field_install(unit, port, (*list)->mac);
if (rv < 0) {
_auth_maclist_remove(list, (*list)->mac, &entry);
sal_free(entry);
} else {
list = &(*list)->next;
}
}
auth_cntl[unit][port].mac_set = TRUE;
return rv;
}
开发者ID:ariavie,项目名称:bcm,代码行数:33,代码来源:auth.c
示例15: socend_send_done
void
socend_send_done(int unit, bcm_pkt_t *pkt, void *cookie)
/*
* Function: socend_send_done
* Purpose: Process a completion of a send request
* Parameters: unit - unit #
* pkt - The tx packet structure
* cookie - pointer to mBlk structure to free
* If null, assume we free the cluster directly.
* Returns: Nothing
* Notes:
* Assumption: This function is called from a non-interrupt context.
*/
{
LOG_INFO(BSL_LS_SYS_END,
(BSL_META_U(unit,
"Socend send done, in. pkt %p. ck %p. "),
(void *)pkt->_pkt_data.data, (void *)cookie));
if (NULL == cookie) {
if (SOC_IS_ESW(unit)) {
socend_packet_free(unit, pkt->_pkt_data.data);
} else {
soc_cm_sfree(unit, pkt->_pkt_data.data);
}
} else {
netMblkClChainFree(cookie); /* Free MBLK */
}
sal_free(pkt);
LOG_INFO(BSL_LS_SYS_END,
(BSL_META_U(unit,
"out.\n")));
}
开发者ID:ariavie,项目名称:bcm,代码行数:32,代码来源:socend.c
示例16: ces_test_done
int
ces_test_done(int u, void *p)
{
int rv = 0;
/*
* Clear ge0 loopback
*/
#if 0
ces_test_ge0_loopback_set(u, FALSE);
#else
printk("<<<< GE0 LOOPBACK STILL ON >>>>\n");
#endif
#if 0
/*
* Reset CES
*/
bcm_ces_services_init(u);
#else
printk("<<<< CES NOT CLEANED UP >>>>\n");
#endif
if (p != NULL)
sal_free(p);
if (rv < 0) {
test_error(u, "Post-CES reset failed: %s\n", soc_errmsg(rv));
return -1;
}
return 0;
}
开发者ID:Reedgarden,项目名称:bcm-sdk-xgs,代码行数:32,代码来源:ces.c
示例17: bcm_pkt_rx_alloc
int
bcm_pkt_rx_alloc(int unit, int len, bcm_pkt_t **pkt_buf)
{
bcm_pkt_t *pkt;
uint8 *buf;
int rv;
UNIT_VALID(unit);
buf = NULL;
pkt = sal_alloc(sizeof(bcm_pkt_t), "pkt_rx_alloc");
if (pkt == NULL) {
*pkt_buf = NULL;
return BCM_E_MEMORY;
}
sal_memset(pkt, 0, sizeof(bcm_pkt_t));
if (len > 0) {
rv = bcm_rx_alloc(unit, len, 0, (void*)&buf);
if (rv != BCM_E_NONE) {
sal_free(pkt);
return rv;
}
pkt->_pkt_data.data = buf;
pkt->_pkt_data.len = len;
pkt->pkt_len = len;
pkt->pkt_data = &pkt->_pkt_data;
pkt->blk_count = 1;
}
/* Set up flags here if possible */
*pkt_buf = pkt;
return BCM_E_NONE;
}
开发者ID:ariavie,项目名称:bcm,代码行数:35,代码来源:pkt.c
示例18: shr_mem_avl_destroy
int shr_mem_avl_destroy(shr_mem_avl_t *mem_avl)
{
int status, rv = 0;
shr_mem_avl_entry_pt entry;
shr_mem_avl_entry_pt next;
/* destroy the avl tree. Frees the space for datum's also. */
status = shr_avl_destroy(mem_avl->tree);
if (status != 0) {
rv = -1;
}
mem_avl->tree = NULL;
/*
* Now walk the dll and free each entry
*/
entry = mem_avl->mem_list;
while (NULL != entry) {
next = entry->next;
sal_free(entry);
entry = next;
}
mem_avl->mem_list = NULL;
return rv;
}
开发者ID:Reedgarden,项目名称:bcm-sdk-xgs,代码行数:27,代码来源:mem_avl.c
示例19: soc_robo_dos_monitor_deinit
/*
* soc_robo_dos_monitor_deinit
* Purpose:
* dos monitor de-init
* Parameters:
* unit - unit number.
* Returns:
*
*/
int
soc_robo_dos_monitor_deinit(int unit)
{
drv_robo_dos_monitor_t *dm = drv_dm_control[unit];
/* check if dm is null and dm thread running status */
if (dm != NULL){
SOC_IF_ERROR_RETURN(soc_robo_dos_monitor_enable_set(unit, 0));
if (dm->dm_thread != NULL){
soc_cm_debug(DK_ERR,
"HW DOS monitor disabled but still exist!,thread(%p)\n",
(void *)dm->dm_thread);
}
if (dm->dm_sema != NULL) {
sal_sem_destroy(dm->dm_sema);
dm->dm_sema = NULL;
}
if (dm->dm_lock != NULL) {
sal_mutex_destroy(dm->dm_lock);
dm->dm_lock = NULL;
}
/* free dm */
drv_dm_control[unit] = NULL;
sal_free(dm);
}
return SOC_E_NONE;
}
开发者ID:Reedgarden,项目名称:bcm-sdk-xgs,代码行数:43,代码来源:dos.c
示例20: fetion_conversation_send_sms_to_myself_with_reply
int fetion_conversation_send_sms_to_myself_with_reply(Conversation* conversation,
const char* message)
{
SipHeader *toheader = NULL;
SipHeader *eheader = NULL;
char *res = NULL;
char rep[1024];
int code;
FetionSip *sip = conversation->currentUser->sip;
fetion_sip_set_type(sip , SIP_MESSAGE);
toheader = fetion_sip_header_new("T" , conversation->currentUser->sipuri);
eheader = fetion_sip_event_header_new(SIP_EVENT_SENDCATMESSAGE);
fetion_sip_add_header(sip , toheader);
fetion_sip_add_header(sip , eheader);
res = fetion_sip_to_string(sip , message);
debug_info("Sent a message to myself" , conversation->currentContact->sipuri);
tcp_connection_send(sip->tcp , res , strlen(res));
sal_free(res);
memset(rep, 0, sizeof(rep));
tcp_connection_recv(sip->tcp , rep , sizeof(rep));
code = fetion_sip_get_code(rep);
if(code == 200 || code == 280){
return 1;
}else{
return -1;
}
}
开发者ID:amoid,项目名称:oslabs,代码行数:28,代码来源:fetion_conversation.c
注:本文中的sal_free函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论