| 526 | } |
| 527 | |
| 528 | pres_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 | |
| 573 | error: |
| 574 | if(p) |
| 575 | shm_free(p); |
| 576 | return NULL; |
| 577 | } |
| 578 | |
| 579 | int delete_phtable_query(str *pres_uri, int event, str* etag) |
| 580 | { |
no test coverage detected