rem: db_res_t* db_res = NULL; code_t i, code; dc_t* cell;
add: DBG("PDT: initializing...\n");
context: static int mod_init(void){	db_res_t* db_res = NULL;	code_t i, code;	dc_t* cell; 			DBG("PDT: initializing...\n");		if(hs_two_pow<0)	{		LOG(L_ERR, "PDT: mod_init: hash_size_two_pow must be"					" positive and less than %d\n", MAX_HSIZE_TWO_POW);		return -1;	}		if(code_terminator>9 || code_terminator<0)	{		LOG(L_ERR, "PDT: mod_init: code_terminator must be a digit\n");		return -1;	}	if(!prefix_valid())		return -1;	next_code = (code_t*)shm_malloc(sizeof(code_t));	if(!next_code)	{		LOG(L_ERR, "PDT: mod_init: cannot allocate next_code!\n");		return -1;	}	if(lock_init(&l) == 0)	{				shm_free(next_code);		LOG(L_ERR, "PDT: mod_init: cannot init the lock\n");		return -1;		}			if(register_fifo_cmd(get_domainprefix, "get_domainprefix", 0)<0)	{		LOG(L_ERR, "PDT: mod_init: cannot register fifo command 'get_domaincode'\n");		goto error1;	}		if(unixsock_register_cmd("get_domainprefix", get_domainprefix_unixsock)<0)	{		LOG(L_ERR, "PDT: mod_init: cannot register unixsock command 'get_domainprefix'\n");		goto error1;	}	/* binding to mysql module */	if(bind_dbmod(db_url, &pdt_dbf))	{		LOG(L_ERR, "PDT: mod_init: Database module not found\n");		goto error1;	}	if (!DB_CAPABILITY(pdt_dbf, DB_CAP_ALL)) {		LOG(L_ERR, "PDT: mod_init: Database module does not "		    "implement all functions needed by the module\n");		goto error1;	}	/* open a connection with the database */	db_con = pdt_dbf.init(db_url);	if(!db_con)	{			LOG(L_ERR, "PDT: mod_init: Error while connecting to database\n");        		goto error1;	}	else	{		if (pdt_dbf.use_table(db_con, db_table) < 0) {			LOG(L_ERR, "PDT: mod_init: Error in use_table\n");			goto error1;		}		DBG("PDT: mod_init: Database connection opened successfully\n");	}		/* init hashes in share memory */	if( (hash = init_double_hash(hs_two_pow)) == NULL)	{		LOG(L_ERR, "PDT: mod_init: hash could not be allocated\n");			goto error2;	}		/* loading all information from database */	*next_code = 0;	if(pdt_dbf.query(db_con, NULL, NULL, NULL, NULL, 0, 0, "code", &db_res)==0)	{		for(i=0; i<RES_ROW_N(db_res); i++)		{						code = RES_ROWS(db_res)[i].values[0].val.int_val; 			if (!code_valid(code))			{				LOG(L_ERR, "PDT: mod_init: existing code contains the terminator\n");				goto error;			}						if (*next_code < code)				*next_code = code;			cell=new_cell(			(char*)(RES_ROWS(db_res)[i].values[1].val.string_val), code);						if(cell == NULL)					goto error;						if(add_to_double_hash(hash, cell)<0)			{				LOG(L_ERR, "PDT: mod_init: could not add information from database"								" into shared-memory hashes\n");				goto error;			}			 		}		// clear up here		//print_hash(hash->dhash, hash->hash_size);		//print_hash(hash->chash, hash->hash_size);		(*next_code)++;		if (*next_code < start_range)				*next_code = start_range;		*next_code = apply_correction(*next_code);		DBG("PDT: mod_init: next_code:%d\n", *next_code);				/* free up the space allocated for response */		if(pdt_dbf.free_result(db_con, db_res)<0)		{			LOG(L_ERR, "PDT: mod_init: error when freeing"				" up the response space\n");		}	}	else	{		/* query to database failed */		LOG(L_ERR, "PDT: mod_init: query to database failed\n");		goto error;	}	pdt_dbf.close(db_con); /* janakj - close the connection */	/* success code */	return 0;error:	free_double_hash(hash);	hash = 0;error2:	pdt_dbf.close(db_con);	db_con = 0;error1:		shm_free(next_code);	next_code = 0;	lock_destroy(&l);	return -1;}	