Exemple #1
0
/**
 *	main function of program.
 *
 *	Return 0 if success, -1 on error. 
 */
int 
main(int argc, char **argv)
{
	if (_parse_cmd(argc, argv)) {
		_usage();
		return -1;
	}

	if (_initiate())
		return -1;

	if (cfg_load_file(_s_proxy, _s_cfgfile)) {
		_release();
		ERR_RET(-1, "parse config file %s failed\n", _s_cfgfile);
	}

	if (_s_vrycfg)	
		proxy_print(_s_proxy);		
	else 
		proxy_main(_s_proxy);

	_release();

	return 0;
}
Exemple #2
0
void _release(entry *e)
{
    if (e != NULL)
    {
        _release(e->pLeft);
        _release(e->pRight);
        e->pLeft = e->pRight = NULL;
        free(e);
    }
}
Exemple #3
0
		ThisClass(const ThisClass& source)
			: SuperClass(source)
		{
			//	이미 경로값은 assign이 끝나있다.
			//	_materials, _textures를 assign 방지를 위해서 정의하였다.
			_release();
		}
 AzSvect & operator =(const AzSvect &inp) {
   if (this == &inp) return *this; 
   _release(); 
   row_num = inp.row_num; 
   set(&inp); 
   return *this; 
 }
SecCamera::SecCamera(int ch) :
    _isInited(false),
    _previewWidth(0),
    _previewHeight(0),
    _previewPixfmt(-1),
    _previewFrameSize(0),
    _snapshotWidth(0),
    _snapshotHeight(0),
    _snapshotPixfmt(-1),
    _isPreviewOn(false),
    _isRecordOn(false),
    _v4l2Cam(NULL),
    _v4l2Rec(NULL),
    _encoder(NULL),
    _tagger(NULL)
{
    LOGI("%s()", __func__);

    _v4l2Cam = new SecV4L2Adapter(CAMERA_DEV_NAME, ch);
    _encoder = get_encoder();
    _tagger = get_tagger();

    if (_v4l2Cam->getFd() == 0) {
        _release();
        LOGE("!! %s: Failed to create SecCamera !!", __func__);
        return;
    }

    _initParms();

    _isInited = true;
}
Exemple #6
0
 void read(const char *fn) {
   _release(); 
   AzFile file(fn); 
   file.open("rb"); 
   read(&file); 
   file.close(); 
 }
Exemple #7
0
Shader& Shader::operator = (const Shader& other) {
    _release();
    _object = other._object;
    _refCount = other._refCount;
    _retain();
    return *this;
}
Exemple #8
0
int main(int argc, char **argv)
{
	xmlSAXHandler handler;
	int fd;
	int mid;

	if (_parse_cmd(argc, argv)) {
		_usage();
		return -1;
	}

	if (_init())
		return -1;

	memset(&handler, 0, sizeof(xmlSAXHandler));

	handler.startElement = _element_start;
	handler.endElement = _element_end;
	handler.error = _element_error;

	if (xmlSAXUserParseMemory(&handler, NULL, g_buffer, g_buflen) < 0) {
		printf("SAX parser error 1\n");
	}

	xmlCleanupParser();

	_release();

	return 0;
}
Exemple #9
0
/**
 *	The main entry of program.	
 *
 * 	Return 0 if success, other value on error.
 */
int 
main(int argc, char **argv)
{
	if (_parse_cmd(argc, argv)) {
		_usage();
		return -1;
	}

	if (_initiate()) {
		return -1;
	}

	switch (_g_type) {

	case TEST_STRING:
		_test_string();
		break;

	case TEST_DIR:
		_test_dir();

	default:
		break;

	}

	_release();

	return 0;
}
Exemple #10
0
/**
 *	The main entry of program.	
 *
 * 	Return 0 if success, other value on error.
 */
int 
main(int argc, char **argv)
{
	int i = 0;
	int j = 0;

	if (_parse_cmd(argc, argv)) {
		_usage();
		return -1;
	}

	if (_initiate()) {
		return -1;
	}

	alarm(1);
	while(1) {
		if (_g_count > 2)
			break;
		i++;
	}
	
	j = i;
	printf("j is %d\n", j);

	_release();

	return 0;
}
Exemple #11
0
/**
 *	The main entry of program.	
 *
 * 	Return 0 if success, other value on error.
 */
int 
main(int argc, char **argv)
{
	if (_parse_cmd(argc, argv)) {
		_usage();
		return -1;
	}

	if (_initiate()) {
		return -1;
	}

	printf("current pid is %d\n", getpid());

	if (_g_perf) {
		_sem_mutex_perf();
		return 0;
	}

	if (_g_op & SEM_OP_CREATE) {
		if (sem_mutex_create(_g_key))
			return -1;
		if (_g_verbose)
			sem_mutex_print(_g_key);
	}

	if (_g_op & SEM_OP_LOCK) {
		if (sem_mutex_lock(_g_key))
			return -1;

		if (_g_verbose)
			sem_mutex_print(_g_key);

	}
	
	if (_g_op & SEM_OP_UNLOCK) {
		if (sem_mutex_unlock(_g_key))
			return -1;

		if (_g_verbose)
			sem_mutex_print(_g_key);

//		_crash();
	}

	if (_g_op & SEM_OP_DESTROY) {
		if (sem_mutex_destroy(_g_key))
			return -1;
	}

	if (_g_verbose)
		if (sem_mutex_print(_g_key))
			return -1;

	_release();

	return 0;
}
		void quit()
		{
			if (!_thread.joinable())
				return;
			_commandQueue.autoPriorityEmplace<TMQ::CloseQueue>();
			_run = false;
			_thread.join();
			_release();
		}
Exemple #13
0
	//	---------------------------------------------------------------------------------	
	//	히스토리:	2011-07-07	이태훈	개발 완료
	//	---------------------------------------------------------------------------------
	NE_DLL NEScriptHeader::NEScriptHeader()
		: SuperClass(), 
		_max_namecode(0, NECodeType::NAME),
		_max_scriptcode(0, NECodeType::SCRIPT),
		_max_groupcode(0, NECodeType::GROUP),
		_max_prioritycode(0, NECodeType::PRIORITY)
	{
		_release();
	}
Exemple #14
0
static int
_drop_queue(struct message_queue *q) {
	// todo: send message back to message source
	struct skynet_message msg;
	int s = 0;
	while(!skynet_mq_pop(q, &msg)) {
		++s;
		free(msg.data);
	}
	_release(q);
	return s;
}
	/*/////////////////////////////////////////////////////////////////*/
	void OgreOggStreamSound::_stopImpl()
	{
		if(mSource != AL_NONE)
		{
			// Remove audio data from source
			_dequeue();

			// Stop playback
			mState = SS_STOPPED;

			if (mTemporary)
			{
				OgreOggSoundManager::getSingletonPtr()->_destroyTemporarySound(this);
				return;
			}

			// Jump to beginning if seeking available
			if ( mSeekable ) 
			{
				ov_time_seek(&mOggStream,0);
				mLastOffset=0;
				mStreamEOF=false;
			}
			// Non-seekable - close/reopen
			else
			{
				// Close
				_release();

				// Reopen
				_openImpl(mAudioStream);
			}

			// If marked for auto-destruction request destroy()
			if (mTemporary)
			{
				mAwaitingDestruction=true;
			}
			else
			{
				// Reload data
				_prebuffer();

				// Give up source immediately if specfied
				if (mGiveUpSource) OgreOggSoundManager::getSingleton()._releaseSoundSource(this);
			}
		
			// Notify listener
			if ( mSoundListener ) mSoundListener->soundStopped(this);
		}
	}
Exemple #16
0
int Configure::reload() {
	_fs = fopen(_file.c_str(), "r");
	_release(_root);
	_root = NULL;
	if (NULL == _fs) {
		fprintf(stderr, "conf file open error\n");
		throw exception(NOT_EXIST, "%s", _file.c_str());
	}
	_layers.clear();
	_parse();
	if (NULL != _fs) {
		fclose(_fs);
	}
	_fs = NULL;
	return CONF_SUCC;
};
Exemple #17
0
/**
 *	The main entry of program.	
 *
 * 	Return 0 if success, other value on error.
 */
int 
main(int argc, char **argv)
{
	if (_parse_cmd(argc, argv)) {
		_usage();
		return -1;
	}

	if (_initiate()) {
		return -1;
	}

	_release();

	return 0;
}
	//  [1/15/2009 zhangxiang]
	void sgFrameBufferManager::getSliceFromAnother(const sgFrameBufferManager &aParentBuffers,
												size_t aLeft, size_t aTop,
												size_t aWidth, size_t aHeight){
		_release();
		if(aParentBuffers.getColorBuffer()){
			m_pColorBuffer = new sgColorBuffer(*(aParentBuffers.getColorBuffer()),
											aLeft, aTop, aWidth, aHeight);
		}
		if(aParentBuffers.getDepthBuffer()){
			m_pDepthBuffer = new sgDepthBuffer(*(aParentBuffers.getDepthBuffer()),
											aLeft, aTop, aWidth, aHeight);
		}
		if(aParentBuffers.getStencilBuffer()){
			m_pStencilBuffer = new sgStencilBuffer(*(aParentBuffers.getStencilBuffer()),
												aLeft, aTop, aWidth, aHeight);
		}
	}
SecCamera::~SecCamera()
{
    LOGI("%s()", __func__);

    if (!_isInited) {
        LOGV("%s: Can't destroy! SecCamera not inited!", __func__);
        return;
    }

    LOGE_IF(this->stopPreview() < 0,
            "ERR(%s):Fail on stopPreview()\n", __func__);

    stopRecord();
    _release();

    _isInited = false;
}
void socket_buffer_pool_release(struct socket_buffer_pool* pool)
{
	struct socket_buffer* sb;
	LOCK(pool)
	while (pool->head != pool->tail)
	{
		sb = pool->queue[pool->head];
		if ( ++pool->head >= pool->cap)
		{
			pool->head = 0;
		}
		free_buffer(sb);
	}
	UNLOCK(pool)

	DeleteCriticalSection(&pool->cs);
	_release(pool);
}
Exemple #21
0
static int
_drop_queue(struct message_queue *q) {
	// todo: send message back to message source
	struct skynet_message msg;
	int s = 0;
	while(!skynet_mq_pop(q, &msg)) {
		++s;
		int type = msg.sz >> HANDLE_REMOTE_SHIFT;
		if (type == PTYPE_MULTICAST) {
			assert((msg.sz & HANDLE_MASK) == 0);
			skynet_multicast_dispatch((struct skynet_multicast_message *)msg.data, NULL, NULL);
		} else {
			free(msg.data);
		}
	}
	_release(q);
	return s;
}
/**
 *	The main entry of program.	
 *
 * 	Return 0 if success, other value on error.
 */
int 
main(int argc, char **argv)
{
	int i;
	struct timeval tv1, tv2;
	unsigned long sec, usec;


	if (_parse_cmd(argc, argv)) {
		_usage();
		return -1;
	}

	if (_initiate()) {
		return -1;
	}

	gettimeofday(&tv1, NULL);

	for (i = 0; i < _g_count; i++) {
		_g_pid = getpid();
	}

	gettimeofday(&tv2, NULL);

	if (tv2.tv_usec >= tv1.tv_usec) {
		usec = tv2.tv_usec - tv1.tv_usec;
	}
	else {
		usec = 1000000 + tv2.tv_usec - tv1.tv_usec;
		tv2.tv_sec--;
	}
	
	sec = tv2.tv_sec - tv1.tv_sec;

	printf("glibc syscall %d times spend %lu sec %lu usec\n",
	       _g_count, sec, usec);
	
	

	_release();

	return 0;
}
Exemple #23
0
/*-------------------------------------------------------------*/
void AzDmat::_set(const AzDmat *m_inp)
{
  const char *eyec = "AzDmat::set(Dmat)";   
  checkLock(eyec); 
  if (row_num != m_inp->row_num || col_num != m_inp->col_num) {
    _release(); 
    if (m_inp->col_num < 0 || m_inp->row_num < 0) {
      throw new AzException(eyec, "# columns or row must be non-negative"); 
    }
    col_num = m_inp->col_num; 
    row_num = m_inp->row_num; 
    a.alloc(&column, col_num, eyec, "column"); 
    dummy_zero.reform(row_num);   
  }
  int cx; 
  for (cx = 0; cx < col_num; ++cx) {
    delete column[cx]; 
    column[cx] = new AzDvect(m_inp->col(cx)); 
  }
}
bool indri::index::DiskKeyfileVocabularyIterator::_readData() {

  if( _bulkIterator->finished() ) {
    _release();
    return false;
  }

  int actual;
  int actualKeyLen;

  memset(_termString, 0, 1024);
  _bulkIterator->get( _termString, 1024, actualKeyLen, _compressedData.front(), _compressedData.size(), actual );
  indri::utility::RVLDecompressStream stream( _compressedData.front(), actual );

  _diskTermData = ::disktermdata_decompress( stream,
                                             _decompressedData.front(),
                                             _fieldCount,
                                             DiskTermData::WithOffsets |
                                             DiskTermData::WithTermID );

  _diskTermData->termData->term = _termString;
  return true;
}
Exemple #25
0
/*-------------------------------------------------------------*/
void AzDmat::_reform(int new_row_num, int new_col_num, 
                     bool do_zeroOut) 
{
  const char *eyec = "AzDmat::_reform";  
  checkLock(eyec); 
  if (row_num == new_row_num && col_num == new_col_num) {
    if (do_zeroOut) zeroOut(); 
    return; 
  }
 
  _release(); 
  if (new_col_num < 0 || new_row_num < 0) {
    throw new AzException(eyec, "# columns or row must be non-negative"); 
  }
  col_num = new_col_num; 
  row_num = new_row_num; 
  a.alloc(&column, col_num, eyec, "column"); 
  dummy_zero.reform(row_num);   
  
  int cx; 
  for (cx = 0; cx < col_num; ++cx) {
    column[cx] = new AzDvect(this->row_num); 
  }
}
Exemple #26
0
/**
 *	The main entry of program.	
 *
 * 	Return 0 if success, other value on error.
 */
int 
main(int argc, char **argv)
{
	int i;
	sigval_t sv;

	if (_parse_cmd(argc, argv)) {
		_usage();
		return -1;
	}

	if (_initiate()) {
		return -1;
	}

	for (i = 34; i < 64; i++) {
		sv.sival_int = i - 34;
		sigqueue(getpid(), i, sv);		
	}

	_release();

	return 0;
}
Exemple #27
0
natsStatus
natsSub_create(natsSubscription **newSub, natsConnection *nc, const char *subj,
               const char *queueGroup, natsMsgHandler cb, void *cbClosure,
               bool noDelay)
{
    natsStatus          s = NATS_OK;
    natsSubscription    *sub = NULL;

    sub = (natsSubscription*) NATS_CALLOC(1, sizeof(natsSubscription));
    if (sub == NULL)
        return nats_setDefaultError(NATS_NO_MEMORY);

    s = natsMutex_Create(&(sub->mu));
    if (s != NATS_OK)
    {
        NATS_FREE(sub);
        return NATS_UPDATE_ERR_STACK(s);
    }

    natsConn_retain(nc);

    sub->refs           = 1;
    sub->conn           = nc;
    sub->msgCb          = cb;
    sub->msgCbClosure   = cbClosure;
    sub->noDelay        = noDelay;
    sub->msgsLimit      = nc->opts->maxPendingMsgs;
    sub->bytesLimit     = nc->opts->maxPendingMsgs * 1024;
    sub->signalLimit    = (int)(sub->msgsLimit * 0.75);

    sub->subject = NATS_STRDUP(subj);
    if (sub->subject == NULL)
        s = nats_setDefaultError(NATS_NO_MEMORY);

    if ((s == NATS_OK) && (queueGroup != NULL) && (strlen(queueGroup) > 0))
    {
        sub->queue = NATS_STRDUP(queueGroup);
        if (sub->queue == NULL)
            s = nats_setDefaultError(NATS_NO_MEMORY);
    }
    if (s == NATS_OK)
        s = natsCondition_Create(&(sub->cond));
    if ((s == NATS_OK) && !(sub->noDelay))
    {
        // Set the interval to any value, really, it will get reset to
        // a smaller value when the delivery thread should be signaled.
        sub->signalTimerInterval = 10000;

        // Let's not rely on the created timer acquiring the lock that
        // would make it safe to retain only on success.
        _retain(sub);

        s = natsTimer_Create(&(sub->signalTimer),
                             _signalMsgAvailable,
                             _signalTimerStopped,
                             sub->signalTimerInterval, (void*) sub);
        if (s != NATS_OK)
            _release(sub);
    }
    if ((s == NATS_OK) && (cb != NULL))
    {
        // Let's not rely on the created thread acquiring the lock that
        // would make it safe to retain only on success.
        _retain(sub);

        // If we have an async callback, start up a sub specific
        // thread to deliver the messages.
        s = natsThread_Create(&(sub->deliverMsgsThread), natsSub_deliverMsgs,
                              (void*) sub);
        if (s != NATS_OK)
            _release(sub);
    }

    if (s == NATS_OK)
        *newSub = sub;
    else
        natsSub_release(sub);

    return NATS_UPDATE_ERR_STACK(s);
}
Exemple #28
0
		ThisClass(const ThisClass& rhs)
			: SuperClass(rhs), _font(0)
		{
			_release();
			getConnector().connect(getKeySet());
		}
Exemple #29
0
		ThisClass()
			: SuperClass(), _font(0)
		{
			_release();
		}
indri::index::DiskKeyfileVocabularyIterator::~DiskKeyfileVocabularyIterator() {
  _release();
  delete _bulkIterator;
}