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

Function new_ehtable

modules/emergency/hash.c:36–77  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

34#include "hash.h"
35
36emetable_t new_ehtable(int hash_size){
37 emetable_t htable= NULL;
38 int i, j;
39
40 i = 0;
41 htable= (call_table_t*)shm_malloc(hash_size* sizeof(call_table_t));
42 if(htable== NULL)
43 {
44 LM_ERR("--------------------------------------------------no more shm memory\n");
45 goto error;
46 }
47 memset(htable, 0, hash_size* sizeof(call_table_t));
48
49 for(i= 0; i< hash_size; i++)
50 {
51 if(lock_init(&htable[i].lock)== 0)
52 {
53 LM_ERR("initializing lock [%d]\n", i);
54 goto error;
55 }
56 htable[i].entries= (NODE*)shm_malloc(sizeof(NODE));
57 if(htable[i].entries== NULL)
58 {
59 lock_destroy(&htable[i].lock);
60 LM_ERR("--------------------------------------------------no more shm memory\n");
61 }
62 memset(htable[i].entries, 0, sizeof(NODE));
63 htable[i].entries->next= NULL;
64 }
65
66 return htable;
67
68error:
69 if(htable){
70 for(j=0; j< i; j++){
71 lock_destroy(&htable[j].lock);
72 shm_free(htable[j].entries);
73 }
74 shm_free(htable);
75 }
76 return NULL;
77}
78
79
80sbtable_t new_shtable(int hash_size){

Callers 1

mod_initFunction · 0.85

Calls 4

shm_mallocFunction · 0.85
lock_initFunction · 0.85
lock_destroyFunction · 0.85
shm_freeFunction · 0.85

Tested by

no test coverage detected