struct cc_data* init_cc_data(void) { struct cc_data *data; data = (struct cc_data*) shm_malloc( sizeof(struct cc_data) ); if (data==NULL) { LM_ERR("failed to allocate shm mem\n"); return NULL; } memset( data, 0, sizeof(struct cc_data)); /* create & init lock */ if ( (data->lock=lock_alloc())==0) { LM_CRIT("failed to alloc lock\n"); goto error; } if (lock_init(data->lock)==0 ) { LM_CRIT("failed to init lock\n"); goto error; } /* set of locks for calls */ if ( (data->call_locks=lock_set_alloc(512))==0) { LM_CRIT("failed to alloc set of call locks\n"); goto error; } if (lock_set_init(data->call_locks)==0 ) { LM_CRIT("failed to init set of call locks\n"); goto error; } return data; error: free_cc_data(data); return NULL; }
static void mod_destroy(void) { /* destroy data */ free_cc_data( data ); }