Example #1
0
void cControls::FreeAll()
{
   DELETE_A(m_game);
   m_gsize = 0;

   DELETE_A(m_player);
   m_psize = 0;
}
Example #2
0
				~CopiedRow()
				{
					for (uint32 i = 0; i < m_row.n_columns; i++)
					{
						free(m_ref[i]);
					}
					DELETE_A(m_ref);
				}
Example #3
0
cLevelInfo::~cLevelInfo()
{
   DELETE_A(g);
   ng = 0;

   if(p != NULL)
   {
      uInt8 i;
      for(i = 0; i < np; ++i)
      {
         DELETE_A(p[i]);
      }

      delete [] p;
   }

   np = 0;
   na = 0;
}
Example #4
0
int cScriptEngine::Exit()
{
   if(m_cx != NULL)
   {
      JS_DestroyContext(m_cx);
      m_cx = NULL;
   }

	if(m_rt != NULL)
   {
      JS_Finish(m_rt);
      m_rt = NULL;
   }

   DELETE_A(m_script_code);

   return 0;
}
Example #5
0
    static void default_loghandler(LogLevel level, const char* filename, const char* function, int line,
                    const char* format, ...)
    {
        const char* levelstr = 0;
        uint64_t timestamp = get_current_epoch_millis();
        if (level > 0 && level < ALL_LOG_LEVEL)
        {
            levelstr = kLogLevelNames[level - 1];
        }
        else
        {
            levelstr = "???";
        }
        size_t log_line_size = k_default_log_line_buf_size;
        va_list args;
        std::string record;
        va_start(args, format);
        for (;;)
        {
            //char content[log_line_size + 1];
            char* content = new char[log_line_size + 1];
#ifndef va_copy
#define va_copy(dst, src)   memcpy(&(dst), &(src), sizeof(va_list))
#endif
            va_list aq;
            va_copy(aq, args);
            int sz = vsnprintf(content, log_line_size, format, aq);
            va_end(aq);
            if (sz < 0)
            {
                DELETE_A(content);
                return;
            }
            if ((size_t) sz < log_line_size)
            {
                record = content;
                DELETE_A(content);
                break;
            }
            log_line_size <<= 1;
            DELETE_A(content);
        }

        uint32 mills = timestamp % 1000;
        char timetag[256];
        struct tm& tm = get_current_tm();
        sprintf(timetag, "%02u-%02u %02u:%02u:%02u", tm.tm_mon + 1, tm.tm_mday, tm.tm_hour, tm.tm_min, tm.tm_sec);
        LockGuard<ThreadMutex> guard(kLogMutex);
        fprintf(kLogFile, "[%u] %s,%03u %s %s\n", getpid(), timetag, mills, levelstr, record.c_str());
        fflush(kLogFile);
        if (!kLogFilePath.empty() && kLogFile != stdout)
        {
            long file_size = ftell(kLogFile);
            if (file_size < 0)
            {
                reopen_default_logfile();
            }
            else if ((uint32) file_size >= k_max_file_size)
            {
                rollover_default_logfile();
                reopen_default_logfile();
            }
        }
    }