• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C++ ERR_MEM函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中ERR_MEM函数的典型用法代码示例。如果您正苦于以下问题:C++ ERR_MEM函数的具体用法?C++ ERR_MEM怎么用?C++ ERR_MEM使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了ERR_MEM函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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;
}
开发者ID:adubovikov,项目名称:kamailio,代码行数:59,代码来源:event_list.c


示例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;
}
开发者ID:MayamaTakeshi,项目名称:opensips,代码行数:58,代码来源:hash.c


示例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;
}
开发者ID:AlessioCasco,项目名称:kamailio,代码行数:58,代码来源:hash.c


示例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;
}
开发者ID:Distrotech,项目名称:opensips,代码行数:48,代码来源:event_list.c


示例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;
}
开发者ID:KISSMonX,项目名称:opensips,代码行数:48,代码来源:hash.c


示例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;
}
开发者ID:MayamaTakeshi,项目名称:opensips,代码行数:60,代码来源:hash.c


示例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;

}
开发者ID:MayamaTakeshi,项目名称:opensips,代码行数:47,代码来源:hash.c


示例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;

}
开发者ID:MayamaTakeshi,项目名称:opensips,代码行数:44,代码来源:hash.c


示例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;
}
开发者ID:GeorgeShaw,项目名称:opensips,代码行数:53,代码来源:client.c


示例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;
}
开发者ID:halan,项目名称:kamailio,代码行数:40,代码来源:xcap_functions.c


示例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;
}
开发者ID:Danfx,项目名称:opensips,代码行数:46,代码来源:presentity.c


示例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;
}
开发者ID:AlessioCasco,项目名称:kamailio,代码行数:46,代码来源:presence_xml.c


示例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;
}
开发者ID:Parantido,项目名称:opensips,代码行数:45,代码来源:server.c


示例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;
}
开发者ID:dynamicpacket-public,项目名称:opensips17,代码行数:18,代码来源:records.c


示例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;
}
开发者ID:Jared-Prime,项目名称:kamailio,代码行数:20,代码来源:xcap_callbacks.c


示例16: update_rlsubs

/*
 * function that updates a subscription in hash table
 *	sets reply_code and reply_str in case of error and
 *	if different that server error
 * */
int update_rlsubs( subs_t* subs, unsigned int hash_code,
		int* reply_code, str* reply_str)
{
	subs_t* s, *ps;

	/* search the record in hash table */
	lock_get(&rls_table[hash_code].lock);

	s= pres_search_shtable(rls_table, subs->callid,
			subs->to_tag, subs->from_tag, hash_code);
	if(s== NULL)
	{
		LM_DBG("record not found in hash table\n");
		lock_release(&rls_table[hash_code].lock);
		return -1;
	}

	s->expires= subs->expires+ (int)time(NULL);
	
	if(s->db_flag == NO_UPDATEDB_FLAG)
		s->db_flag= UPDATEDB_FLAG;
	
	if(	s->remote_cseq>= subs->remote_cseq)
	{
		lock_release(&rls_table[hash_code].lock);
		LM_DBG("stale cseq stored cseq= %d - received cseq= %d\n", s->remote_cseq, subs->remote_cseq);
		*reply_code =  Stale_cseq_code;
		*reply_str = stale_cseq_rpl;
		return -1;
	}
	s->remote_cseq= subs->remote_cseq;

	subs->pres_uri.s= (char*)pkg_malloc(s->pres_uri.len* sizeof(char));
	if(subs->pres_uri.s== NULL)
	{
		ERR_MEM(PKG_MEM_STR);
	}
	memcpy(subs->pres_uri.s, s->pres_uri.s, s->pres_uri.len);
	subs->pres_uri.len= s->pres_uri.len;

	subs->local_cseq= s->local_cseq;
	subs->version= s->version;

	if(s->record_route.s && s->record_route.len)
	{
		subs->record_route.s= (char*)pkg_malloc(s->record_route.len);
		if(subs->record_route.s== NULL)
		{
			ERR_MEM(PKG_MEM_STR);
		}
		memcpy(subs->record_route.s, s->record_route.s, s->record_route.len);
		subs->record_route.len= s->record_route.len;
	}

	if(subs->expires== 0)
	{
		/* delete record from hash table */
		ps= rls_table[hash_code].entries;
		int found= 0;
		while(ps->next)
		{
			if(ps->next== s)
			{
				found= 1;
				break;
			}
			ps= ps->next;
		}
		if(found== 0)
		{
			LM_ERR("record not found\n");
			goto error;
		}
		ps->next= s->next;
		shm_free(s);
	
	/* delete from rls_presentity table also */
	}
	
	lock_release(&rls_table[hash_code].lock);

	return 0;

error:
	lock_release(&rls_table[hash_code].lock);
	return -1;
}
开发者ID:KISSMonX,项目名称:opensips,代码行数:92,代码来源:subscribe.c


示例17: pxml_add_xcap_server

static int pxml_add_xcap_server( modparam_t type, void* val)
{
	xcap_serv_t* xs;
	int size;
	char* serv_addr= (char*)val;
	char* sep= NULL;
	unsigned int port= 80;
	str serv_addr_str;
		
	serv_addr_str.s= serv_addr;
	serv_addr_str.len= strlen(serv_addr);

	sep= strchr(serv_addr, ':');
	if(sep)
	{	
		char* sep2= NULL;
		str port_str;
		
		sep2= strchr(sep+ 1, ':');
		if(sep2)
			sep= sep2;
		

		port_str.s= sep+ 1;
		port_str.len= serv_addr_str.len- (port_str.s- serv_addr);

		if(str2int(&port_str, &port)< 0)
		{
			LM_ERR("while converting string to int\n");
			goto error;
		}
		if(port< 0 || port> 65535)
		{
			LM_ERR("wrong port number\n");
			goto error;
		}
		*sep = '\0';
		serv_addr_str.len= sep- serv_addr;
	}

	size= sizeof(xcap_serv_t)+ (serv_addr_str.len+ 1)* sizeof(char);
	xs= (xcap_serv_t*)pkg_malloc(size);
	if(xs== NULL)
	{
		ERR_MEM(PKG_MEM_STR);
	}
	memset(xs, 0, size);
	size= sizeof(xcap_serv_t);

	xs->addr= (char*)xs+ size;
	strcpy(xs->addr, serv_addr);

	xs->port= port;
	/* check for duplicates */
	xs->next= xs_list;
	xs_list= xs;
	return 0;

error:
	free_xs_list(xs_list, PKG_MEM_TYPE);
	return -1;
}
开发者ID:AlessioCasco,项目名称:kamailio,代码行数:62,代码来源:presence_xml.c


示例18: parse_subs_state

int parse_subs_state(str auth_state, str *reason, int *expires)
{
	str str_exp;
	char* smc= NULL;
	int len, flag= -1;

	if (strncmp(auth_state.s, "active", 6)== 0)
		flag= ACTIVE_STATE;

	if (strncmp(auth_state.s, "pending", 7)== 0)
		flag= PENDING_STATE; 

	if (strncmp(auth_state.s, "terminated", 10)== 0)
	{
		smc= strchr(auth_state.s, ';');
		if (smc== NULL)
		{
			LM_ERR("terminated state and no reason found");
			return -1;
		}
		if (strncmp(smc+1, "reason=", 7))
		{
			LM_ERR("terminated state and no reason found");
			return -1;
        	}
		len=  auth_state.len- 10- 1- 7;
		reason->s = (char*) pkg_malloc(len* sizeof(char));
		if (reason->s== NULL)
		{
			ERR_MEM(PKG_MEM_STR);
		}
		memcpy(reason->s, smc+ 8, len);
		reason->len= len;
		return TERMINATED_STATE;
	}
	
	if(flag> 0)
	{
		smc= strchr(auth_state.s, ';');
		if(smc== NULL)
		{
			LM_ERR("active or pending state and no expires parameter found");
			return -1;
		}	
		if(strncmp(smc+1, "expires=", 8))
		{
			LM_ERR("active or pending state and no expires parameter found");
			return -1;
		}
		str_exp.s= smc+ 9;
		str_exp.len= auth_state.s+ auth_state.len- smc- 9;

		if( str2int(&str_exp, (unsigned int*)expires)< 0)
		{
			LM_ERR("while getting int from str\n");
			return -1;
		}
		return flag;
	
	}

error:
	if (reason->s) pkg_free(reason->s);
	return -1;
}
开发者ID:mattvv,项目名称:kamailio,代码行数:65,代码来源:resource_notify.c


示例19: subs_cback_func


//.........这里部分代码省略.........
	size+= pfrom->uri.len;

	presentity->call_id.s= (char*)presentity + size;
	memcpy(presentity->call_id.s,msg->callid->body.s, 
		msg->callid->body.len);
	presentity->call_id.len= msg->callid->body.len;
	size+= presentity->call_id.len;

	presentity->to_tag.s= (char*)presentity + size;
	memcpy(presentity->to_tag.s,pto->tag_value.s, 
			pto->tag_value.len);
	presentity->to_tag.len= pto->tag_value.len;
	size+= pto->tag_value.len;

	presentity->from_tag.s= (char*)presentity + size;
	memcpy(presentity->from_tag.s,pfrom->tag_value.s, 
			pfrom->tag_value.len);
	presentity->from_tag.len= pfrom->tag_value.len;
	size+= pfrom->tag_value.len;

	if(record_route.len && record_route.s)
	{
		presentity->record_route.s= (char*)presentity + size;
		memcpy(presentity->record_route.s, record_route.s, record_route.len);
		presentity->record_route.len= record_route.len;
		size+= record_route.len;
		pkg_free(record_route.s);
	}


	presentity->contact.s= (char*)presentity + size;
	memcpy(presentity->contact.s, hentity->contact.s, hentity->contact.len);
	presentity->contact.len= hentity->contact.len;
	size+= hentity->contact.len;

	if(hentity->id.s)
	{
		presentity->id.s=(char*)presentity+ size;
		memcpy(presentity->id.s, hentity->id.s, 
			hentity->id.len);
		presentity->id.len= hentity->id.len; 
		size+= presentity->id.len;
	}

	if(hentity->extra_headers.s && hentity->extra_headers.len)
	{
		presentity->extra_headers.s= (char*)shm_malloc(hentity->extra_headers.len* sizeof(char));
		if(presentity->extra_headers.s== NULL)
		{
			ERR_MEM(SHARE_MEM);
		}
		memcpy(presentity->extra_headers.s, hentity->extra_headers.s, hentity->extra_headers.len);
		presentity->extra_headers.len= hentity->extra_headers.len;
	}

	/* write the remote contact filed */
	presentity->remote_contact.s= (char*)shm_malloc(contact.len* sizeof(char));
	if(presentity->remote_contact.s== NULL)
	{
		ERR_MEM(SHARE_MEM);
	}
	memcpy(presentity->remote_contact.s, contact.s, contact.len);
	presentity->remote_contact.len= contact.len;

	presentity->event|= hentity->event;
	presentity->flag= hentity->flag;
	presentity->etag.s= NULL;
	presentity->cseq= cseq;
	presentity->desired_expires= hentity->desired_expires;
	presentity->expires= lexpire+ (int)time(NULL);
	if(BLA_SUBSCRIBE & presentity->flag)
	{
		LM_DBG("BLA_SUBSCRIBE FLAG inserted\n");
	}
	LM_DBG("record for subscribe from %.*s to %.*s inserted in datatbase\n",
			presentity->watcher_uri->len, presentity->watcher_uri->s,
			presentity->pres_uri->len, presentity->pres_uri->s);
	insert_htable(presentity);

done:
	if(hentity->ua_flag == REQ_OTHER)
	{
		hentity->flag= flag;
		run_pua_callbacks( hentity, msg);
	}
error:
	if(hentity)
	{
	        if(presentity)
	        {
		        if(presentity->extra_headers.s)
		                shm_free(presentity->extra_headers.s);
		        if(presentity->remote_contact.s)
		                shm_free(presentity->remote_contact.s);
	        }
		shm_free(hentity);
		hentity= NULL;
	}
	return;
}
开发者ID:franklyfox,项目名称:opensips,代码行数:101,代码来源:send_subscribe.c


示例20: update_rlsubs

int update_rlsubs( subs_t* subs, unsigned int hash_code)
{
	subs_t* s;

	if (dbmode == RLS_DB_ONLY)
	{
		LM_ERR( "update_rlsubs called in RLS_DB_ONLY mode\n" );
	} 

	/* search the record in hash table */
	lock_get(&rls_table[hash_code].lock);

	s= pres_search_shtable(rls_table, subs->callid,
			subs->to_tag, subs->from_tag, hash_code);
	if(s== NULL)
	{
		LM_DBG("record not found in hash table\n");
		lock_release(&rls_table[hash_code].lock);
		return -1;
	}

	s->expires= subs->expires+ (int)time(NULL);
	
	if(s->db_flag & NO_UPDATEDB_FLAG)
		s->db_flag= UPDATEDB_FLAG;
	
	if(	s->remote_cseq>= subs->remote_cseq)
	{
		lock_release(&rls_table[hash_code].lock);
		LM_DBG("stored cseq= %d\n", s->remote_cseq);
		return Stale_cseq_code;
	}

	s->remote_cseq= subs->remote_cseq;

	subs->pres_uri.s= (char*)pkg_malloc(s->pres_uri.len* sizeof(char));
	if(subs->pres_uri.s== NULL)
	{
		ERR_MEM(PKG_MEM_STR);
	}
	memcpy(subs->pres_uri.s, s->pres_uri.s, s->pres_uri.len);
	subs->pres_uri.len= s->pres_uri.len;

	if(s->record_route.s!=NULL && s->record_route.len>0)
	{
		subs->record_route.s =
				(char*)pkg_malloc(s->record_route.len* sizeof(char));
		if(subs->record_route.s==NULL)
		{
			ERR_MEM(PKG_MEM_STR);
		}
		memcpy(subs->record_route.s, s->record_route.s, s->record_route.len);
		subs->record_route.len= s->record_route.len;
	}

	subs->local_cseq= s->local_cseq;
	subs->version= s->version;

	lock_release(&rls_table[hash_code].lock);

	return 0;

error:
	lock_release(&rls_table[hash_code].lock);
	return -1;
}
开发者ID:tripped,项目名称:kamailio,代码行数:66,代码来源:subscribe.c



注:本文中的ERR_MEM函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ ERR_MSG函数代码示例发布时间:2022-05-30
下一篇:
C++ ERR_IS_FATAL函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap