本文整理汇总了C++中ERR_MEM函数的典型用法代码示例。如果您正苦于以下问题:C++ ERR_MEM函数的具体用法?C++ ERR_MEM怎么用?C++ ERR_MEM使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了ERR_MEM函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ERR_MEM
event_t *shm_copy_event(event_t *e)
{
event_t *ev = NULL;
param_t *p1, *p2;
int size;
ev = (event_t *)shm_malloc(sizeof(event_t));
if(ev == NULL) {
ERR_MEM(SHARE_MEM);
}
memset(ev, 0, sizeof(event_t));
ev->name.s = (char *)shm_malloc(e->name.len * sizeof(char));
if(ev->name.s == NULL) {
ERR_MEM(SHARE_MEM);
}
memcpy(ev->name.s, e->name.s, e->name.len);
ev->name.len = e->name.len;
p1 = e->params.list;
while(p1) {
size = sizeof(param_t) + (p1->name.len + p1->body.len) * sizeof(char);
p2 = (param_t *)shm_malloc(size);
if(p2 == NULL) {
ERR_MEM(SHARE_MEM);
}
memset(p2, 0, size);
size = sizeof(param_t);
CONT_COPY(p2, p2->name, p1->name);
if(p1->body.s && p1->body.len)
CONT_COPY(p2, p2->body, p1->body);
p2->next = ev->params.list;
ev->params.list = p2;
/* Update parameter hooks in the shmmem copy, this is needed so that
* we can test for the presence of the sla parameter even in the
* shared copy of the event */
if(e->params.hooks.event_dialog.call_id == p1)
ev->params.hooks.event_dialog.call_id = p2;
if(e->params.hooks.event_dialog.from_tag == p1)
ev->params.hooks.event_dialog.from_tag = p2;
if(e->params.hooks.event_dialog.to_tag == p1)
ev->params.hooks.event_dialog.to_tag = p2;
if(e->params.hooks.event_dialog.include_session_description == p1)
ev->params.hooks.event_dialog.include_session_description = p2;
if(e->params.hooks.event_dialog.sla == p1)
ev->params.hooks.event_dialog.sla = p2;
p1 = p1->next;
}
ev->type = e->type;
return ev;
error:
shm_free_event(ev);
return NULL;
}
示例2: mem_copy_subs_noc
subs_t* mem_copy_subs_noc(subs_t* s)
{
int size;
subs_t* dest;
size= sizeof(subs_t)+ s->pres_uri.len+ s->to_user.len
+ s->to_domain.len+ s->from_user.len+ s->from_domain.len+ s->callid.len
+ s->to_tag.len+ s->from_tag.len+s->event_id.len
+ s->local_contact.len + s->record_route.len+
+ s->reason.len+ 1;
dest= (subs_t*)shm_malloc(size);
if(dest== NULL)
{
ERR_MEM(SHARE_MEM);
}
memset(dest, 0, size);
size= sizeof(subs_t);
CONT_COPY(dest, dest->pres_uri, s->pres_uri);
CONT_COPY(dest, dest->to_user, s->to_user);
CONT_COPY(dest, dest->to_domain, s->to_domain);
CONT_COPY(dest, dest->from_user, s->from_user);
CONT_COPY(dest, dest->from_domain, s->from_domain);
CONT_COPY(dest, dest->to_tag, s->to_tag);
CONT_COPY(dest, dest->from_tag, s->from_tag);
CONT_COPY(dest, dest->callid, s->callid);
CONT_COPY(dest, dest->local_contact, s->local_contact);
CONT_COPY(dest, dest->record_route, s->record_route);
if(s->event_id.s)
CONT_COPY(dest, dest->event_id, s->event_id);
if(s->reason.s)
CONT_COPY(dest, dest->reason, s->reason);
dest->event= s->event;
dest->local_cseq= s->local_cseq;
dest->remote_cseq= s->remote_cseq;
dest->status= s->status;
dest->version= s->version;
dest->expires= s->expires;
dest->db_flag= s->db_flag;
dest->sockinfo = s->sockinfo;
dest->contact.s= (char*)shm_malloc(s->contact.len);
if(dest->contact.s== NULL)
{
ERR_MEM(SHARE_MEM);
}
memcpy(dest->contact.s, s->contact.s, s->contact.len);
dest->contact.len= s->contact.len;
return dest;
error:
if(dest)
shm_free(dest);
return NULL;
}
示例3: insert_phtable
int insert_phtable(str* pres_uri, int event, char* sphere)
{
unsigned int hash_code;
pres_entry_t* p= NULL;
int size;
hash_code= core_case_hash(pres_uri, NULL, phtable_size);
lock_get(&pres_htable[hash_code].lock);
p= search_phtable(pres_uri, event, hash_code);
if(p)
{
p->publ_count++;
lock_release(&pres_htable[hash_code].lock);
return 0;
}
size= sizeof(pres_entry_t)+ pres_uri->len* sizeof(char);
p= (pres_entry_t*)shm_malloc(size);
if(p== NULL)
{
lock_release(&pres_htable[hash_code].lock);
ERR_MEM(SHARE_MEM);
}
memset(p, 0, size);
size= sizeof(pres_entry_t);
p->pres_uri.s= (char*)p+ size;
memcpy(p->pres_uri.s, pres_uri->s, pres_uri->len);
p->pres_uri.len= pres_uri->len;
if(sphere)
{
p->sphere= (char*)shm_malloc((strlen(sphere)+ 1)*sizeof(char));
if(p->sphere== NULL)
{
lock_release(&pres_htable[hash_code].lock);
shm_free(p);
ERR_MEM(SHARE_MEM);
}
strcpy(p->sphere, sphere);
}
p->event= event;
p->publ_count=1;
/* link the item in the hash table */
p->next= pres_htable[hash_code].entries->next;
pres_htable[hash_code].entries->next= p;
lock_release(&pres_htable[hash_code].lock);
return 0;
error:
return -1;
}
示例4: shm_copy_event
event_t* shm_copy_event(event_t* e)
{
event_t* ev= NULL;
param_t* p1, *p2;
int size;
ev= (event_t*)shm_malloc(sizeof(event_t));
if(ev== NULL)
{
ERR_MEM(SHARE_MEM);
}
memset(ev, 0, sizeof(event_t));
ev->text.s= (char*)shm_malloc(e->text.len);
if(ev->text.s== NULL)
{
ERR_MEM(SHARE_MEM);
}
memcpy(ev->text.s, e->text.s, e->text.len);
ev->text.len= e->text.len;
p1= e->params;
while(p1)
{
size= sizeof(param_t)+ p1->name.len+ p1->body.len;
p2= (param_t*)shm_malloc(size);
if(p2== NULL)
{
ERR_MEM(SHARE_MEM);
}
memset(p2, 0, size);
size= sizeof(param_t);
CONT_COPY(p2, p2->name, p1->name);
if(p1->body.s && p1->body.len)
CONT_COPY(p2, p2->body, p1->body);
p2->next= ev->params;
ev->params= p2;
p1= p1->next;
}
ev->parsed= e->parsed;
return ev;
error:
shm_free_event(ev);
return NULL;
}
示例5: insert_phtable
pres_entry_t* insert_phtable(str* pres_uri, int event, str* etag, char* sphere, int init_turn)
{
unsigned int hash_code;
pres_entry_t* p= NULL;
int size;
size= sizeof(pres_entry_t)+ pres_uri->len;
p= (pres_entry_t*)shm_malloc(size);
if(p== NULL)
{
ERR_MEM(SHARE_MEM);
}
memset(p, 0, size);
size= sizeof(pres_entry_t);
p->pres_uri.s= (char*)p+ size;
memcpy(p->pres_uri.s, pres_uri->s, pres_uri->len);
p->pres_uri.len= pres_uri->len;
if(sphere)
{
p->sphere= (char*)shm_malloc(strlen(sphere)+ 1);
if(p->sphere== NULL)
{
ERR_MEM(SHARE_MEM);
}
strcpy(p->sphere, sphere);
}
p->event= event;
update_pres_etag(p, etag);
hash_code= core_hash(pres_uri, NULL, phtable_size);
lock_get(&pres_htable[hash_code].lock);
p->next= pres_htable[hash_code].entries->next;
pres_htable[hash_code].entries->next= p;
p->last_turn = init_turn;
lock_release(&pres_htable[hash_code].lock);
return p;
error:
if(p)
shm_free(p);
return NULL;
}
示例6: mem_copy_subs
subs_t* mem_copy_subs(subs_t* s, int mem_type)
{
int size;
subs_t* dest;
size= sizeof(subs_t)+ s->pres_uri.len+ s->to_user.len
+ s->to_domain.len+ s->from_user.len+ s->from_domain.len+ s->callid.len
+ s->to_tag.len+ s->from_tag.len+s->event_id.len
+ s->local_contact.len+ s->contact.len+ s->record_route.len+
+ s->reason.len+ 1;
if(mem_type == PKG_MEM_TYPE)
dest= (subs_t*)pkg_malloc(size);
else
dest= (subs_t*)shm_malloc(size);
if(dest== NULL)
{
ERR_MEM((mem_type==PKG_MEM_TYPE)?PKG_MEM_STR:SHARE_MEM);
}
memset(dest, 0, size);
size= sizeof(subs_t);
CONT_COPY(dest, dest->pres_uri, s->pres_uri);
CONT_COPY(dest, dest->to_user, s->to_user);
CONT_COPY(dest, dest->to_domain, s->to_domain);
CONT_COPY(dest, dest->from_user, s->from_user);
CONT_COPY(dest, dest->from_domain, s->from_domain);
CONT_COPY(dest, dest->to_tag, s->to_tag);
CONT_COPY(dest, dest->from_tag, s->from_tag);
CONT_COPY(dest, dest->callid, s->callid);
CONT_COPY(dest, dest->local_contact, s->local_contact);
CONT_COPY(dest, dest->contact, s->contact);
CONT_COPY(dest, dest->record_route, s->record_route);
if(s->event_id.s)
CONT_COPY(dest, dest->event_id, s->event_id);
if(s->reason.s)
CONT_COPY(dest, dest->reason, s->reason);
dest->event= s->event;
dest->local_cseq= s->local_cseq;
dest->remote_cseq= s->remote_cseq;
dest->status= s->status;
dest->version= s->version;
dest->expires= s->expires;
dest->db_flag= s->db_flag;
dest->sockinfo= s->sockinfo;
return dest;
error:
if(dest)
{
if(mem_type == PKG_MEM_TYPE)
pkg_free(dest);
else
shm_free(dest);
}
return NULL;
}
示例7: new_phtable
phtable_t* new_phtable(void)
{
phtable_t* htable= NULL;
int i, j;
i = 0;
htable= (phtable_t*)shm_malloc(phtable_size* sizeof(phtable_t));
if(htable== NULL)
{
ERR_MEM(SHARE_MEM);
}
memset(htable, 0, phtable_size* sizeof(phtable_t));
for(i= 0; i< phtable_size; i++)
{
if(lock_init(&htable[i].lock)== 0)
{
LM_ERR("initializing lock [%d]\n", i);
goto error;
}
htable[i].entries= (pres_entry_t*)shm_malloc(sizeof(pres_entry_t));
if(htable[i].entries== NULL)
{
ERR_MEM(SHARE_MEM);
}
memset(htable[i].entries, 0, sizeof(pres_entry_t));
htable[i].entries->next= NULL;
}
return htable;
error:
if(htable)
{
for(j=0; j< i; j++)
{
if(htable[i].entries)
shm_free(htable[i].entries);
else
break;
lock_destroy(&htable[i].lock);
}
shm_free(htable);
}
return NULL;
}
示例8: new_shtable
shtable_t new_shtable(int hash_size)
{
shtable_t htable= NULL;
int i, j;
i = 0;
htable= (subs_entry_t*)shm_malloc(hash_size* sizeof(subs_entry_t));
if(htable== NULL)
{
ERR_MEM(SHARE_MEM);
}
memset(htable, 0, hash_size* sizeof(subs_entry_t));
for(i= 0; i< hash_size; i++)
{
if(lock_init(&htable[i].lock)== 0)
{
LM_ERR("initializing lock [%d]\n", i);
goto error;
}
htable[i].entries= (subs_t*)shm_malloc(sizeof(subs_t));
if(htable[i].entries== NULL)
{
lock_destroy(&htable[i].lock);
ERR_MEM(SHARE_MEM);
}
memset(htable[i].entries, 0, sizeof(subs_t));
htable[i].entries->next= NULL;
}
return htable;
error:
if(htable)
{
for(j=0; j< i; j++)
{
lock_destroy(&htable[j].lock);
shm_free(htable[j].entries);
}
shm_free(htable);
}
return NULL;
}
示例9: b2b_client_build_dlg
dlg_t* b2b_client_build_dlg(b2b_dlg_t* dlg, dlg_leg_t* leg)
{
dlg_t* td =NULL;
td = (dlg_t*)pkg_malloc(sizeof(dlg_t));
if(td == NULL)
{
ERR_MEM(PKG_MEM_STR);
}
memset(td, 0, sizeof(dlg_t));
td->loc_seq.value = dlg->cseq[CALLER_LEG];
dlg->cseq[CALLER_LEG]++;
td->loc_seq.is_set = 1;
td->id.call_id = dlg->callid;
td->id.loc_tag = dlg->tag[CALLER_LEG];
td->loc_uri = dlg->from_uri;
td->rem_uri = dlg->to_uri;
td->loc_dname = dlg->from_dname;
td->rem_dname = dlg->to_dname;
if(leg)
{
if(leg->route_set.s && leg->route_set.len)
{
if(parse_rr_body(leg->route_set.s, leg->route_set.len,
&td->route_set)< 0)
{
LM_ERR("failed to parse record route body\n");
goto error;
}
}
td->id.rem_tag = leg->tag;
LM_DBG("Rem_target = %.*s\n", leg->contact.len, leg->contact.s);
td->rem_target = leg->contact;
}
td->state= DLG_CONFIRMED ;
td->send_sock = dlg->send_sock;
if(dlg->send_sock)
LM_DBG("send sock= %.*s\n", dlg->send_sock->address_str.len,
dlg->send_sock->address_str.s);
return td;
error:
if(td)
pkg_free(td);
return 0;
}
示例10: xcapInitNodeSel
xcap_node_sel_t* xcapInitNodeSel(void)
{
xcap_node_sel_t* nsel= NULL;
nsel= (xcap_node_sel_t*)pkg_malloc(sizeof(xcap_node_sel_t));
if(nsel== NULL)
{
ERR_MEM(PKG_MEM_STR);
}
memset(nsel, 0, sizeof(xcap_node_sel_t));
nsel->steps= (step_t*)pkg_malloc(sizeof(step_t));
if(nsel->steps== NULL)
{
ERR_MEM(PKG_MEM_STR);
}
memset(nsel->steps, 0, sizeof(step_t));
nsel->last_step= nsel->steps;
nsel->ns_list= (ns_list_t*)pkg_malloc(sizeof(ns_list_t));
if(nsel->ns_list== NULL)
{
ERR_MEM(PKG_MEM_STR);
}
memset(nsel->ns_list, 0, sizeof(ns_list_t));
nsel->last_ns= nsel->ns_list;
return nsel;
error:
if(nsel)
{
if(nsel->steps)
pkg_free(nsel->steps);
if(nsel->ns_list)
pkg_free(nsel->ns_list);
pkg_free(nsel);
}
return NULL;
}
示例11: extract_sphere
char* extract_sphere(str body)
{
/* check for a rpid sphere element */
xmlDocPtr doc= NULL;
xmlNodePtr node;
char* cont, *sphere= NULL;
doc= xmlParseMemory(body.s, body.len);
if(doc== NULL)
{
LM_ERR("failed to parse xml body\n");
return NULL;
}
node= xmlNodeGetNodeByName(doc->children, "sphere", "rpid");
if(node== NULL)
node= xmlNodeGetNodeByName(doc->children, "sphere", "r");
if(node)
{
LM_DBG("found sphere definition\n");
cont= (char*)xmlNodeGetContent(node);
if(cont== NULL)
{
LM_ERR("failed to extract sphere node content\n");
goto error;
}
sphere= (char*)pkg_malloc(strlen(cont)+ 1);
if(sphere== NULL)
{
xmlFree(cont);
ERR_MEM(PKG_MEM_STR);
}
strcpy(sphere, cont);
xmlFree(cont);
}
else
LM_DBG("didn't find sphere definition\n");
error:
xmlFreeDoc(doc);
return sphere;
}
示例12: shm_copy_xcap_list
static int shm_copy_xcap_list(void)
{
xcap_serv_t* xs, *shm_xs, *prev_xs;
int size;
xs= xs_list;
if(xs== NULL)
{
if(force_active== 0 && !integrated_xcap_server)
{
LM_ERR("no xcap_server parameter set\n");
return -1;
}
return 0;
}
xs_list= NULL;
size= sizeof(xcap_serv_t);
while(xs)
{
size+= (strlen(xs->addr)+ 1)* sizeof(char);
shm_xs= (xcap_serv_t*)shm_malloc(size);
if(shm_xs== NULL)
{
ERR_MEM(SHARE_MEM);
}
memset(shm_xs, 0, size);
size= sizeof(xcap_serv_t);
shm_xs->addr= (char*)shm_xs+ size;
strcpy(shm_xs->addr, xs->addr);
shm_xs->port= xs->port;
shm_xs->next= xs_list;
xs_list= shm_xs;
prev_xs= xs;
xs= xs->next;
pkg_free(prev_xs);
}
return 0;
error:
free_xs_list(xs_list, SHM_MEM_TYPE);
return -1;
}
示例13: b2b_server_build_dlg
dlg_t* b2b_server_build_dlg(b2b_dlg_t* dlg)
{
dlg_t* td =NULL;
td = (dlg_t*)pkg_malloc(sizeof(dlg_t));
if(td == NULL)
{
ERR_MEM(PKG_MEM_STR);
}
memset(td, 0, sizeof(dlg_t));
td->loc_seq.value = dlg->cseq[CALLEE_LEG];
td->loc_seq.is_set = 1;
dlg->cseq[CALLEE_LEG]++;
td->id.call_id = dlg->callid;
td->id.rem_tag = dlg->tag[CALLER_LEG];
td->id.loc_tag = dlg->tag[CALLEE_LEG];
td->rem_target = dlg->contact[CALLER_LEG];
td->loc_uri = dlg->to_uri;
td->rem_uri = dlg->from_uri;
td->loc_dname = dlg->to_dname;
td->rem_dname = dlg->from_dname;
if(dlg->route_set[CALLER_LEG].s && dlg->route_set[CALLER_LEG].len)
{
if(parse_rr_body(dlg->route_set[CALLER_LEG].s, dlg->route_set[CALLER_LEG].len,
&td->route_set)< 0)
{
LM_ERR("failed to parse record route body\n");
goto error;
}
}
td->state= DLG_CONFIRMED ;
td->send_sock = dlg->send_sock;
return td;
error:
if(td)
pkg_free(td);
return NULL;
}
示例14: init_b2bl_htable
int init_b2bl_htable(void)
{
int i;
b2bl_htable = (b2bl_table_t)shm_malloc(b2bl_hsize* sizeof(b2bl_entry_t));
if(!b2bl_htable)
ERR_MEM(SHARE_MEM);
memset(b2bl_htable, 0, b2bl_hsize* sizeof(b2bl_entry_t));
for(i= 0; i< b2bl_hsize; i++)
{
lock_init(&b2bl_htable[i].lock);
b2bl_htable[i].first = NULL;
}
return 0;
error:
return -1;
}
示例15: register_xcapcb
int register_xcapcb( int types, xcap_cb f)
{
xcap_callback_t* xcb;
xcb= (xcap_callback_t*)shm_malloc(sizeof(xcap_callback_t));
if(xcb== NULL)
{
ERR_MEM(SHARE_MEM);
}
memset(xcb, 0, sizeof(xcap_callback_t));
xcb->callback= f;
xcb->types= types;
xcb->next= xcapcb_list;
xcapcb_list= xcb;
return 0;
error:
return -1;
}