| 104 | |
| 105 | |
| 106 | struct cc_data* init_cc_data(void) |
| 107 | { |
| 108 | struct cc_data *data; |
| 109 | |
| 110 | data = (struct cc_data*) shm_malloc( sizeof(struct cc_data) ); |
| 111 | if (data==NULL) { |
| 112 | LM_ERR("failed to allocate shm mem\n"); |
| 113 | return NULL; |
| 114 | } |
| 115 | memset( data, 0, sizeof(struct cc_data)); |
| 116 | |
| 117 | /* create & init lock */ |
| 118 | if ( (data->lock=lock_alloc())==0) { |
| 119 | LM_CRIT("failed to alloc lock\n"); |
| 120 | goto error; |
| 121 | } |
| 122 | if (lock_init(data->lock)==0 ) { |
| 123 | LM_CRIT("failed to init lock\n"); |
| 124 | goto error; |
| 125 | } |
| 126 | |
| 127 | /* set of locks for calls */ |
| 128 | if ( (data->call_locks=lock_set_alloc(512))==0) { |
| 129 | LM_CRIT("failed to alloc set of call locks\n"); |
| 130 | goto error; |
| 131 | } |
| 132 | if (lock_set_init(data->call_locks)==0 ) { |
| 133 | LM_CRIT("failed to init set of call locks\n"); |
| 134 | goto error; |
| 135 | } |
| 136 | |
| 137 | agent_evi_id = evi_publish_event(agent_event); |
| 138 | if (agent_evi_id == EVI_ERROR) { |
| 139 | LM_ERR("cannot register %.*s event\n", agent_event.len, agent_event.s); |
| 140 | goto error; |
| 141 | } |
| 142 | |
| 143 | return data; |
| 144 | error: |
| 145 | free_cc_data(data); |
| 146 | return NULL; |
| 147 | } |
| 148 | |
| 149 | |
| 150 | void free_cc_data(struct cc_data *data) |
no test coverage detected