Ejemplo n.º 1
0
void ATOM_BaseImage::init (unsigned width, unsigned height, ATOM_PixelFormat format, const void* data, int mipcount) 
{
	ATOM_STACK_TRACE(ATOM_BaseImage::init);
	if ( width == 0 || height == 0)
	{
		fini ();
		return;
	}

	if ( !ATOM_IS_VALID_FORMAT(format))
	{
		ATOM_LOGGER::error ("[ATOM_BaseImage::init] Bad arguments: %d, %d, %d.\n", width, height, format);
		return;
	}

	unsigned buffersize = 0;
	const int blockdiv = 4;

	switch (format)
	{
	case ATOM_PIXEL_FORMAT_DXT1:
	case ATOM_PIXEL_FORMAT_DXT3:
	case ATOM_PIXEL_FORMAT_DXT5:
		{
			int blocksize = (format == ATOM_PIXEL_FORMAT_DXT1) ? 8 : 16;
			unsigned w = width;
			unsigned h = height;
			for (int i = 0; i < mipcount; ++i)
			{
				buffersize += ATOM_max2(blockdiv, w)/blockdiv * ATOM_max2(blockdiv, h)/blockdiv * blocksize;
				w = (w+1)>>1;
				h = (h+1)>>1;
			}
			break;
		}
	default:
		{
			unsigned bpp = ATOM_PIXEL_FORMAT(format).bpp / 8;
			buffersize = width * height * bpp;
			break;
		}
	}

	if (_M_contents && buffersize > _M_actual_size)
	{
		fini();
	}

	_M_buffersize = buffersize;

	if (!_M_contents)
	{
		_M_contents = ATOM_NEW_ARRAY(unsigned char, _M_buffersize);
		ATOM_ASSERT (_M_contents);
		_M_actual_size = _M_buffersize;
	}
Ejemplo n.º 2
0
int PlatDbAccess::init(const char *host, const char *user, const char *passwd, int port
        , int index)
{
    if (host==NULL || user==NULL || passwd==NULL 
        || index >= DB_CONN_MAX || index <0)
    {
        ACE_DEBUG((LM_ERROR, "[%D] PlatDbAccess init failed, para is invalid\n"));
        return -1;
    }
	
	//初始化一池连接
    if (db_conn_[index] != NULL)
    {
        fini(index);
    }

    ACE_DEBUG((LM_DEBUG, "[%D] PlatDbAccess start to connect db"
    	",host=%s"
    	",user=%s"
    	",passwd=%s"
    	",index=%d"
    	"\n"
    	, host
    	, user
    	, passwd
    	, index
    	));

    db_conn_[index] = new PlatDbConn();
    if (db_conn_[index]->connect(host, user, passwd, port, time_out_) != 0)
    {
        ACE_DEBUG((LM_ERROR, "[%D] PlatDbAccess connect db failed, errmsg=%s\n"
            , db_conn_[index]->get_err_msg()));
        fini(index);
        return -1;
    }

    ACE_DEBUG((LM_INFO, "[%D] PlatDbAccess connect db succ"
        ",host=%s"
        ",user=%s"
        ",passwd=%s"
        ",index=%d"
        "\n"
        , host
        , user
        , passwd
        , index
        ));
    
    return 0;
}
Ejemplo n.º 3
0
ogl::pool::~pool()
{
    for (node_s::iterator i = my_node.begin(); i != my_node.end(); ++i)
        delete (*i);

    fini();
}
Ejemplo n.º 4
0
int db2_access(test_req_t *req, test_req_t *resp)
{
	SQLHENV henv;	/* environment handle */
	SQLHDBC hdbc;	/* connection handle */
	SQLRETURN rc = SQL_ERROR;
	SQLHSTMT shdl;

	btlogger_debug("op=%c data=%s db=%s\n", req->op, req->data, req->db);

	if (init(req->db, &henv, &hdbc) != SQL_SUCCESS)
		return (int) rc;

	rc = SQLAllocHandle(SQL_HANDLE_STMT, hdbc, &shdl);

	if ( rc != SQL_SUCCESS ) {
		(void) check_error(SQL_HANDLE_STMT, shdl, rc, "SQLAllocHandle", (SQLCHAR *) "statement handle");
	} else {
		rc = doWork(req->op, req->data, henv, hdbc, shdl, resp);
		(void) SQLFreeStmt(shdl, SQL_DROP);
	}

	fini(henv, hdbc);

	return (int) rc;
}
Ejemplo n.º 5
0
static int __init init(void)
{
	int i, ret;

	if (ports[0] == 0)
		ports[0] = WMINITIAL;

	for (i = 0; (i < MAXWM_PORTS) && ports[i]; i++) {
		memset(&wm[i], 0, sizeof(struct ip_conntrack_helper));
		wm[i].tuple.src.u.tcp.port = htons(ports[i]);
		wm[i].tuple.dst.protonum = IPPROTO_TCP;
		wm[i].mask.src.u.tcp.port = 0xFFFF;
/*eshi*/
		wm[i].mask.dst.protonum = 0xFFFF;
		wm[i].max_expected = WMMAXEXPECTED;
                wm[i].timeout = 0;
                wm[i].flags = IP_CT_HELPER_F_REUSE_EXPECT;
                wm[i].me = ip_conntrack_wm;
		wm[i].help = help;

		DEBUGP("ip_conntrack_wm: registering helper for port %d\n", 
				ports[i]);
		ret = ip_conntrack_helper_register(&wm[i]);

		if (ret) {
		  fini();
	  printk("ip_conntrack_wm: registering helper for port FAILED  \n"); 
		  return ret;
		}
		ports_c++;
	}
	return 0;
}
Ejemplo n.º 6
0
int main(int argc, char **argv)
{
    int ret = 0;
    
	if(tapp_sigaction() != E_TLIBC_NOERROR)
	{
		ret = 1;
		ERROR_PRINT("tapp_sigaction(), errno %d.", errno);
		goto done;
	}

    tapp_load_config(&g_config, argc, argv, (tapp_xml_reader_t)tlibc_read_tlogd_config);
	if(init() != E_TLIBC_NOERROR)
	{
		ret = 1;
		goto done;
	}


	if(tapp_loop(TAPP_IDLE_USEC, TAPP_IDLE_LIMIT
				 , tbusapi_process, &g_tbusapi
	             , NULL, NULL) != E_TLIBC_NOERROR)
	{
		ret = 1;
	}

	fini();
done:
    return ret;
}
Ejemplo n.º 7
0
/**
 * i'm being really sloppy here. ideally, one should probably save the rc and
 * then display or do some other cool thing with it. don't be like this code. if
 * QUO_construct or QUO_init fail, then someone using this could just continue
 * without the awesomeness that is libquo. they cleanup after themselves, so
 * things *should* be in an okay state after an early failure. the failures may
 * be part of a larger problem, however. */
static int
init(context_t **c)
{
    int name_len = 0;
    context_t *newc = NULL;
    /* alloc our context */
    if (NULL == (newc = calloc(1, sizeof(*newc)))) return 1;
    /* libquo requires that MPI be initialized before its init is called */
    if (MPI_SUCCESS != MPI_Init(NULL, NULL)) return 1;
    /* gather some basic job info from our mpi lib */
    if (MPI_SUCCESS != MPI_Comm_size(MPI_COMM_WORLD, &(newc->nranks))) goto err;
    /* ...and more */
    if (MPI_SUCCESS != MPI_Comm_rank(MPI_COMM_WORLD, &(newc->rank))) goto err;
    /* stash my host's name */
    if (MPI_SUCCESS != MPI_Get_processor_name(newc->hostname, &name_len)) {
        goto err;
    }
    /* can be called at any point -- even before init and construct. */
    if (QUO_SUCCESS != QUO_version(&(newc->qv), &(newc->qsv))) goto err;
    /* relatively expensive call. you only really want to do this once at the
     * beginning of time and pass the context all over the place within your
     * code. */
    if (QUO_SUCCESS != QUO_create(&newc->quo)) goto err;
    newc->mpi_inited = true;
    *c = newc;
    return 0;
err:
    (void)fini(newc);
    return 1;
}
Ejemplo n.º 8
0
static int __init init(void)
{
	int i, ret;

	/* If no port given, default to standard irc port */

	if (ports[0] == 0)
		ports[0] = 500;

	for (i = 0; (i < MAX_PORTS) && ports[i]; i++) {
		memset(&ipsec_helpers[i], 0,
		       sizeof(struct ip_conntrack_helper));
		ipsec_helpers[i].tuple.src.u.udp.port = htons(ports[i]);
		ipsec_helpers[i].tuple.dst.protonum = IPPROTO_UDP;
		ipsec_helpers[i].mask.src.u.udp.port = 0xFFFF;
		ipsec_helpers[i].mask.dst.protonum = 0xFFFF;
		ipsec_helpers[i].help = help;


		ret = ip_conntrack_helper_register(&ipsec_helpers[i]);

		if (ret) {
			printk("ip_conntrack_ipsec: ERROR registering port %d\n",
				ports[i]);
			fini();
			return -EBUSY;
		}
		ports_n_c++;
	}

	return 0;
}
Ejemplo n.º 9
0
static int __init init(void) {
	int ret;
	char *tmpname;

	if (ports == 0)
		ports = 6112;

	memset(&sc, 0, sizeof(struct ip_nat_helper));

	sc.tuple.dst.protonum = IPPROTO_TCP;
	sc.tuple.src.u.udp.port = htons(ports);
	sc.mask.dst.protonum = 0xFFFF;
	sc.mask.src.u.tcp.port = 0xFFFF;
	sc.help = help;

	tmpname = &sc_names[0];
	sprintf(tmpname, "sc");
	sc.name = tmpname;

	DEBUGP("ip_nat_sc: Trying to register for port %d\n", ports);
	ret = ip_nat_helper_register(&sc);

	if (ret) {
		printk("ip_nat_sc: error registering helper for port %d\n", ports);
		fini();
		return ret;
	}

	return ret;
}
Ejemplo n.º 10
0
static int __init init(void)
{
    int ret = 0;
    
    slport.list.next = 0;
    slport.list.prev = 0;
    slport.me = THIS_MODULE;
    slport.flags = (IP_NAT_HELPER_F_STANDALONE|IP_NAT_HELPER_F_ALWAYS);
    slport.tuple.dst.protonum = IPPROTO_TCP;
    
    slport.tuple.dst.u.tcp.port = __constant_htons(SL_PORT);
    slport.mask.dst.u.tcp.port = 0;
    slport.help = slport_help;
    slport.expect = NULL;

#ifdef SL_DEBUG
    printk(KERN_DEBUG "ip_nat_sl: Trying to register for port %d\n", SL_PORT);
#endif

    ret = ip_nat_helper_register(&slport);


    if (ret) {

#ifdef SL_DEBUG
        printk(KERN_ERR "ip_nat_sl: error registering helper for port %d\n", SL_PORT);
#endif

        fini();
      return ret;
    }
    return ret;
}
Ejemplo n.º 11
0
static int __init
init(void)
{
	int i, ret;
	struct nf_conntrack_helper *hlpr;
	char *tmpname;

	printk("nf_conntrack_rtsp v" IP_NF_RTSP_VERSION " loading\n");

	if (max_outstanding < 1) {
		printk("nf_conntrack_rtsp: max_outstanding must be a positive integer\n");
		return -EBUSY;
	}
	if (setup_timeout < 0) {
		printk("nf_conntrack_rtsp: setup_timeout must be a positive integer\n");
		return -EBUSY;
	}

	rtsp_expect_policy.max_expected = max_outstanding;
	rtsp_expect_policy.timeout = setup_timeout;

	rtsp_buffer = kmalloc(65536, GFP_KERNEL);
	if (!rtsp_buffer)
		return -ENOMEM;

	/* If no port given, default to standard rtsp port */
	if (ports[0] == 0) {
		ports[0] = RTSP_PORT;
	}

	for (i = 0; (i < MAX_PORTS) && ports[i]; i++) {
		hlpr = &rtsp_helpers[i];
		memset(hlpr, 0, sizeof(struct nf_conntrack_helper));
		hlpr->tuple.src.u.tcp.port = htons(ports[i]);
		hlpr->tuple.dst.protonum = IPPROTO_TCP;
		hlpr->expect_policy = &rtsp_expect_policy;
		hlpr->me = THIS_MODULE;
		hlpr->help = help;

		tmpname = &rtsp_names[i][0];
		if (ports[i] == RTSP_PORT) {
			sprintf(tmpname, "rtsp");
		} else {
			sprintf(tmpname, "rtsp-%d", i);
		}
		hlpr->name = tmpname;

		DEBUGP("port #%d: %d\n", i, ports[i]);

		ret = nf_conntrack_helper_register(hlpr);

		if (ret) {
			printk("nf_conntrack_rtsp: ERROR registering port %d\n", ports[i]);
			fini();
			return -EBUSY;
		}
		num_ports++;
	}
	return 0;
}
Ejemplo n.º 12
0
void
abnormTest()
{
	init();
	TEST(testDocco);
	fini();
}
Ejemplo n.º 13
0
void
genfoamTestSuite()
{
	init();
	TEST(testForeign);
	fini();
}
Ejemplo n.º 14
0
int main(int argc, char *argv[])
{
	int ret;
	tapp_load_config(&g_config, argc, argv, (tapp_xml_reader_t)tlibc_read_tconnd_robot_config);
	if(tapp_sigaction() != E_TLIBC_NOERROR)
	{
		ret = 1;
		goto done;
	}

	init();
	if(tapp_loop(TAPP_IDLE_USEC, TAPP_IDLE_LIMIT
	            , process, NULL
	            , NULL, NULL) == E_TLIBC_NOERROR)
	{
		ret = 0;
	}
	else
	{
		ret = 1;
	}
	fini();
done:
	return ret;
}
Ejemplo n.º 15
0
int PlatDbAccess::exec_trans(const vector<string>& sqls, int & last_insert_id
    , int & affected_rows, unsigned int uin)
{
    int index = get_conn_index(uin);
    ACE_Guard<ACE_Thread_Mutex> guard(db_conn_lock_[index]); 
    // 标识是否在使用 如果不使用了 请注意清理 
	db_conn_flag_[index] = 1; 
    
    ACE_DEBUG((LM_TRACE, "[%D] PlatDbAccess exec_trans sql vec size=%d,conn index=%d\n", sqls.size(), index));

    PlatDbConn* db_conn = get_db_conn(index);
    if (db_conn == NULL)
    {
        ACE_DEBUG((LM_ERROR, "[%D] PlatDbAccess get db conn failed\n"));
		db_conn_flag_[index] = 0;
        return -1;
    }

    int ret = 0;
    ret = db_conn->exec_trans(sqls, last_insert_id, affected_rows);
    if (ret != 0)
    {
        ACE_DEBUG((LM_ERROR, "[%D] PlatDbAccess exec_trans failed,%s\n", db_conn->get_err_msg() ));
        if(ret == -1) // -1 表示服务器连接断开
        {
            ret = db_conn->exec_trans(sqls, last_insert_id, affected_rows);
            if(ret == -1) //重连还失败,清理这个连接对象
            {
                fini(index);
            }
        }
    }
    db_conn_flag_[index] = 0;
    return stat_return(ret);
}
Ejemplo n.º 16
0
void
archiveTestSuite()
{
	init();
	TEST(testArchive);
	fini();
}
Ejemplo n.º 17
0
int main(int argc, char **argv)
{
    int ret = 0;
    
	if(tapp_sigaction() != E_TLIBC_NOERROR)
	{
    	ERROR_PRINT("tapp_sigaction failed.");
		goto ERROR_RET;
	}
    tapp_load_config(&g_config, argc, argv, (tapp_xml_reader_t)tlibc_read_tconnd_config);

    
	if(init() != E_TLIBC_NOERROR)
	{
		goto ERROR_RET;
	}   

    if(tapp_loop(TAPP_IDLE_USEC, TAPP_IDLE_LIMIT
                , process, NULL
                , NULL, NULL) == E_TLIBC_NOERROR)
    {
        ret = 0;
    }
    else
    {
        ret = 1;
    }

	fini();

	return 0;
ERROR_RET:
	return 1;
}
Ejemplo n.º 18
0
CPropPannel::CPropPannel(CWnd* pParent /*=NULL*/)
	: CDialog(CPropPannel::IDD, pParent)
	, m_nHoldCount(0)
	, m_nBuyCount(0)
	, m_strBuyMoney(_T(""))
	, m_sGiveUser(_T(""))
	, m_nGiveCount(0)
{
	pParentWnd=NULL;
	imgDialog=0;
	

	CString s=CBcfFile::GetAppPath ();/////本地路径
	CBcfFile f( s + "skin0.bcf");
	CString key=TEXT("PropPannel");
	int r,g,b;
	m_bkcolor_R = f.GetKeyVal(key,"PropPannelR",44);
	m_bkcolor_G = f.GetKeyVal(key,"PropPannelG",114);
	m_bkcolor_B = f.GetKeyVal(key,"PropPannelB",233);
	m_bkcolor=RGB(m_bkcolor_R,m_bkcolor_G,m_bkcolor_B);

	CBcfFile fini(s+"bzgame.bcf");
	m_strPropUrl=fini.GetKeyVal("BZW","PropPannelUrl","http://game.bzw.cn/app/Prop/PropInfo.asp");
	m_nOpenFrom=0;

	curPropID = 0;
	curPropPrice = 0;
	curPropVipPrice = 0;

	m_bkBrush=NULL;
}
Ejemplo n.º 19
0
void Fini(int display)
{
  glutDisplay *glut_dpy = (glutDisplay *)display;

  fini((int)glut_dpy->x11_dpy);

  free(glut_dpy);
}
Ejemplo n.º 20
0
void
bitvTestSuite()
{
	init();
	TEST(testBitvToInt);
	TEST(testBitvCount);
	fini();
}
Ejemplo n.º 21
0
void
symeTest()
{
	init();
	TEST(testSymeSExpr);
	TEST(testSymeAddCondition);
	fini();
}
Ejemplo n.º 22
0
void
scobindTest(void)
{
	init();
	TEST(testScobind);
	TEST(testScobindCondition);
	TEST(testScobindConditionMulti);
	fini();
}
Ejemplo n.º 23
0
DHVideoDecoder::~DHVideoDecoder()
{
	fini();
	if( m_pDecBuff )
	{
		delete []m_pDecBuff;
		m_pDecBuff = NULL;
	}
}
Ejemplo n.º 24
0
static int __init init(void)
{
	int port, ret;
	char *tmpname;

	/* If no port given, default to standard RPC port */
	if (ports[0] == 0)
		ports[0] = RPC_PORT;

	for (port = 0; (port < MAX_PORTS) && ports[port]; port++) {
		memset(&rpc_helpers[port], 0, sizeof(struct ip_conntrack_helper));

		tmpname = &rpc_names[port][0];
		if (ports[port] == RPC_PORT)
			sprintf(tmpname, "rpc");
		else
			sprintf(tmpname, "rpc-%d", ports[port]);
		rpc_helpers[port].name = tmpname;

		rpc_helpers[port].me = THIS_MODULE;
		rpc_helpers[port].max_expected = 1;
		rpc_helpers[port].timeout = 5 * 60; /* stes */

		rpc_helpers[port].tuple.dst.protonum = IPPROTO_UDP;
		rpc_helpers[port].mask.dst.protonum = 0xff;

		/* RPC can come from ports 0:65535 to ports[port] (111) */
		rpc_helpers[port].tuple.src.u.udp.port = htons(ports[port]);
		rpc_helpers[port].mask.src.u.udp.port = htons(0xffff);
		rpc_helpers[port].mask.dst.u.udp.port = htons(0x0);

		rpc_helpers[port].help = help;

		PRINTK("registering helper for port #%d: %d/UDP\n", port, ports[port]);
		PRINTK("helper match ip   %u.%u.%u.%u:%u->%u.%u.%u.%u:%u\n",
			NIPQUAD(rpc_helpers[port].tuple.dst.ip),
			ntohs(rpc_helpers[port].tuple.dst.u.udp.port),
			NIPQUAD(rpc_helpers[port].tuple.src.ip),
			ntohs(rpc_helpers[port].tuple.src.u.udp.port));
		PRINTK("helper match mask %u.%u.%u.%u:%u->%u.%u.%u.%u:%u\n",
			NIPQUAD(rpc_helpers[port].mask.dst.ip),
			ntohs(rpc_helpers[port].mask.dst.u.udp.port),
			NIPQUAD(rpc_helpers[port].mask.src.ip),
			ntohs(rpc_helpers[port].mask.src.u.udp.port));

		ret = ip_conntrack_helper_register(&rpc_helpers[port]);

		if (ret) {
			printk("ERROR registering port %d\n",
				ports[port]);
			fini();
			return -EBUSY;
		}
		ports_n_c++;
	}
	return 0;
}
Ejemplo n.º 25
0
        int GenericCommunicator::init( int minId, int /*flag*/ )
        {
            VT_FUNC_I( "Dist::GenComm::init" );

            // Already running?
            if ( m_hasBeenInitialized ) {
                return 0;
            } else {
                m_hasBeenInitialized = true;
            }

            // Initialize ids:
            m_globalIdShift = minId;

            /*
             * NOTE: This method will be called from init() of a derived class.
             *       The derived class must have instantiated m_channel
             *       accordingly. Therefore, we can use m_channel here.
             */

            // A process cannot send a message to itself.
            // Therefore, disable this channel:
            CNC_ASSERT( m_channel );
            m_channel->deactivate( m_channel->localId() );

            // Start sender loop (same on host and on client):
            CNC_ASSERT( m_sendThread == 0 );
            m_sendThread = new SendThread( *m_channel );
#ifndef WITHOUT_SENDER_THREAD
# ifndef WITHOUT_SENDER_THREAD_TRACING
            m_sendThread->defineThreadName( "SEND", m_channel->localId() );
# endif
            m_sendThread->start();
#endif

            // Start receiver loop:
            CNC_ASSERT( m_recvThread == 0 );
            m_recvThread = new RecvThread( *this ); // needs whole instance, not only the channel
            if ( ! remote() || distributor::distributed_env() ) {
                // Host(s) runs the receiver loop in a separate thread.
                // Prepare receiver thread:
                m_recvThread->defineThreadName( "RECV" );
                m_recvThread->start();
            } else {
                // clients run it in the main thread
                m_recvThread->runEventLoop();
                fini();

                // On certain OSes (such as MIC), a call to "exit" is 
                // considered an abnormal termination, regarless of 
                // the argument. 
                if (m_exit0CallOk) exit( 0 ); 
            }

            return 0;
        }
Ejemplo n.º 26
0
bool MySqlShardingPool::addShardings(const std::vector<std::string> &urls) {
    for (size_t i = 0; i < urls.size(); ++i) {
        if (!addSharding(urls[i])) {
            fini();
            return false;
        }
    }

    return true;
}
Ejemplo n.º 27
0
static int invoke_member_fini(const struct mod_member *member) {
	const struct mod_member_ops *ops;
	mod_member_op_t fini;

	if (!(ops = member->ops) || !(fini = ops->fini)) {
		return 0;
	}

	return fini(member);
}
Ejemplo n.º 28
0
// Implementation skeleton destructor
TAO::FT_FaultNotifier_i::~FT_FaultNotifier_i ()
{
    try
    {
        fini ();
    }
    catch (...)
    {
    }
}
    void TestThread::run()
    {
        init()  ;
        m_Pool.onThreadInitDone( this )     ;

        test()  ;
        m_Pool.onThreadTestDone( this )     ;

        fini()  ;
        m_Pool.onThreadFiniDone( this )     ;
    }
Ejemplo n.º 30
0
void _fapModuleWrapper::unload()
{
   fini() ;

   if ( NULL != _loadModule )
   {
      _loadModule->unload() ;
      SDB_OSS_DEL _loadModule ;
      _loadModule = NULL ;
   }
}