本文整理汇总了C++中Uninit函数的典型用法代码示例。如果您正苦于以下问题:C++ Uninit函数的具体用法?C++ Uninit怎么用?C++ Uninit使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了Uninit函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: snprintf
bool PosixSemaphore::Init(const char *fileName, const char *fileSuffix,
bool create, int initval) {
m_Create = create;
snprintf(m_FileName, sizeof(m_FileName), "%s%s", fileName, fileSuffix);
SID_VDBG("PosixSemaphore::Init sem %s, create: %d, initval: %d", m_FileName, create, initval);
/* android libc only supports sem_init, not sem_open. So we need to create small shm where we can place semaphore*/
if (!m_Shm.Init(m_FileName, sizeof(sem_t), create)) {
SID_ERROR("m_Shm.Init: %s: failed!, error %d %s", m_FileName, errno, strerror(errno));
Uninit();
return false;
}
m_Sem = (sem_t*)m_Shm.GetMemPtr();
if (create) {
if (sem_init(m_Sem, 0, initval) == -1) {
m_Sem = SEM_FAILED;
SID_ERROR("sem_init: %s: failed!, error %d %s", m_FileName, errno, strerror(errno));
Uninit();
return false;
}
}
return true;
}
示例2: Uninit
// Init
status_t
VirtualVolume::Init(const char* name)
{
status_t error = Volume::Init(name);
if (error != B_OK)
return error;
// get an ID for the root node
vnode_id rootNodeID = fVolumeManager->NewNodeID(this);
if (rootNodeID < 0) {
Uninit();
return rootNodeID;
}
// create the root node
fRootNode = new(std::nothrow) VirtualDir(this, rootNodeID);
if (!fRootNode) {
Uninit();
fVolumeManager->RemoveNodeID(rootNodeID);
return B_NO_MEMORY;
}
error = fRootNode->InitCheck();
if (error != B_OK) {
Uninit();
return error;
}
return B_OK;
}
示例3: ServerConnectionProvider
// Init
status_t
ServerVolume::Init(const char* name)
{
status_t error = VirtualVolume::Init(name);
if (error != B_OK)
return error;
// create the server connection provider
fConnectionProvider = new ServerConnectionProvider(fVolumeManager,
fServerInfo, GetRootID());
if (!fConnectionProvider) {
Uninit();
return B_NO_MEMORY;
}
error = fConnectionProvider->Init();
if (error != B_OK) {
Uninit();
return error;
}
// add share volumes
int32 count = fServerInfo->CountShares();
for (int32 i = 0; i < count; i++) {
ExtendedShareInfo* shareInfo = fServerInfo->ShareInfoAt(i);
error = _AddShare(shareInfo);
if (error != B_OK) {
ERROR("ServerVolume::Init(): ERROR: Failed to add share `%s': "
"%s\n", shareInfo->GetShareName(), strerror(error));
}
}
return B_OK;
}
示例4: gnutls_global_init
bool CTlsSocket::Init()
{
// This function initializes GnuTLS
m_initialized = true;
int res = gnutls_global_init();
if (res) {
LogError(res, _T("gnutls_global_init"));
Uninit();
return false;
}
#if TLSDEBUG
if (!pLoggingControlSocket) {
pLoggingControlSocket = m_pOwner;
gnutls_global_set_log_function(log_func);
gnutls_global_set_log_level(99);
}
#endif
res = gnutls_certificate_allocate_credentials(&m_certCredentials);
if (res < 0) {
LogError(res, _T("gnutls_certificate_allocate_credentials"));
Uninit();
return false;
}
if (!InitSession())
return false;
m_shutdown_requested = false;
// At this point, we can start shaking hands.
return true;
}
示例5: gnutls_init
bool CTlsSocket::InitSession()
{
int res = gnutls_init(&m_session, GNUTLS_CLIENT);
if (res) {
LogError(res, _T("gnutls_init"));
Uninit();
return false;
}
// Even though the name gnutls_db_set_cache_expiration
// implies expiration of some cache, it also governs
// the actual session lifetime, independend whether the
// session is cached or not.
gnutls_db_set_cache_expiration(m_session, 100000000);
res = gnutls_priority_set_direct(m_session, ciphers, 0);
if (res) {
LogError(res, _T("gnutls_priority_set_direct"));
Uninit();
return false;
}
gnutls_dh_set_prime_bits(m_session, 512);
gnutls_credentials_set(m_session, GNUTLS_CRD_CERTIFICATE, m_certCredentials);
// Setup transport functions
gnutls_transport_set_push_function(m_session, PushFunction);
gnutls_transport_set_pull_function(m_session, PullFunction);
gnutls_transport_set_ptr(m_session, (gnutls_transport_ptr_t)this);
return true;
}
示例6: SID_DBG
bool MmapShm::Init(const char *fileName, int size, int create) {
SID_DBG("Shm::Init: %s, size: %d, create: %d", fileName, size, create);
m_Create = create;
m_Size = size;
strncpy(m_FileName, fileName, sizeof(m_FileName));
int m_Fd = open(m_FileName, (create ? O_CREAT | O_RDWR : O_RDWR), 0600);
if (m_Fd < 0) {
SID_ERROR( "ShmChannel: open failed: file %s, errno: %d, strerror(errno): %s", m_FileName, errno, strerror(errno));
Uninit();
return false;
}
if (create) {
if (ftruncate(m_Fd, size) == -1) {
SID_ERROR( "ShmChannel: ftruncate failed: file %s, errno: %d, strerror(errno): %s", m_FileName, errno, strerror(errno));
Uninit();
return false;
}
}
if ((int)(m_Shmemory = (unsigned char *)mmap(0, size, PROT_READ|PROT_WRITE, MAP_SHARED, m_Fd, 0)) == -1) {
SID_ERROR( "ShmChannel: mmap failed: file %s, errno: %d, strerror(errno): %s", m_FileName, errno, strerror(errno));
Uninit();
return false;
}
return true;
}
示例7: gnutls_global_init
bool CTlsSocket::Init()
{
// This function initializes GnuTLS
int res = gnutls_global_init();
if (res)
{
LogError(res);
return false;
}
m_initialized = true;
res = gnutls_certificate_allocate_credentials(&m_certCredentials);
if (res < 0)
{
LogError(res);
Uninit();
return false;
}
res = gnutls_init(&m_session, GNUTLS_CLIENT);
if (res)
{
LogError(res);
Uninit();
return false;
}
res = gnutls_set_default_priority(m_session);
if (res)
{
LogError(res);
Uninit();
return false;
}
// Set which type of certificates we accept
const int cert_type_priority[] = { GNUTLS_CRT_X509, 0 };
gnutls_certificate_type_set_priority(m_session, cert_type_priority);
if (res)
{
LogError(res);
Uninit();
return false;
}
gnutls_credentials_set(m_session, GNUTLS_CRD_CERTIFICATE, m_certCredentials);
// Setup transport functions
gnutls_transport_set_push_function(m_session, PushFunction);
gnutls_transport_set_pull_function(m_session, PullFunction);
gnutls_transport_set_ptr(m_session, (gnutls_transport_ptr_t)this);
gnutls_transport_set_lowat(m_session, 0);
m_shutdown_requested = false;
// At this point, we can start shaking hands.
return true;
}
示例8: Uninit
bool CTaskProcessor::Init()
{
Uninit(); // if already initialized
// Initialize the Task Queue. If successful...
if (m_queueTasks.Init())
{
// Create an Event which can be asserted to stop the processor. If successful...
if (m_hStop = CreateEvent(NULL, TRUE, FALSE, NULL))
{
THREAD_INIT_PARAM stParam;
stParam.m_pThis = this;
stParam.m_bInitResult = false;
// Create an Event which, when asserted, will signal that the thread is initialized.
// If successful...
if (stParam.m_hInitEvent = CreateEvent(NULL, TRUE, FALSE, NULL))
{
UINT nThread = 0;
if (m_hThread = (HANDLE) _beginthreadex(NULL, 0, ProcessingFunc, &stParam, 0, &nThread))
{
DWORD dwRes = WaitForSingleObject(stParam.m_hInitEvent, m_dwStartupTimeout);
if (WAIT_OBJECT_0 == dwRes)
{
if (stParam.m_bInitResult)
return true;
else
AddLog(LOG_ERROR, _T("Task processor failed to initialize"));
}
else
{
if (WAIT_TIMEOUT == dwRes)
AddLog(LOG_ERROR, _T("Task processor initialization timed out"));
else
AddLog(LOG_ERROR, _T("WaitForSingleObject failed"));
}
}
else
AddLog(LOG_ERROR, _T("_beginthreadex failed"));
}
else
AddLog(LOG_ERROR, _T("CreateEvent failed"));
}
else
AddLog(LOG_ERROR, _T("CreateEvent failed"));
}
else
AddLog(LOG_ERROR, _T("Failed to create the queue"));
Uninit();
return false;
}
示例9: MOD_SERIALIZE_INIT_READ
/// reads in danger plots info
void CvDangerPlots::Read(FDataStream& kStream)
{
// Version number to maintain backwards compatibility
uint uiVersion;
kStream >> uiVersion;
MOD_SERIALIZE_INIT_READ(kStream);
kStream >> m_ePlayer;
kStream >> m_bArrayAllocated;
int iGridSize;
kStream >> iGridSize;
Uninit();
m_DangerPlots = FNEW(CvDangerPlotContents[iGridSize], c_eCiv5GameplayDLL, 0);
m_bArrayAllocated = true;
for (int i = 0; i < iGridSize; i++)
{
kStream >> m_DangerPlots[i];
}
m_knownUnits.clear();
int iCount;
kStream >> iCount;
for (int i=0; i<iCount; i++)
{
int iTemp1,iTemp2;
kStream >> iTemp1;
kStream >> iTemp2;
m_knownUnits.insert( std::make_pair((PlayerTypes)iTemp1,iTemp2) );
}
m_bDirty = false;
}
示例10: Uninit
int CMySqlAccess::Reinit()
{
Uninit();
mysql_init(m_mysql);
m_res_ptr = NULL;
if (mysql_library_init(0, NULL, NULL))
{
printf("mysql_library_init return failed\n");
return -1;
}
if ((m_mysql = mysql_init(NULL)) == NULL)
{
printf("mysql_init return failed, errinfo = %s\n", mysql_error(m_mysql));
return -1;
}
MYSQL *connect = mysql_real_connect(m_mysql, m_strHost.c_str(),
m_strUid.c_str(), m_strPasswd.c_str(),
m_strDb.c_str(), 0, NULL, 0);
if (connect == NULL)
{
printf("%s\n", mysql_error(m_mysql));
mysql_close(m_mysql);
return -1;
}
// printf(">>> init end\n");
return 0;
}
示例11: mysql_query
bool CDBSrcMySql::ExecSql(void)
{
int re = -1;
re = mysql_query(m_DBHandle, m_strSql.c_str());
if(re != 0)
{
int iError = mysql_errno(m_DBHandle);
if (iError == CR_SERVER_GONE_ERROR) //2006 server has gone away
{
//mysql_ping(m_DBHandle);
//mysql_query(m_DBHandle, "set names 'gb2312';");
Uninit();
//Disconnect();
Init();
while(! Connect(m_strConnStr))
Disconnect();
re = mysql_query(m_DBHandle, m_strSql.c_str());
}
}
if (re == 0)
{
//mysql_commit(m_DBHandle);
return true;
}
return false;
}
示例12: Uninit
void IsuCompetition::AddEvent(OsisEvent* newEvent)
{
if (!newEvent)
{
return;
}
if (newEvent->Id == -1)
{
delete newEvent;
return;
}
if (!Current_Event)
{
Current_Event = newEvent;
return;
}
if (Current_Event->Id != newEvent->Id)
{
Uninit();
Current_Event = newEvent;
}
else
{
Current_Event->Update(newEvent);
}
}
示例13: Remove
//---------------------------------------------------------------------------
void tTVPTimerThread::Remove(tTJSNI_Timer *item)
{
if(TVPTimerThread)
{
if(!TVPTimerThread->RemoveItem(item)) Uninit();
}
}
示例14: main
int main(int argc, char **argv)
{
if (!Init())
{
LOG::Message("Initialization failed.");
AppRunning = false;
}
for (unsigned i = 0; i < argc; i++)
LOG::Message(argv[i]);
time_t lastTime = time(0);
while(AppRunning)
{
SDL_Event event;
while (SDL_PollEvent(&event))
Listen(event);
time_t newTime = time(0);
if (newTime > lastTime)
{
OnTick();
OnFrame();
lastTime = newTime;
}
}
if (!Uninit())
LOG::Message("Uninitialization failed.");
return 0;
}
示例15: remove_handler
CTlsSocket::~CTlsSocket()
{
remove_handler();
Uninit();
delete m_pSocketBackend;
}