MCPcopy Create free account
hub / github.com/OpenSIPS/opensips / insert_phtable

Function insert_phtable

modules/presence/hash.c:528–577  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

526}
527
528pres_entry_t* insert_phtable(str* pres_uri, int event, str* etag, char* sphere,
529 unsigned int flags, int init_turn)
530{
531 unsigned int hash_code;
532 pres_entry_t* p= NULL;
533 int size;
534
535 size= sizeof(pres_entry_t)+ pres_uri->len;
536 p= (pres_entry_t*)shm_malloc(size);
537 if(p== NULL)
538 {
539 ERR_MEM(SHARE_MEM);
540 }
541 memset(p, 0, size);
542
543 size= sizeof(pres_entry_t);
544 p->pres_uri.s= (char*)p+ size;
545 memcpy(p->pres_uri.s, pres_uri->s, pres_uri->len);
546 p->pres_uri.len= pres_uri->len;
547
548 if(sphere)
549 {
550 p->sphere= (char*)shm_malloc(strlen(sphere)+ 1);
551 if(p->sphere== NULL)
552 {
553 ERR_MEM(SHARE_MEM);
554 }
555 strcpy(p->sphere, sphere);
556 }
557 p->event= event;
558 p->flags = flags;
559 update_pres_etag(p, etag);
560
561 hash_code= core_hash(pres_uri, NULL, phtable_size);
562 lock_get(&pres_htable[hash_code].lock);
563
564 p->next= pres_htable[hash_code].entries->next;
565 pres_htable[hash_code].entries->next= p;
566
567 p->last_turn = init_turn;
568
569 lock_release(&pres_htable[hash_code].lock);
570
571 return p;
572
573error:
574 if(p)
575 shm_free(p);
576 return NULL;
577}
578
579int delete_phtable_query(str *pres_uri, int event, str* etag)
580{

Callers 2

update_presentityFunction · 0.85
pres_htable_restoreFunction · 0.85

Calls 6

shm_mallocFunction · 0.85
update_pres_etagFunction · 0.85
core_hashFunction · 0.85
lock_getFunction · 0.85
lock_releaseFunction · 0.85
shm_freeFunction · 0.85

Tested by

no test coverage detected