/** * Initializes the Peer Manager. * The initial list of peers is taken from the configuration provided * @param config - configuration for initial peers * @returns 1 */ int peer_manager_init(dp_config *config) { int i; peer *p; LOG(L_DBG,"DBG:peer_manager_init(): Peer Manager initialization...\n"); peer_list = shm_malloc(sizeof(peer_list_t)); peer_list->head = 0; peer_list->tail = 0; peer_list_lock = lock_alloc(); peer_list_lock = lock_init(peer_list_lock); hopbyhop_id = shm_malloc(sizeof(AAAMsgIdentifier)); endtoend_id = shm_malloc(sizeof(AAAMsgIdentifier)); msg_id_lock = lock_alloc(); msg_id_lock = lock_init(msg_id_lock); srand((unsigned int)time(0)); *hopbyhop_id = rand(); *endtoend_id = (time(0)&0xFFF)<<20; *endtoend_id |= rand() & 0xFFFFF; for(i=0;i<config->peers_cnt;i++){ p = new_peer(config->peers[i].fqdn,config->peers[i].realm,config->peers[i].port); if (!p) continue; p->is_dynamic = 0; add_peer(p); } add_timer(PEER_MANAGER_TIMER,0,&peer_timer,0); return 1; }
int wsconn_init(void) { wsconn_lock = lock_alloc(); if (wsconn_lock == NULL) { LM_ERR("allocating lock\n"); goto error; } if (lock_init(wsconn_lock) == 0) { LM_ERR("initialising lock\n"); goto error; } wsstat_lock = lock_alloc(); if (wsstat_lock == NULL) { LM_ERR("allocating lock\n"); goto error; } if (lock_init(wsstat_lock) == NULL) { LM_ERR("initialising lock\n"); goto error; } wsconn_id_hash = (ws_connection_t **) shm_malloc(TCP_ID_HASH_SIZE * sizeof(ws_connection_t*)); if (wsconn_id_hash == NULL) { LM_ERR("allocating WebSocket hash-table\n"); goto error; } memset((void *) wsconn_id_hash, 0, TCP_ID_HASH_SIZE * sizeof(ws_connection_t *)); wsconn_used_list = (ws_connection_used_list_t *) shm_malloc( sizeof(ws_connection_used_list_t)); if (wsconn_used_list == NULL) { LM_ERR("allocating WebSocket used list\n"); goto error; } memset((void *) wsconn_used_list, 0, sizeof(ws_connection_used_list_t)); return 0; error: if (wsconn_lock) lock_dealloc((void *) wsconn_lock); if (wsstat_lock) lock_dealloc((void *) wsstat_lock); wsconn_lock = wsstat_lock = NULL; if (wsconn_id_hash) shm_free(wsconn_id_hash); if (wsconn_used_list) shm_free(wsconn_used_list); wsconn_id_hash = NULL; wsconn_used_list = NULL; return -1; }
/** * Initializes the session related structures. */ int sessions_init(int hash_size) { int i; session_lock = lock_alloc(); if (!session_lock){ LOG_NO_MEM("lock",sizeof(gen_lock_t)); goto error; } session_lock = lock_init(session_lock); sessions_hash_size=hash_size; sessions = shm_malloc(sizeof(cdp_session_list_t)*hash_size); if (!sessions){ LOG_NO_MEM("shm",sizeof(cdp_session_list_t)*hash_size); goto error; } memset(sessions,0,sizeof(cdp_session_list_t)*hash_size); for(i=0;i<hash_size;i++){ sessions[i].lock = lock_alloc(); if (!sessions[i].lock){ LOG_NO_MEM("lock",sizeof(gen_lock_t)); goto error; } sessions[i].lock = lock_init(sessions[i].lock); } session_id1 = shm_malloc(sizeof(unsigned int)); if (!session_id1){ LOG_NO_MEM("shm",sizeof(unsigned int)); goto error; } session_id2 = shm_malloc(sizeof(unsigned int)); if (!session_id2){ LOG_NO_MEM("shm",sizeof(unsigned int)); goto error; } srand((unsigned int)time(0)); *session_id1 = rand(); *session_id1 <<= 16; *session_id1 += time(0)&0xFFFF; *session_id2 = 0; add_timer(1,0,session_timer,0); return 1; error: return 0; }
int dbt_init_cache() { if(!_cachesem) { /* init locks */ _cachesem = lock_alloc(); if(!_cachesem) { LOG(L_CRIT,"dbtext:dbt_init_cache: could not alloc a lock\n"); return -1; } if (lock_init(_cachesem)==0) { LOG(L_CRIT,"dbtext:dbt_init_cache: could not intialize a lock\n"); lock_dealloc(_cachesem); return -1; } } /* init pointer to caches list */ if (!_cachedb) { _cachedb = shm_malloc( sizeof(dbt_cache_p) ); if (!_cachedb) { LOG(L_CRIT,"dbtext:dbt_init_cache: no enough shm mem\n"); lock_dealloc(_cachesem); return -1; } *_cachedb = NULL; } return 0; }
int dbg_init_mypid(void) { if(_dbg_pid_list==NULL) return -1; if(process_no>=_dbg_pid_no) return -1; _dbg_pid_list[process_no].pid = (unsigned int)my_pid(); if(_dbg_breakpoint==1) _dbg_pid_list[process_no].set |= DBG_ABKPOINT_ON; if(_dbg_cfgtrace==1) _dbg_pid_list[process_no].set |= DBG_CFGTRACE_ON; if(_dbg_reset_msgid==1) { LM_DBG("[%d] create locks\n", process_no); _dbg_pid_list[process_no].lock = lock_alloc(); if(_dbg_pid_list[process_no].lock==NULL) { LM_ERR("cannot allocate the lock\n"); return -1; } if(lock_init(_dbg_pid_list[process_no].lock)==NULL) { LM_ERR("cannot init the lock\n"); lock_dealloc(_dbg_pid_list[process_no].lock); return -1; } } return 0; }
static int mod_init( void ) { LM_INFO("exec - initializing\n"); if (time_to_kill) initialize_kill(); if (async) { /* init exeternal structure if async enabled */ exec_async_list = shm_malloc(sizeof(exec_list_t)); if (!exec_async_list) { LM_ERR("no more shm memory\n"); return -1; } memset(exec_async_list, 0, sizeof(exec_list_t)); exec_async_list->lock = lock_alloc(); if (!exec_async_list->lock) { LM_ERR("cannot alloc asyncronous lock \n"); return -1; } if (!lock_init(exec_async_list->lock)) { LM_ERR("failed to init lock\n"); return -1; } } else { #ifdef STATIC_EXEC exec_exports.procs = 0; #else exports.procs = 0; #endif } return 0; }
static int update(struct vidfilt_st **stp, struct vidfilt *vf) { struct selfview *st; int err; if (!stp || !vf) return EINVAL; if (*stp) return 0; st = mem_zalloc(sizeof(*st), destructor); if (!st) return ENOMEM; err = lock_alloc(&st->lock); if (err) goto out; out: if (err) mem_deref(st); else *stp = (struct vidfilt_st *)st; return err; }
static int mod_init(void) { if(default_siputils_cfg.ring_timeout > 0) { ring_init_hashtable(); ring_lock = lock_alloc(); assert(ring_lock); if (lock_init(ring_lock) == 0) { LM_CRIT("cannot initialize lock.\n"); return -1; } if (register_script_cb(ring_filter, PRE_SCRIPT_CB|ONREPLY_CB, 0) != 0) { LM_ERR("could not insert callback"); return -1; } } /* bind the SL API */ if (sl_load_api(&opt_slb)!=0) { LM_ERR("cannot bind to SL API\n"); return -1; } if ( init_rpid_avp(rpid_avp_param)<0 ) { LM_ERR("failed to init rpid AVP name\n"); return -1; } if(cfg_declare("siputils", siputils_cfg_def, &default_siputils_cfg, cfg_sizeof(siputils), &siputils_cfg)){ LM_ERR("Fail to declare the configuration\n"); return -1; } return 0; }
static int selfview_alloc(struct selfview **selfviewp, void **ctx) { struct selfview *selfview; int err; if (!selfviewp || !ctx) return EINVAL; if (*ctx) { *selfviewp = mem_ref(*ctx); } else { selfview = mem_zalloc(sizeof(*selfview), destructor); if (!selfview) return ENOMEM; err = lock_alloc(&selfview->lock); if (err) return err; *ctx = selfview; *selfviewp = selfview; } return 0; }
static void init_push_queue() { if (push_queue == NULL) { push_lock = lock_alloc(); push_queue = calloc(1, sizeof(push_queue_t)); } }
char *dpth_mk(struct dpth *dpth) { static char save_path[32]; static struct lock *lock=NULL; while(1) { snprintf(save_path, sizeof(save_path), "%04X/%04X/%04X/%04X", dpth->prim, dpth->seco, dpth->tert, dpth->sig); if(!dpth->need_data_lock) return save_path; if(!lock && !(lock=lock_alloc())) goto error; if(get_data_lock(lock, dpth, save_path)) goto error; switch(lock->status) { case GET_LOCK_GOT: break; case GET_LOCK_NOT_GOT: // Increment and try again. if(dpth_incr(dpth)) goto error; continue; case GET_LOCK_ERROR: default: goto error; } dpth->need_data_lock=0; // Got it. if(add_lock_to_list(dpth, lock, save_path)) goto error; lock=NULL; return save_path; } error: lock_free(&lock); return NULL; }
int rtcp_sess_alloc(struct rtcp_sess **sessp, struct rtp_sock *rs) { struct rtcp_sess *sess; int err; if (!sessp) return EINVAL; sess = mem_zalloc(sizeof(*sess), sess_destructor); if (!sess) return ENOMEM; sess->rs = rs; tmr_init(&sess->tmr); err = lock_alloc(&sess->lock); if (err) goto out; err = hash_alloc(&sess->members, MAX_MEMBERS); if (err) goto out; out: if (err) mem_deref(sess); else *sessp = sess; return err; }
int init_tcp() { /* init lock */ tcpconn_lock=lock_alloc(); if (tcpconn_lock==0){ LOG(L_CRIT, "ERROR: init_tcp: could not alloc lock\n"); goto error; } if (lock_init(tcpconn_lock)==0){ LOG(L_CRIT, "ERROR: init_tcp: could not init lock\n"); lock_dealloc((void*)tcpconn_lock); tcpconn_lock=0; goto error; } /* init globals */ connection_id=(int*)shm_malloc(sizeof(int)); if (connection_id==0){ LOG(L_CRIT, "ERROR: init_tcp: could not alloc globals\n"); lock_destroy(tcpconn_lock); lock_dealloc((void*)tcpconn_lock); tcpconn_lock=0; goto error; } *connection_id=1; /* alloc hashtables*/ tcpconn_addr_hash=(struct tcp_connection**)shm_malloc(TCP_ADDR_HASH_SIZE* sizeof(struct tcp_connection*)); if (tcpconn_addr_hash==0){ LOG(L_CRIT, "ERROR: init_tcp: could not alloc address hashtable\n"); shm_free(connection_id); connection_id=0; lock_destroy(tcpconn_lock); lock_dealloc((void*)tcpconn_lock); tcpconn_lock=0; goto error; } tcpconn_id_hash=(struct tcp_connection**)shm_malloc(TCP_ID_HASH_SIZE* sizeof(struct tcp_connection*)); if (tcpconn_id_hash==0){ LOG(L_CRIT, "ERROR: init_tcp: could not alloc id hashtable\n"); shm_free(connection_id); connection_id=0; shm_free(tcpconn_addr_hash); tcpconn_addr_hash=0; lock_destroy(tcpconn_lock); lock_dealloc((void*)tcpconn_lock); tcpconn_lock=0; goto error; } /* init hashtables*/ memset((void*)tcpconn_addr_hash, 0, TCP_ADDR_HASH_SIZE * sizeof(struct tcp_connection*)); memset((void*)tcpconn_id_hash, 0, TCP_ID_HASH_SIZE * sizeof(struct tcp_connection*)); return 0; error: return -1; }
/*! * \brief Initialize the ro_session timer handler * Initialize the ro_session timer handler, allocate the lock and a global * timer in shared memory. The global timer handler will be set on success. * \param hdl ro_session timer handler * \return 0 on success, -1 on failure */ int init_ro_timer(ro_timer_handler hdl) { roi_timer = (struct ro_timer*) shm_malloc(sizeof (struct ro_timer)); if (roi_timer == 0) { LM_ERR("no more shm mem\n"); return -1; } memset(roi_timer, 0, sizeof (struct ro_timer)); roi_timer->first.next = roi_timer->first.prev = &(roi_timer->first); roi_timer->lock = lock_alloc(); if (roi_timer->lock == 0) { LM_ERR("failed to alloc lock\n"); goto error0; } if (lock_init(roi_timer->lock) == 0) { LM_ERR("failed to init lock\n"); goto error1; } timer_hdl = hdl; return 0; error1: lock_dealloc(roi_timer->lock); error0: shm_free(roi_timer); roi_timer = 0; return -1; }
/** * Initializes the worker structures, like the task queue. */ void worker_init() { tasks = shm_malloc(sizeof(task_queue_t)); tasks->lock = lock_alloc(); tasks->lock = lock_init(tasks->lock); tasks->empty = semget(IPC_PRIVATE,1,0666 | IPC_CREAT ); if (tasks->empty==-1){ LOG(L_ERR,"ERROR:worker_init(): Error creating semaphore for empty queue > %s\n",strerror(errno)); }else semctl(tasks->empty, 0, SETVAL, cdp_semun_init ); tasks->full = semget(IPC_PRIVATE,1, 0666 | IPC_CREAT ); if (tasks->full==-1){ LOG(L_ERR,"ERROR:worker_init(): Error creating semaphore for full queue > %s\n",strerror(errno)); }else semctl(tasks->full, 0, SETVAL, cdp_semun_init); tasks->start = 0; tasks->end = 0; tasks->max = config->queue_length; tasks->queue = shm_malloc(tasks->max*sizeof(task_t)); if (!tasks->queue) LOG_NO_MEM("shm",tasks->max*sizeof(task_t)); memset(tasks->queue,0,tasks->max*sizeof(task_t)); callbacks = shm_malloc(sizeof(cdp_cb_list_t)); callbacks->head = 0; callbacks->tail = 0; cdp_lock_get(tasks->empty); // lock_release(tasks->full); }
int initialize_kill(void) { /* if disabled ... */ if (time_to_kill == 0) return 0; if (register_timer("exec_kill", timer_routine, NULL /* param */, 1 /* period */, TIMER_FLAG_SKIP_ON_DELAY) < 0) { LM_ERR("no exec timer registered\n"); return -1; } kill_list = shm_malloc(sizeof *kill_list); if (!kill_list) { LM_ERR("no more shm!\n"); return -1; } kill_list->first_tl.next_tl = &kill_list->last_tl; kill_list->last_tl.prev_tl = &kill_list->first_tl; kill_list->first_tl.prev_tl = kill_list->last_tl.next_tl = NULL; kill_list->last_tl.time_out = -1; kill_lock = lock_alloc(); if (!kill_lock) { LM_ERR("no shm mem for mutex\n"); return -1; } lock_init(kill_lock); LM_DBG("kill initialized\n"); return 0; }
struct session* effect_session_start(void) { struct session *sess; char *automixv = webapp_options_getv("auto-mix-n-1"); sess = mem_zalloc(sizeof(*sess), sess_destruct); if (!sess) return NULL; calc_channel(sess); sess->run_play = false; sess->run_src = false; sess->bypass = bypass; sess->trev = 0; sess->prev = 0; lock_alloc(&sess->plock); list_append(&sessionl, &sess->le, sess); if (0 == str_cmp(automixv, "true")) { sess->run_auto_mix = true; warning("auto mix enabled\n"); } else { sess->run_auto_mix = false; warning("auto mix disabled\n"); } return sess; }
int init_dlg_ping_timer(void) { ping_timer = (struct dlg_ping_timer*)shm_malloc(sizeof(struct dlg_timer)); if (ping_timer==0) { LM_ERR("no more shm mem\n"); return -1; } memset(ping_timer,0,sizeof(struct dlg_ping_timer)); ping_timer->lock = lock_alloc(); if (ping_timer->lock == 0) { LM_ERR("failed to alloc lock\n"); goto error0; } if (lock_init(ping_timer->lock) == 0) { LM_ERR("failed to init lock\n"); goto error1; } return 0; error1: lock_dealloc(ping_timer->lock); error0: shm_free(ping_timer); ping_timer=0; return -1; }
/** * Create a new peer. * - All the memory from parameters is duplicated. * @param fqdn - FQDN of the peer * @param realm - Realm of the peer * @param port - port of the peer to connect to * @returns the new peer* if ok, NULL on error */ peer* new_peer(str fqdn,str realm,int port) { peer *x; x = shm_malloc(sizeof(peer)); if (!x){ LOG_NO_MEM("shm",sizeof(peer)); goto error; } memset(x,0,sizeof(peer)); shm_str_dup(x->fqdn,fqdn); if (!x->fqdn.s) goto error; shm_str_dup(x->realm,realm); if (!x->realm.s) goto error; x->port = port; x->lock = lock_alloc(); x->lock = lock_init(x->lock); x->state = Closed; x->I_sock = -1; x->R_sock = -1; x->activity = time(0)-500; x->next = 0; x->prev = 0; return x; error: return 0; }
struct lock *lock_alloc_and_init(const char *path) { struct lock *lock; if(!(lock=lock_alloc()) || lock_init(lock, path)) lock_free(&lock); return lock; }
/** * Initializes the high availability (ha) structure * * returns * 0 on success * -1 on error */ inline int init_pingtable(struct ha *table,int timeout,int maxpings) { if(maxpings<=0) maxpings=1; table->begin=0; table->end=0; table->timed_out_pings=0; table->size=maxpings; table->timeout=timeout; if (!(table->mutex=lock_alloc())){ LM_ERR("Unable to allocate a lock for the ping table\n"); goto error; }else lock_init(table->mutex); LM_ERR("alloc'ing %d bytes for %d pings\n",(int)(maxpings*sizeof(struct ping)),maxpings); if (0==(table->pings=shm_malloc(maxpings*sizeof(struct ping)))){ LM_ERR("Unable to shm_malloc %d bytes for %d pings\n",(int)(maxpings*sizeof(struct ping)),maxpings); goto error; }else{ memset(table->pings,0,(maxpings*sizeof(struct ping))); } return 0; error: destroy_pingtable(table); return -1; }
/** * Initializes the session related structures. */ int session_init() { session_lock = lock_alloc(); if (!session_lock){ LOG_NO_MEM("lock",sizeof(gen_lock_t)); goto error; } session_lock = lock_init(session_lock); session_id1 = shm_malloc(sizeof(unsigned int)); if (!session_id1){ LOG_NO_MEM("shm",sizeof(unsigned int)); goto error; } session_id2 = shm_malloc(sizeof(unsigned int)); if (!session_id2){ LOG_NO_MEM("shm",sizeof(unsigned int)); goto error; } srand((unsigned int)time(0)); *session_id1 = rand(); *session_id1 <<= 16; *session_id1 += time(0)&0xFFFF; *session_id2 = 0; return 1; error: return 0; }
int init_extra_avps(void) { extra_lock = lock_alloc(); if (!extra_lock) { LM_ERR("cannot allocate lock\n"); return -1; } if (!lock_init(extra_lock)) { LM_ERR("cannot init lock\n"); return -1; } last_avp_index_shm = shm_malloc(sizeof(int)); if (!last_avp_index_shm) { LM_ERR("not enough shm mem\n"); return -1; } *last_avp_index_shm = last_avp_index; /* initialize map for dynamic avps */ avp_map_shm = map_create(AVLMAP_SHARED); if (!avp_map_shm) { LM_ERR("cannot create shared avp_map\n"); return -1; } return 0; }
/* * Initializes the charging timer @Params char *key_value_file - the IPTV hash table configuration file * * */ int msg_timer_init(char *key_value_file) { LOG(L_INFO,"UCT IMS Charging System\n"); LOG(L_INFO,"Developers: Vitalis Gavole Ozianyi and Joyce B. Mwangama (2009)\n"); LOG(L_INFO,"INFO: msg_timer_init() - Initialize message timer\n"); list_of_clients = shm_malloc(sizeof(client_list)); if (!list_of_clients){ LOG_NO_MEM("shm",sizeof(client_list)); return 0; } list_of_clients->head = 0; list_of_clients->tail = 0; list_of_clients->lock = lock_alloc(); list_of_clients->lock = lock_init(list_of_clients->lock); if(!add_timer(1,0,&msg_timer,0)) { LOG(L_ERR,"CTF - msg_timer_init() - Failed to adder timer"); return 0; } LOG(L_INFO,"INFO: msg_timer_init() - Calling the IPTV function\n\n"); if(!iptv_start(key_value_file)) { LOG(L_CRIT,"CRITICAL: msg_timer_init() - Error on iptv_start\n"); return 0; } return 1; }
/* probably implemented as a heap */ dispatcher_t* new_dispatcher(void) { dispatcher_t* ret = shm_malloc(sizeof (*ret)); if (ret == NULL) { LM_ERR("Allocating dispatcher\n"); return NULL; } ret->size = 0; ret->lock = lock_alloc(); if (ret->lock == NULL) { LM_ERR("Allocating lock\n"); return NULL; } lock_init(ret->lock); sem_init(&ret->sem, 0, 0); return ret; }
int dbt_init_cache(void) { int i, j; if(!_dbt_cachesem) { /* init locks */ _dbt_cachesem = lock_alloc(); if(!_dbt_cachesem) { LM_CRIT("could not alloc a lock\n"); return -1; } if (lock_init(_dbt_cachesem)==0) { LM_CRIT("could not initialize a lock\n"); lock_dealloc(_dbt_cachesem); return -1; } } /* init pointer to caches list */ if (!_dbt_cachedb) { _dbt_cachedb = shm_malloc( sizeof(dbt_cache_p) ); if (!_dbt_cachedb) { LM_CRIT("no enough shm mem\n"); lock_dealloc(_dbt_cachesem); return -1; } *_dbt_cachedb = NULL; } /* init tables' hash table */ if (!_dbt_cachetbl) { _dbt_cachetbl = (dbt_tbl_cachel_p)shm_malloc(DBT_CACHETBL_SIZE* sizeof(dbt_tbl_cachel_t)); if(_dbt_cachetbl==NULL) { LM_CRIT("no enough shm mem\n"); lock_dealloc(_dbt_cachesem); shm_free(_dbt_cachedb); return -1; } memset(_dbt_cachetbl, 0, DBT_CACHETBL_SIZE*sizeof(dbt_tbl_cachel_t)); for(i=0; i<DBT_CACHETBL_SIZE; i++) { if (lock_init(&_dbt_cachetbl[i].sem)==0) { LM_CRIT("cannot init tables' sem's\n"); for(j=i-1; j>=0; j--) lock_destroy(&_dbt_cachetbl[j].sem); lock_dealloc(_dbt_cachesem); shm_free(_dbt_cachedb); return -1; } } } return 0; }
/** * Init the timer structures */ void timer_cdp_init() { timers = shm_malloc(sizeof(timer_cb_list_t)); timers->head=0; timers->tail=0; timers_lock = lock_alloc(); timers_lock = lock_init(timers_lock); }
IORWLock * IORWLockAlloc( void ) { IORWLock * lock; lock = lock_alloc( true, ETAP_IO_AHA, ETAP_IO_AHA); return( lock); }
static struct lock *setup(void) { struct lock *lock; fail_unless((lock=lock_alloc())!=NULL); fail_unless(!lock_init(lock, lockfile)); ck_assert_str_eq(lock->path, lockfile); fail_unless(lock->status==GET_LOCK_NOT_GOT); return lock; }
/** * Parse a IMS Subscription. * @param doc - the XML document * @param root - the current node * @returns the ims_subscription* on success or NULL on error */ static ims_subscription* parse_ims_subscription(xmlDocPtr doc, xmlNodePtr root) { xmlNodePtr child; xmlChar *x; ims_subscription *s; unsigned short sp_cnt=0; int rc; if (!root) return 0; while(root->type!=XML_ELEMENT_NODE || strcasecmp((char*)root->name,"IMSSubscription")!=0){ root = root->next; } if (!root) { LM_ERR("No IMSSubscription node found\n"); return 0; } s = (ims_subscription*) shm_malloc(sizeof(ims_subscription)); if (!s) { LM_ERR("Out of memory allocating %lx bytes\n",sizeof(ims_subscription)); return 0; } memset(s,0,sizeof(ims_subscription)); for(child=root->children;child;child=child->next) if (child->type==XML_ELEMENT_NODE) switch (child->name[0]){ case 'P':case 'p': /* Private Identity */ if (!s->private_identity.len){ x = xmlNodeListGetString(doc,child->xmlChildrenNode,1); space_trim_dup(&(s->private_identity),(char*)x); xmlFree(x); } break; case 'S':case 's': /* Service Profile */ sp_cnt++; break; } s->service_profiles = (ims_service_profile*) shm_malloc(sp_cnt * sizeof(ims_service_profile)); if (!s->service_profiles) { LM_ERR("Out of memory allocating %lx bytes\n",sp_cnt*sizeof(ims_service_profile)); return s; } memset(s->service_profiles,0,sp_cnt * sizeof(ims_service_profile)); for(child=root->children;child;child=child->next) if (child->type==XML_ELEMENT_NODE) if (child->name[0]=='S' || child->name[0]=='s') { rc=parse_service_profile(doc,child,&(s->service_profiles[s->service_profiles_cnt])); if (rc==2) s->wpsi=1; if (rc) s->service_profiles_cnt++; } s->lock = lock_alloc(); s->lock = lock_init(s->lock); return s; }